Giter VIP home page Giter VIP logo

ngx-printer-demo's People

Contributors

dependabot[bot] avatar ngoquoc avatar plaetzchen79 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ngx-printer-demo's Issues

ngx-printer element is not higing in Chrome after print dialog on current page

Everything was ok before Google Chrome updated to v.109.0.5414.75
I have downloaded and installed Chrome v.108.0.5359.125 and it works.

I use the next code (ngx-printer: 0.7.0):

print(): void {
    this.printerService.printOpenWindow = false;
    this.printerService.printDiv('check');
    this.printerService.printOpenWindow = true;
}

It works in Firefox and Edge, but in Chrome (after update) element ngx-printer is not hidding after print dialog.

<!DOCTYPE html> == $0
<html lang="en" class="plt-tablet pit-desktop md hydrated" mode="md">
<head>...</head>
<body class="backdrop-no-scroll">
    <bk-root _nghost-sjq-c166 ng-version="9.1.13">...</bk-root>
    <script src="runtime.js" type="module"></script>
    <script src="polyfills.js" type="module"></script>
    <script src="stvles.js" type="module"></script>
    <script src="vendor.js" type="module"></script>
    <script src="main.js" type="module"></script>
    <scribe-shadow id="shadow-root-scribe-elem" style="position: fixed; width: 0px; height: 0px; top: 0px; left: 0px; z-index: 2147483647; overflow: visible;">...</scribe-shadow>
    <ngx-printer _nghost-sjq-c134 class="ngx-printer">...</ngx-printer>
</body>
</html>

Demo-page has the same behaviour.
What can I do to fix this?

Cancel print window not removing default CSS on first page load.

I'm using printDivToCurrent() function to print a specific div (print div to current window).

Issue - When I click on cancel print button in print preview popup, then the webpage becomes non-responsive & default CSS not removing from the DOM. The elements that are hidden during printing doen't come again in the DOM.

But when I reload the same page & again check the print functionality then on cancelling the print preview dialog box, webpage comes to normal state, hidden elements becomes visible & functionality works fine.

The issue is also reproducible in official demo - https://plaetzchen79.github.io/

Check the screencast here - https://nimb.ws/T1Dwrq

To check the scenario :

  1. Open the demo page in incognito.
  2. Click on "Print div to current window" button.
  3. When you click on cancel button in print preview dialog box, the webpage not return to normal state (Other DOM elements are not visible).
  4. Now, reload the same page & again repeat the same process. But this time webpage return to normal state & other elements are now visible.

useExistingCss does not work

I tried useExistingCss and styleSheetFile both are not working. only printStyle is working fine. Here is my code

....
print

Unable to install ngx-printer

Error trying to install ngx-printer.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"~13.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^15.0.0" from [email protected]
npm ERR! node_modules/ngx-printer
npm ERR! ngx-printer@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! C:\Users\hp\AppData\Local\npm-cache_logs\2023-01-30T04_38_24_455Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hp\AppData\Local\npm-cache_logs\2023-01-30T04_38_24_455Z-debug-0.log
PS E:\asol\AlphaSalesOnlineFrontEnd\ALphaSales> npm i ngx-printer
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree

Print selective items inside a div

Hi Plaetzchen79,
Is there any option to print selective elements inside a div.

Ex:

This shouldnt be printed This should be printed
In my project i have an usecase where i have to skip printing certain elements in my html. Can u pls let me know whether there is an option to do this. In ng-print library we have a directive called noPrint, which will allow us to hide certain elements in Print.

unable to print from same window/tab

i want to print page without opening new tab so i had set root config as

in app.module
NgxPrinterModule.forRoot({printOpenWindow: false});

featureModule have sales feature so i have to print bill so code as
in sales component i have call print component from shared module
<button (click)="printHTMLElementToCurrent()">print</button> <app-print #printContainer> </app-print>

sales.component.ts

`
@ViewChild('printContainer', {read: ElementRef}) PrintComponent: ElementRef | undefined;

constructor(private printerService: NgxPrinterService) { }
ngOnInit(): void {
}
printHTMLElementToCurrent(): void {
this.PrintComponent &&
this.printerService.printHTMLElement(this.PrintComponent.nativeElement);
}
`
i need help to fixed this issue

angular dependency

"
"dependencies": {
"@angular/animations": "~10.0.0",
"@angular/cdk": "^11.0.0",
"@angular/common": "~10.0.0",
"@angular/compiler": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@prajna10/sd_design": "0.0.29",
"ngx-printer": "^0.9.1",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
}

Add directive ngxPrintItemButton

If you want to print a single item from the list of ngxPrintItems without ts you can use the diretive ngxPrintItemButton. You have to know the id of the printItem.

printDiv does not work on mobile browsers

I have tried the demo https://plaetzchen79.github.io/ and I must say all work really well.

However, I need to use this component on a mobile angular project. And, I found that the printDiv does not work on mobile browsers (on phones), such as Chrome.

All I get is a new window with a printer icon, and a message which says "There was a problem printing the page. Please try again."

Compatible with Ivy (angular 10).

getting error just after importing in app.module

"This likely means that the library (ngx-printer/lib/ngx-printer.module) which declares NgxPrinterModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy."

White Space on top

This library works wonder, but whenever I print my angular component, in all the pages once the PDF is finished there is always a really big white space that takes around 15% of the view, how can that whites space be eliminated ?

The `printOpenWindow` can not load the global style.css

My Angular app is using the default PathLocationStragey

And in one of my page, says /masterPage/detail/:id, I have this printing functionality set up:

this._printerService.timeToWaitRender = 1500;
this._printerService.printOpenWindow = true;

this._printerService.printDiv('myDivId');

Issue: when it opens the print window, it has the following stylesheet tag in the generated HTML document:
<link rel="stylesheet" href="styles.76979927b9a7bc88a048.css">

However, the browser tries to look at {hostname}/masterPage/detail/styles.76979927b9a7bc88a048.css instead of {hostname}/styles.76979927b9a7bc88a048.css.

I actually checked the implementation of copyCss functionality and everything looks great:

private copyCss(printWindowDoc: Document) {
const links = document.querySelectorAll('link');
const styles = document.querySelectorAll('style');
const targetHead = printWindowDoc.getElementsByTagName('head')[0];
links.forEach(link => {
targetHead.appendChild(document.importNode(link, true));
});
styles.forEach(style => {
targetHead.appendChild(document.importNode(style, true));
});
}

However, it only copies the link and style tags, and ignores everything else. What I think it should do is to copy also the base tag which tells the browser what would be the relative path of the CSS resources to load from.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.