Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ class WorkerMessageHandler {
pdfManager.ensureCatalog("acroFormRef"),
pdfManager.ensureDoc("startXRef"),
pdfManager.ensureDoc("xref"),
pdfManager.ensureDoc("linearization"),
pdfManager.ensureCatalog("structTreeRoot"),
];
const changes = new RefSetCache();
Expand All @@ -581,7 +580,6 @@ class WorkerMessageHandler {
acroFormRef,
startXRef,
xref,
linearization,
_structTreeRoot,
] = await Promise.all(globalPromises);
const catalogRef = xref.trailer.getRaw("Root") || null;
Expand Down Expand Up @@ -736,9 +734,7 @@ class WorkerMessageHandler {
infoRef: xref.trailer.getRaw("Info") || null,
infoMap,
fileIds: xref.trailer.get("ID") || null,
startXRef: linearization
? startXRef
: (xref.lastXRefStreamPos ?? startXRef),
startXRef,
filename,
};
}
Expand Down Expand Up @@ -905,11 +901,6 @@ class WorkerMessageHandler {
handler.on("GetXFADatasets", function (data) {
return pdfManager.ensureDoc("xfaDatasets");
});
handler.on("GetXRefPrevValue", function (data) {
return pdfManager
.ensureXRef("trailer")
.then(trailer => trailer.get("Prev"));
});
handler.on("GetStartXRefPos", function (data) {
return pdfManager.ensureDoc("startXRef");
});
Expand Down
10 changes: 0 additions & 10 deletions src/core/xref.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { BaseStream } from "./base_stream.js";
import { CipherTransformFactory } from "./crypto.js";

class XRef {
#firstXRefStmPos = null;

constructor(stream, pdfManager) {
this.stream = stream;
this.pdfManager = pdfManager;
Expand Down Expand Up @@ -754,7 +752,6 @@ class XRef {
// (possible infinite recursion)
this._xrefStms.add(obj);
this.startXRefQueue.push(obj);
this.#firstXRefStmPos ??= obj;
}
} else if (Number.isInteger(obj)) {
// Parse in-stream XRef
Expand Down Expand Up @@ -803,13 +800,6 @@ class XRef {
throw new XRefParseException();
}

get lastXRefStreamPos() {
return (
this.#firstXRefStmPos ??
(this._xrefStms.size > 0 ? Math.max(...this._xrefStms) : null)
);
}

getEntry(i) {
const xrefEntry = this.entries[i];
if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
Expand Down
3 changes: 0 additions & 3 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,6 @@ class PDFDocumentProxy {
Object.defineProperty(this, "getXFADatasets", {
value: () => this._transport.getXFADatasets(),
});
Object.defineProperty(this, "getXRefPrevValue", {
value: () => this._transport.getXRefPrevValue(),
Comment thread
calixteman marked this conversation as resolved.
});
Object.defineProperty(this, "getStartXRefPos", {
value: () => this._transport.getStartXRefPos(),
});
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue20302.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/user-attachments/files/22526382/JADC2.via.ABMS.PDF
22 changes: 22 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13027,5 +13027,27 @@
"md5": "cc53e96a8fd9eafbfbb74de564f37047",
"rounds": 1,
"type": "eq"
},
{
"id": "issue20302-save-print",
"file": "pdfs/issue20302.pdf",
"md5": "d8db2fa1889fd14effcfa5b597b6fe7b",
"rounds": 1,
"lastPage": 1,
"type": "eq",
"link": true,
"save": true,
"print": true,
"annotationStorage": {
"pdfjs_internal_editor_0": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": "Hello World",
"pageIndex": 0,
"rect": [115, 325, 171, 342],
"rotation": 0
}
}
}
]
8 changes: 5 additions & 3 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,8 @@ describe("api", function () {

let loadingTask = getDocument(buildGetDocumentParams("bug1823296.pdf"));
let pdfDoc = await loadingTask.promise;
let page = await pdfDoc.getPage(1);
const originalStructTree = await page.getStructTree();
pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_0", {
annotationType: AnnotationEditorType.FREETEXT,
rect: [12, 34, 56, 78],
Expand All @@ -2514,9 +2516,9 @@ describe("api", function () {

loadingTask = getDocument(data);
pdfDoc = await loadingTask.promise;
const xrefPrev = await pdfDoc.getXRefPrevValue();

expect(xrefPrev).toEqual(143954);
page = await pdfDoc.getPage(1);
const newStructTree = await page.getStructTree();
expect(newStructTree).toEqual(originalStructTree);

await loadingTask.destroy();
});
Expand Down