Bug 214602
Summary: | WKPDFConfiguration should have option to specify final PDF size | ||
---|---|---|---|
Product: | WebKit | Reporter: | Brad Andalman <bya> |
Component: | WebKit API | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | beidson, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | Other | ||
Hardware: | Mac | ||
OS: | macOS 10.15 |
Brad Andalman
Currently, the createPDF() method on WKWebView uses the rect in WKPDFConfiguration and a dpi of 72 to create the final PDF. That means that there is no way to change the size of the final PDF – you get what you get based on the rect.
It would be great if that were configurable. The current "rect" property is really the source rect, so perhaps a "destRect" property on WKPDFConfiguration could be considered. Another way to think of this is a scale on the rect, or even just a configurable dpi (if the destRect/scale options are too general).
The motivation: we are trying to use WKWebViews in our application, instead of the legacy WebViews. Our app, though, needs to generate PDFs of an exact size (for publishing). We also want to show a preview of the PDF to our users – but the size that we need for the PDF would be too small for our users.
For this reason (and others), we use a rect that is twice as big as the dimensions of the final PDF. With the old WebViews, we can use CGContextScaleCTM in between CGPDFContext{Begin,End}Page calls, and our final PDF will have the correct, halved, size. Unfortunately, there is no great way to do this with the current API on WKWebView.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/65914286>