cesarvr / pdf-generator

Cordova plugin to generate pdf in the client-side
MIT License
107 stars 61 forks source link

Android - Paper Size is always set to A4 #60

Closed wnbittle closed 6 years ago

wnbittle commented 6 years ago

On Android, it seems to be applying a max width to the page (when passing HTML).

The effect is that when the HTML is printed, it's not full width in Paper size = Letter (A4?). Changing the Paper size to something else that's smaller, works and the HTML is resized to fit as expected. Changing the Paper size back to Letter or a paper size larger than Letter, it doesn't fit the whole page. You can also see this when changing the orientation to landscape with Letter size.

Looking at the source code, the problem seems to be in the PDFPrinter class here. From what I read, regardless of the user selected print size, this code will force it to render in A4. I'm not sure why that code is there, perhaps to solve some other problem, or maybe some testing code? Either way, when I change that method to: return attrs; The printing now works as expected, resizing and filling the whole page in all print sizes.

Thanks, William

cesarvr commented 6 years ago

Hi William,

Thanks for reporting, would you send a PR ? as it seems that you have located the source of bug.

Thanks.

cesarvr commented 6 years ago

Just fixed the landscape and document size in Android just download the new version of the plugin 2.0.

If you want to see it working just download this demo, I have added an example allowing to chose different page sizes (A1,A2,A3,A4) and orientations.

Cheers