1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00
Commit graph

1455 commits

Author SHA1 Message Date
Calixte Denizet
3194f3de8b Keep the empty lines in the text fields
It fixes #18036.
2024-10-05 16:19:41 +02:00
Calixte Denizet
3103deaa44 Fix missing annotation parent in using the one from the Fields entry
Fixes #15096.
2024-10-04 20:00:19 +02:00
Calixte Denizet
c9050be863 [Editor] Add the possibility to save an updated stamp annotation (bug 1921291) 2024-10-02 11:45:16 +02:00
Calixte Denizet
2481a4bab9 Write the display flags in F entry when saving an annotation (issue 18072) 2024-10-01 17:26:39 +02:00
calixteman
c46ac3f73f
Merge pull request #18800 from calixteman/popup_deletion
[Editor] When deleting an annotation with popup, then delete the popup too
2024-09-26 18:04:24 +02:00
Calixte Denizet
0382dd0e25 [Editor] When deleting an annotation with popup, then delete the popup too 2024-09-26 17:52:25 +02:00
Jonas Jenwald
7db9941e0f Add basic support for non-embedded GillSansMT fonts (issue 18801)
Given the following excerpt from the [Wikipedia article](https://en.wikipedia.org/wiki/Gill_Sans), mapping this to Helvetica should hopefully be fine:

> It has been described as "the British Helvetica" because of its lasting popularity in British design.
2024-09-26 16:42:54 +02:00
Calixte Denizet
6d88f9f154 Fix the rendering of tiling pattern when the steps are lower than the tile dimensions (bug 1837738)
It fixes #16038.

The idea is to create a pattern having the steps for dimensions and then draw
the base tile and the different overlapping parts on it.
2024-09-26 14:20:48 +02:00
Jonas Jenwald
67af371e58 Ignore non-existing /Shading resources during parsing (issue 18765) 2024-09-19 21:55:02 +02:00
Calixte Denizet
78dd35483c Read a signed integer when using PUSHW in sanitizing a font (bug 1919513) 2024-09-18 22:09:17 +02:00
Calixte Denizet
ca95264e8b [JS] Correctly format floating numbers when they're close to an integer (bug 1918115) 2024-09-11 17:19:34 +02:00
Calixte Denizet
06f9d8002d Consider foo-\nBar as a compound word
Fixes #18693.
2024-09-11 15:01:54 +02:00
Calixte Denizet
518b776e43 Consume any pending path before drawing an annotation
Fixes #18058.
2024-09-10 16:44:30 +02:00
Calixte Denizet
68332ec236 Avoid to have a white line around the canvas
The canvas must have the same dims as the page in order to avoid to see the page
background.
2024-09-07 20:12:29 +02:00
Calixte Denizet
ddba096191 Make tagged images visible for screen readers (bug 1708040)
The idea is to insert a span in the text layer with an aria-role set to img
and use the bounding box provided by the attribute field in the tag dict in
order to have non-null dimensions for the image to make it "visible".
2024-09-05 17:59:42 +02:00
Calixte Denizet
a62ceedb69 [Editor] Make highlight annotations editable (bug 1883884)
The goal of this patch is to be able to edit existing highlight annotations.
2024-09-03 15:27:55 +02:00
Jonas Jenwald
8728f7f134 Support an odd number of digits in hexadecimal strings (issue 18645)
See https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G6.1840792
2024-08-23 16:31:43 +02:00
Jonas Jenwald
6dd31183be Use standard glyph mapping for non-embedded and non-composite Calibri fonts (issue 18208)
Given that we handle non-embedded Calibri fonts as "mapped to standard font", we really ought to be able to use the same glyph mapping as for an actual standard font.
Note that this actually improves consistency in the code, given how we already handle such fonts if they happen to be of the `CIDFontType2` type; see b47c7eca83/src/core/fonts.js (L1186-L1190)
2024-08-19 19:10:35 +02:00
Calixte Denizet
ad12f33999 Don't stop calculating field values when a Calculate callback throws
It fixes #18561.
2024-08-05 20:36:04 +02:00
Calixte Denizet
4b7f9a8d87 Empty fields are 0 when using AFSimple_Calculate
It fixes #18536 and #18532.
2024-08-02 21:51:27 +02:00
Jonas Jenwald
c4cd405a8f Ignore non-dictionary nodes when parsing StructTree data (issue 18503) 2024-07-28 12:08:44 +02:00
Calixte Denizet
482994cc04 Use a transparent color when setting fill/stroke colors in a pattern context but with no colorspace 2024-07-22 09:56:10 +02:00
Jonas Jenwald
d24a61c648 Allow /XYZ destinations without zoom parameter (issue 18408)
According to the PDF specification these destinations should have a zoom parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the zoom parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-18 13:29:32 +02:00
Calixte Denizet
37db3a7143 Remove active smask when restoring the initial canvas state
Fixes #18444.
2024-07-17 14:20:50 +02:00
Calixte Denizet
6dd75c0e62 [Editor] When in non-editing mode, add a new editor only once the editing mode has switched
Switching to an editing mode can be asynchronous (e.g. if an editable annotation exists on a
visible page), so we must add a new editor only when the page rendering is done.
2024-07-15 21:04:52 +02:00
Jonas Jenwald
50a5a15088 Create absolute filter-URLs when needed in DOMFilterFactory (issue 18406)
This functionality is purposely limited to development mode and GENERIC builds, since it's unnecessary in e.g. the *built-in* Firefox PDF Viewer, and will only be used when a `<base>`-element is actually present.

*Please note:* We also have tests in mozilla-central that will *indirectly* ensure that relative filter-URLs work as intended in the Firefox PDF Viewer, see https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/test/browser_pdfjs_filters.js

---

To test that the issue is fixed, the following code can be used:

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <base href=".">
  <title>base href (issue 18406)</title>
</head>
<body>

<ul>
  <li>Place this code in a file, named `base_href.html`, in the root of the PDF.js repository</li>
  <li>Run <pre>npx gulp dist-install</pre></li>
  <li>Run <pre>npx gulp server</pre></li>
  <li>Open <a href="http://localhost:8888/base_href.html">http://localhost:8888/base_href.html</a> in a browser</li>
  <li>Compare rendering with <a href="http://localhost:8888/web/viewer.html?file=/test/pdfs/issue16287.pdf">http://localhost:8888/web/viewer.html?file=/test/pdfs/issue16287.pdf</a></li>
</ul>

<canvas id="the-canvas" style="border: 1px solid black; direction: ltr;"></canvas>

<script src="/node_modules/pdfjs-dist/build/pdf.mjs" type="module"></script>

<script id="script" type="module">
  //
  // If absolute URL from the remote server is provided, configure the CORS
  // header on that server.
  //
  const url = '/test/pdfs/issue16287.pdf';

  //
  // The workerSrc property shall be specified.
  //
  pdfjsLib.GlobalWorkerOptions.workerSrc =
    '/node_modules/pdfjs-dist/build/pdf.worker.mjs';

  //
  // Asynchronous download PDF
  //
  const loadingTask = pdfjsLib.getDocument(url);
  const pdf = await loadingTask.promise;
  //
  // Fetch the first page
  //
  const page = await pdf.getPage(1);
  const scale = 1.5;
  const viewport = page.getViewport({ scale });
  // Support HiDPI-screens.
  const outputScale = window.devicePixelRatio || 1;

  //
  // Prepare canvas using PDF page dimensions
  //
  const canvas = document.getElementById("the-canvas");
  const context = canvas.getContext("2d");

  canvas.width = Math.floor(viewport.width * outputScale);
  canvas.height = Math.floor(viewport.height * outputScale);
  canvas.style.width = Math.floor(viewport.width) + "px";
  canvas.style.height = Math.floor(viewport.height) + "px";

  const transform = outputScale !== 1
    ? [outputScale, 0, 0, outputScale, 0, 0]
    : null;

  //
  // Render PDF page into canvas context
  //
  const renderContext = {
    canvasContext: context,
    transform,
    viewport,
  };
  page.render(renderContext);
</script>

</body>
</html>
```
2024-07-11 11:30:45 +02:00
Jonas Jenwald
e8d35c25ee
Merge pull request #18412 from Snuffleupagus/issue-18059
Also update the width/unicode data when replacing missing glyphs in non-embedded Type1 fonts (issue 18059)
2024-07-11 10:52:17 +02:00
Jonas Jenwald
403d023617 Allow e.g. /FitH destinations without additional parameter (bug 1907000)
According to the PDF specification these destinations should have a coordinate parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the coordinate parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-11 10:36:44 +02:00
Jonas Jenwald
56653e5770 Also update the width/unicode data when replacing missing glyphs in non-embedded Type1 fonts (issue 18059)
*Please note:* This causes a little bit of movement in the `issue2770` test-case, however this matches the rendering in both Adobe Reader and PDFium.
2024-07-09 09:41:01 +02:00
alexcat3
1c364422a6 Handle toUnicode cmaps that omit leading zeros in hex encoded UTF-16 (issue 18099)
Add unit test to check compatability with such cmaps

In the PDF in issue 18099. the toUnicode cmap had a line to map the glyph char codes from 00 to 7F to the corresponding code points. The syntax to map a range of char codes to a range of unicode code points is
<start_char_code> <end_char_code> <start_unicode_codepoint>
As the unicode code points are supposed to be given in UTF-16 BE, the PDF's line SHOULD have probably read
<00> <7F> <0000>
Instead it omitted two leading zeros from the UTF-16 like this
<00> <7F> <00>
This confused PDF.js into mapping these character codes to the UTF-16 characters with the corresponding HIGH bytes (01 became \u0100, 02 became \u0200, et cetera), which ended up turning latin text in the PDF into chinese when it was copied
I'm not sure if the PDF spec actually allows PDFs to do this, but since there's at least one PDF in the wild that does and other PDF readers read it correctly, PDF.js should probably support this
2024-07-06 11:29:21 -04:00
Calixte Denizet
832fc93aa4 Use vertical variant of a char when it's in a missing vertical font (bug 1905623) 2024-07-03 09:46:54 +02:00
Calixte Denizet
576aaf7cc1 [Editor] Take into account the page translation when computing the quadpoints when saving an highlight
It fixes #18360.
2024-07-02 10:12:26 +02:00
Calixte Denizet
dacf8bb0d1 Take into account PageOpen and PageClose actions which are present in some fields 2024-06-28 22:21:03 +02:00
Calixte Denizet
42bb2b0737 Fix the computation of unitsPerEm when the fontMatrix has some negative coefficients
It's a follow-up of #18253.
2024-06-24 16:40:07 +02:00
calixteman
a081dd25eb
Merge pull request #18306 from calixteman/bug1903731
Always use DW if it's a number for the font default width (bug 1903731)
2024-06-20 16:52:29 +02:00
Calixte Denizet
8c9a665728 Always use DW if it's a number for the font default width (bug 1903731) 2024-06-20 15:33:34 +02:00
Jonas Jenwald
3fae2d71f6 Don't throw if there's not enough data to get the header in FlateStream (issue 18298)
Following in the footsteps of PR 17340.
2024-06-20 13:03:17 +02:00
Calixte Denizet
d1452206d9 Compute correctly the unitsPerEm value from the fontMatrix when converting a font (bug 1539074) 2024-06-15 17:51:34 +02:00
Calixte Denizet
e3faa40f0f Don't display annotations with a PMD (barcode stuff) entry (bug 1899804)
There's no specification for that (even if it's possible to have an idea from
the xfa specs) so we just want to hide them in order to avoid to display something
wrong.
2024-06-10 21:01:37 +02:00
Calixte Denizet
61398066b9 Update our OpenJPEG decoder in order to fix a malloc failure due to big image (bug 1901253)
It has been fixed in:
5ef68089b5
2024-06-07 17:38:35 +02:00
Calixte Denizet
196affd8e0 Fix decoding of JPX images having an alpha channel
When an image has a non-zero SMaskInData it means that the image
has an alpha channel.
With JPX images, the colorspace isn't required (by spec) so when we
don't have it, the JPX decoder will handle the conversion in RGBA
format.
2024-06-03 20:08:11 +02:00
Jonas Jenwald
cfcb700ecc Prevent XRef errors from breaking font loading (bug 1898802)
Note that the referenced file is trivially corrupt, since it contains *two* PDF documents placed in the same file which doesn't make sense (and isn't how a PDF document should be updated).
However it's still a good idea to ensure that `loadFont` is able to handle errors when resolving References, since that allows us to invoke the existing fallback font handling.
2024-05-24 21:37:35 +02:00
Jonas Jenwald
3afa9bfc42 Improve /Page validation for linearized documents (issue 18138)
The referenced PDF document contains corrupt linearization-data, that doesn't point to the *first* page as intended.
2024-05-22 12:04:02 +02:00
Jonas Jenwald
2a52fda11b
Merge pull request #17770 from Aditi-1400/fix-issue-16843
Add language attribute to canvas
2024-05-21 21:35:43 +02:00
Aditi
9edca0a5ed Add lang attribute to canvas element
Fixes issue #16843.
In certain cases, the text layer was misaligned
due to a difference between the `lang` attribute
of the viewer and the canvas. This commit addresses
the problem by adding the `lang` attribute to the canvas.

The issue was caused because PDF.js uses serif/sans-serif
fonts to generate the text layer and relies on system fonts.
The difference in the `lang` attribute led to different fonts
being picked, causing the misalignment.
2024-05-21 19:41:24 +05:30
Jonas Jenwald
57014d0d13 Support corrupt PDF documents that contain "endsteam" commands (issue 18122)
This patch also re-factors the findStreamLength-helper to avoid even more code duplication.
2024-05-21 13:38:17 +02:00
Jonas Jenwald
440b4b6eeb Support charCodes larger than 32-bit in adjustMapping (issue 18117)
This also required changing the initial `charCodeToGlyphId`-data to an Object, which seems generally correct since it's consistent with existing code in the `src\core\{cff_font, type1_font}.js` files.
2024-05-20 12:13:55 +02:00
Jonas Jenwald
c5f92437f7 Avoid re-parsing global images that failed decoding (issue 18042, PR 17428 follow-up)
For images that failed to decode once we want to avoid a pointless round-trip to the main-thread, which could otherwise happen for globally cached images.
2024-05-14 13:58:36 +02:00
calixteman
33732ff2cb
Merge pull request #18035 from calixteman/rm_max_group_size
Remove the limit used to decided if a group canvas must be upscaled or not
2024-05-01 20:14:28 +02:00
Calixte Denizet
5c771628de Remove the limit used to decided if a group canvas must be upscaled or not
It fixes issues #14982 and #14724.
The main problem of upscaling a canvas is that it can induces some pixelation
(see issue #14724). So this patch is just removing the limit and as a side
effect it fixes issue #14982.
As far as I can tell, in looking different profiles (especially some memory profile)
in using the Firefox profiler, I don't see any noticeable difference in term of
memory use.
2024-05-01 18:01:54 +02:00