Compare commits

...

8 Commits

Author SHA1 Message Date
Jonas Jenwald
63e6566597
Merge pull request #19816 from Snuffleupagus/bug-1957401
Add a "supportsPrinting" viewer-option (bug 1957401)
2025-04-22 15:25:20 +02:00
Jonas Jenwald
213d51d7e9
Merge pull request #19823 from Snuffleupagus/rm-duplicate-secondaryToolbar-mask-image
Remove duplicate secondaryToolbar button `mask-image` definitions (PR 18385 follow-up)
2025-04-22 15:14:47 +02:00
Jonas Jenwald
c8ed291cf9
Merge pull request #19836 from Snuffleupagus/issue-19835
Always fallback to checking all destinations, when lookup fails (issue 19835)
2025-04-22 15:14:05 +02:00
Jonas Jenwald
c63c51e016
Merge pull request #19841 from Snuffleupagus/issue-19840
Fix printing of XFA documents, by calling `XfaLayerBuilder.prototype.render` correctly (issue 19840)
2025-04-22 15:12:46 +02:00
Jonas Jenwald
b4626a77a2 Fix printing of XFA documents, by calling XfaLayerBuilder.prototype.render correctly (issue 19840)
When changing the format of various `render`-methods in PR 19365 I forgot to update the code used to print XFA documents, sorry about that.
2025-04-22 09:15:52 +02:00
Jonas Jenwald
adc9eb5a5a Always fallback to checking all destinations, when lookup fails (issue 19835)
In the referenced PDF document the keys, in the /Dests dictionary, need to account for PDFDocEncoding.
To improve destination handling in general we'll now unconditionally fallback to always checking all destinations.
2025-04-20 14:53:10 +02:00
Jonas Jenwald
8e7060158e Remove duplicate secondaryToolbar button mask-image definitions (PR 18385 follow-up)
It appears that all secondaryToolbar buttons currently have their `mask-image` definitions duplicated, which leads to larger than necessary CSS files.
2025-04-17 10:51:51 +02:00
Jonas Jenwald
97fe7d6a19 Add a "supportsPrinting" viewer-option (bug 1957401)
This will allow us to respect the `print.enabled` Firefox preference, by extending [this method](https://searchfox.org/mozilla-central/rev/56117379696ea0cffb94cd09c14cd022a8c5e4e8/toolkit/components/pdfjs/content/PdfStreamConverter.sys.mjs#426-453), which will hide the toolbar and secondaryToolbar print-buttons.
2025-04-15 12:43:11 +02:00
8 changed files with 48 additions and 79 deletions

View File

@ -682,7 +682,7 @@ class Catalog {
const dest = fetchDest(value);
if (dest) {
// Always let the NameTree take precedence.
dests[key] ||= dest;
dests[stringToPDFString(key)] ||= dest;
}
}
}
@ -701,12 +701,12 @@ class Catalog {
}
}
if (rawDests[0] instanceof NameTree) {
// Fallback to checking the *entire* NameTree, in an attempt to handle
// corrupt PDF documents with out-of-order NameTrees (fixes issue 10272).
// Always fallback to checking all destinations, in order to support:
// - PDF documents with out-of-order NameTrees (fixes issue 10272).
// - Destination keys that use PDFDocEncoding (fixes issue 19835).
if (rawDests.length) {
const dest = this.destinations[id];
if (dest) {
warn(`Found "${id}" at an incorrect position in the NameTree.`);
return dest;
}
}

View File

@ -0,0 +1 @@
https://github.com/user-attachments/files/19825124/AAPL-2024-09-28-10-K-d71aeb7ff955e2fc4770624610676221.pdf

View File

@ -23,6 +23,14 @@
"link": true,
"type": "other"
},
{
"id": "issue19835",
"file": "pdfs/issue19835.pdf",
"md5": "2940a2f8a41fae299b9a599b8364d05c",
"rounds": 1,
"link": true,
"type": "other"
},
{
"id": "filled-background-range",
"file": "pdfs/filled-background.pdf",

View File

@ -1399,6 +1399,28 @@ describe("api", function () {
await loadingTask.destroy();
});
it("gets a destination, from /Dests dictionary with keys using PDFDocEncoding", async function () {
if (isNodeJS) {
pending("Linked test-cases are not supported in Node.js.");
}
const loadingTask = getDocument(buildGetDocumentParams("issue19835.pdf"));
const pdfDoc = await loadingTask.promise;
const page3 = await pdfDoc.getPage(3);
const annots = await page3.getAnnotations();
const annot = annots.find(x => x.id === "22R");
// Sanity check to make sure that we found the "correct" annotation.
expect(annot.dest).toEqual(
"\u00f2\u00ab\u00d9\u0025\u006f\u2030\u0062\u2122\u0030\u00ab\u00f4\u0047\u0016\u0142\u00e8\u00bd\u2014\u0063\u00a1\u00db"
);
const dest = await pdfDoc.getDestination(annot.dest);
expect(dest).toEqual([2, { name: "XYZ" }, 34.0799999, 315.439999, 0]);
await loadingTask.destroy();
});
it("gets non-string destination", async function () {
let numberPromise = pdfDocument.getDestination(4.3);
let booleanPromise = pdfDocument.getDestination(true);

View File

@ -875,7 +875,12 @@ const PDFViewerApplication = {
},
get supportsPrinting() {
return PDFPrintServiceFactory.supportsPrinting;
return shadow(
this,
"supportsPrinting",
AppOptions.get("supportsPrinting") &&
PDFPrintServiceFactory.supportsPrinting
);
},
get supportsFullscreen() {

View File

@ -136,6 +136,11 @@ const defaultOptions = {
value: true,
kind: OptionKind.BROWSER,
},
supportsPrinting: {
/** @type {boolean} */
value: true,
kind: OptionKind.BROWSER,
},
toolbarDensity: {
/** @type {number} */
value: 0, // 0 = "normal", 1 = "compact", 2 = "touch"

View File

@ -35,7 +35,7 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
});
const viewport = getXfaPageViewport(xfaPage, { scale });
builder.render(viewport, "print");
builder.render({ viewport, intent: "print" });
page.append(builder.div);
}
}

View File

@ -549,10 +549,6 @@ body {
mask-image: var(--toolbarButton-zoomIn-icon);
}
#presentationMode::before {
mask-image: var(--toolbarButton-presentationMode-icon);
}
#editorFreeTextButton::before {
mask-image: var(--toolbarButton-editorFreeText-icon);
}
@ -577,20 +573,10 @@ body {
mask-image: var(--toolbarButton-print-icon);
}
/*#if GENERIC*/
#secondaryOpenFile::before {
mask-image: var(--toolbarButton-openFile-icon);
}
/*#endif*/
#downloadButton::before {
mask-image: var(--toolbarButton-download-icon);
}
#viewBookmark::before {
mask-image: var(--toolbarButton-bookmark-icon);
}
#currentOutlineItem::before {
mask-image: var(--toolbarButton-currentOutlineItem-icon);
transform: scaleX(var(--dir-factor));
@ -1665,64 +1651,6 @@ dialog :link {
}
}
#secondaryToolbar {
#firstPage::before {
mask-image: var(--secondaryToolbarButton-firstPage-icon);
}
#lastPage::before {
mask-image: var(--secondaryToolbarButton-lastPage-icon);
}
#pageRotateCcw::before {
mask-image: var(--secondaryToolbarButton-rotateCcw-icon);
}
#pageRotateCw::before {
mask-image: var(--secondaryToolbarButton-rotateCw-icon);
}
#cursorSelectTool::before {
mask-image: var(--secondaryToolbarButton-selectTool-icon);
}
#cursorHandTool::before {
mask-image: var(--secondaryToolbarButton-handTool-icon);
}
#scrollPage::before {
mask-image: var(--secondaryToolbarButton-scrollPage-icon);
}
#scrollVertical::before {
mask-image: var(--secondaryToolbarButton-scrollVertical-icon);
}
#scrollHorizontal::before {
mask-image: var(--secondaryToolbarButton-scrollHorizontal-icon);
}
#scrollWrapped::before {
mask-image: var(--secondaryToolbarButton-scrollWrapped-icon);
}
#spreadNone::before {
mask-image: var(--secondaryToolbarButton-spreadNone-icon);
}
#spreadOdd::before {
mask-image: var(--secondaryToolbarButton-spreadOdd-icon);
}
#spreadEven::before {
mask-image: var(--secondaryToolbarButton-spreadEven-icon);
}
#documentProperties::before {
mask-image: var(--secondaryToolbarButton-documentProperties-icon);
}
}
@media all and (max-width: 840px) {
#sidebarContainer {
background-color: var(--sidebar-narrow-bg-color);