-
Notifications
You must be signed in to change notification settings - Fork 13
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
Custom Paper Sizes #10
Comments
Also it's probably good to allow setting margins in GtkPageSetup. |
Yeah for sure! Another good polymorphic candidate? Webkit().load('google.com').wait('idle').pdf({
margins: 0
});
// Or
Webkit().load('google.com').wait('idle').pdf({
margins: {
left: 20,
right: 20,
top: 15,
bottom: 25,
unit: 'mm'
}
}); Removes the need for full page? |
Would it be easier to translate the opts object on the JS end? WebKit.prototype.pdf = function() {
var filepath = arguments[0];
var opts, cb;
if (arguments[1] instanceof Function) {
opts = {};
cb = arguments[1];
} else {
opts = arguments[1] || {};
cb = arguments[2] || noop;
}
if (typeof opts.paper === 'string') {
opts.gtkPaperName = opts.paper;
} else if (opts.paper) {
opts.customPaperWidth = opts.paper.width;
opts.customPaperHeight = opts.paper.height;
opts.customPaperUnit = opts.paper.unit || 'mm';
}
delete opts.paper;
if (typeof opts.margins === 'number') {
opts.marginLeft = opts.marginRight = opts.marginTop = opts.marginBottom = opts.margins;
} else if (opts.margins) {
opts.marginLeft = opts.margins.left || 0;
opts.marginRight = opts.margins.right || 0;
opts.marginTop = opts.margins.top || 0;
opts.marginBottom = opts.margins.bottom || 0;
opts.marginUnit = opts.margins.unit;
}
opts.marginUnit = opts.marginUnit || 'mm';
delete opts.margins;
pdf.call(this, filepath, opts, cb);
}; ... roughly. This might make the job on the extension side easier. Or would you prefer no translation between the opts in the JS / c++ APIs? |
Having a look at this. Nearly there, going to add some tests, and seek out c++ advice :) |
Great !
|
Also note that you can also leave it like this and i can take inspiration from your code instead of merging your commits if you don't want to bother with the details :) |
No problem! Happy to help as much as I can. Will add tests for variations of that paper object, including not having one (to see if that default ever gets executed). I've been looking around for info on The Will remove the OSX notes and set up an Installation guide in the wiki. Oh, and will definitely make sure to keep Thanks. |
@bradparker if you're still printing pdf out of webkitgtk, maybe you'd have something to say about https://lists.webkit.org/pipermail/webkit-gtk/2015-September/002435.html |
Being able to feed in GTK paper size names is awesome, thank you. However we wondered what might involved in adding something even more flexible.
We'd love to contribute more directly but we don't speak c/c++, sorry. We're also unfamiliar with v8 / WebKitGTK. We figured we'd talk through how we thought this might work and try to help as much as we can.
I'm not sure how this would work on the c++ side but having that paper param be polymorphic would be pretty cool, perhaps...
... and here's some pseudo code which may / may not be of any help.
I really hope that's helpful. Thanks.
The text was updated successfully, but these errors were encountered: