Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to PDF #195

Merged
merged 3 commits into from
Jun 25, 2014
Merged

Add options to PDF #195

merged 3 commits into from
Jun 25, 2014

Conversation

bernardeli
Copy link
Contributor

Hi,

First of all, thanks for the great work that you've put into SlimerJS.

I couldn't be more excited when PDF rendering came out, unfortunately it does not honour width and height.

Looking at SlimerJS code, I realised it creates a print profile every time you render to PDF.
I have found all available print settings here: http://dxr.mozilla.org/mozilla-central/source/widget/nsIPrintSettings.idl

Having that said, I've tweaked the code to accept dimensions as well as ability to set margin and resolutions.

Dimensions must be passed as millimetres, and resolution in dpi.

This solves #162.

The options are:

printSettings.marginTop
printSettings.marginRight
printSettings.marginBottom
printSettings.marginLeft
printSettings.unwriteableMarginTop
printSettings.unwriteableMarginRight
printSettings.unwriteableMarginBottom
printSettings.unwriteableMarginLeft
printSettings.resolution
printSettings.paperWidth
printSettings.paperHeight

Also, I've bumped to gecko 30.0. I've got some really heavy html that loads heaps of SVG. I believe previous versions had memory leaks, and randomly crashed with Illegal instructions and Segmentation Fault. After updating, all errors have been solved apparently.

Please instruct me if you require anything else for merging this pull request, and hope it helps other developers!

Cheers
@bernardeli

@bernardeli
Copy link
Contributor Author

Forgot to say - I've been testing under a Ubuntu 14.04 box.

It opens the print settings on Mac, reported on #175.

@@ -253,6 +253,33 @@ var webpageUtils = {
}
},

getPrintOptions : function(webpage, options) {
let currentViewport = webpage.viewportSize;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems this variable is not used ;-)

@laurentj
Copy link
Owner

Thank you very much for this patch !! It seems good to me :-)

laurentj added a commit that referenced this pull request Jun 25, 2014
@laurentj laurentj merged commit 9098d7c into laurentj:master Jun 25, 2014
laurentj added a commit that referenced this pull request Jun 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants