mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 09:08:07 +02:00
Move the EXIF-block replacement into JpegStream
(PR 19356 follow-up)
Currently we modify the EXIF-block in place, which may end up "breaking" the JPEG-data of the original PDF document since e.g. saving it from the viewer no longer contains the real EXIF-block. Hence the EXIF-block replacement is moved into the `JpegStream` class, such that we can copy the data before doing the replacement.
This commit is contained in:
parent
63b397f49d
commit
d5ce35f744
3 changed files with 54 additions and 12 deletions
|
@ -2235,6 +2235,29 @@ describe("api", function () {
|
|||
expect(data.length).toEqual(basicApiFileLength);
|
||||
});
|
||||
|
||||
it("gets data from PDF document with JPEG image containing EXIF-data (bug 1942064)", async function () {
|
||||
const typedArrayPdf = await DefaultFileReaderFactory.fetch({
|
||||
path: TEST_PDFS_PATH + "bug1942064.pdf",
|
||||
});
|
||||
|
||||
// Sanity check to make sure that we fetched the entire PDF file.
|
||||
expect(typedArrayPdf instanceof Uint8Array).toEqual(true);
|
||||
expect(typedArrayPdf.length).toEqual(10719);
|
||||
|
||||
const loadingTask = getDocument(typedArrayPdf.slice());
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const page = await pdfDoc.getPage(1);
|
||||
// Trigger parsing of the JPEG image.
|
||||
await page.getOperatorList();
|
||||
|
||||
const data = await pdfDoc.getData();
|
||||
expect(data instanceof Uint8Array).toEqual(true);
|
||||
// Ensure that the EXIF-block wasn't modified.
|
||||
expect(typedArrayPdf).toEqual(data);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("gets download info", async function () {
|
||||
const downloadInfo = await pdfDocument.getDownloadInfo();
|
||||
expect(downloadInfo).toEqual({ length: basicApiFileLength });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue