mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
print: Improve rendering of oversized pages.
This improves and simplifies #13102 in order to make printing of test-cases like the one in bug 1698414 (where the real page is bigger than the target page) much better, see incoming screenshots. The reason why we need to stop setting .style.width / .style.height is to get the right auto-sizing behavior in both axes. This shouldn't change behavior as long as the print resolution is >= the CSS resolution, which seems like a reasonable assumption. If you try to print with a lower resolution than CSS, then instead of an stretched canvas, you'd get a centered CSS-quality canvas, which seems sensible. This could maybe be fixed with some CSS hackery (some combination of min / max and viewport units perhaps?), but I think it's more trouble than it's worth.
This commit is contained in:
parent
63471bcbbe
commit
81c7f905bc
3 changed files with 20 additions and 44 deletions
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
import { RenderingCancelledException, shadow } from "pdfjs-lib";
|
||||
import { CSS_UNITS } from "./ui_utils.js";
|
||||
import { PDFPrintServiceFactory } from "./app.js";
|
||||
|
||||
// Creates a placeholder with div and canvas with right size for the page.
|
||||
|
@ -33,14 +32,8 @@ function composePage(
|
|||
canvas.width = Math.floor(size.width * PRINT_UNITS);
|
||||
canvas.height = Math.floor(size.height * PRINT_UNITS);
|
||||
|
||||
// The physical size of the canvas as specified by the PDF document.
|
||||
canvas.style.width = Math.floor(size.width * CSS_UNITS) + "px";
|
||||
canvas.style.height = Math.floor(size.height * CSS_UNITS) + "px";
|
||||
|
||||
const canvasWrapper = document.createElement("div");
|
||||
canvasWrapper.appendChild(canvas);
|
||||
canvasWrapper.style.width = canvas.style.width;
|
||||
canvasWrapper.style.height = canvas.style.height;
|
||||
printContainer.appendChild(canvasWrapper);
|
||||
|
||||
// A callback for a given page may be executed multiple times for different
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue