EddyVerbruggen / nativescript-printer

:fax: Send an image or the screen contents to a physical printer
MIT License
36 stars 13 forks source link

Printing a view, only returns 1 page #5

Open AndersGerner opened 7 years ago

AndersGerner commented 7 years ago

I have tried to create both a WebView and a HTMLView, but even though the HTMLView has a height above 700, it still only shows one page.

Are those views not supported?

EddyVerbruggen commented 7 years ago

Can you share your code please.

AndersGerner commented 7 years ago

@EddyVerbruggen I cannot share all of it, since it contians confidential information about my client but let me try and see if I can give you all the code you need.

Here is a test app: https://www.dropbox.com/s/9b4p3z4po3cszxk/ns-printer-test.zip?dl=0 I sets up a htmlview and writes "Hello Eddy" 10 times as a H1. It only shows 5 of them in the print view.

Let me know if there are anyting else you need from me :)

AndersGerner commented 7 years ago

I could easily create a PDF with jsPDF and hand that off to the printer if that's an easier solution :)

EddyVerbruggen commented 7 years ago

I think that's a great plan. The HtmlView doesn't seem to want to play nice. Would you be able to turn it into an image instead so you can use the readily available printImage function?

AndersGerner commented 7 years ago

Maybe - I have a webview longer than the example, that I need to print. Maybe I should try and google for a HTML -> Image, and try that, but it would still be several pages. Can it handle that?

AndersGerner commented 7 years ago

@EddyVerbruggen Would something like this: https://github.com/tsayen/dom-to-image work? I won't have a real image, but a data representation of the image.

AndersGerner commented 7 years ago

@EddyVerbruggen Sorry for stalking you, but I really need your input. :)

EddyVerbruggen commented 7 years ago

I'm not sure what the question was. Do you want me to try something for you?

AndersGerner commented 7 years ago

@EddyVerbruggen I'm a bit pressured on time in my current project, and they demand to be able to print the whole webpage of my webview. For some reason the standard window.print doesn't work, and I, therefore, would like to use your plugin.

As you stated, the HTMLView does not play nice with this plugin, and since PDF is not a possibility (yet) you suggested to use an image.

What I need to know is: Would I be able to use something like https://github.com/tsayen/dom-to-image to get a data representation of the image, in this printer plugin? :)

Thank you very much for your help so far!

EddyVerbruggen commented 7 years ago

I understand, but answering that would require me to test that for you. Did you try printing an image that would be about the same size as the one you'd get from dom-to-image?

AndersGerner commented 7 years ago

No, I haven't tried that. I wanted to see if you would say with certainty that the data representation wouldn't work because it needed to be a real image. I didn't want to waste time. :)