Commit Graph

5925 Commits

Author SHA1 Message Date
Calixte Denizet
1ab34d2ae4 [Editor] Don't add an editor for empty FreeText annotations 2023-06-15 18:33:03 +02:00
calixteman
5581e22cc7
Merge pull request #16535 from calixteman/restore_freetext
[Editor] Allow to edit FreeText annotations
2023-06-15 18:10:41 +02:00
calixteman
9f60686c59
Merge pull request #16554 from calixteman/issue16553
Add a container for Signature with their own canvas
2023-06-15 16:20:54 +02:00
Calixte Denizet
be25ee12bb Add a container for Signature with their own canvas 2023-06-15 16:11:52 +02:00
Calixte Denizet
0116a8f484 [Editor] Allow to edit FreeText annotations 2023-06-15 16:06:29 +02:00
Jonas Jenwald
a37f7d2477
Merge pull request #16543 from Snuffleupagus/limit-more-to-GENERIC
Limit more code to GENERIC builds
2023-06-15 13:58:52 +02:00
Jonas Jenwald
877884029d
Merge pull request #16551 from Snuffleupagus/page-destroyed-complete
Ensure that `cleanup` during rendering is actually ignored, to prevent a blank canvas
2023-06-15 12:26:57 +02:00
Jonas Jenwald
0650be4641
Merge pull request #16550 from Snuffleupagus/rm-RenderingCancelledException-type
[api-minor] Remove the `type` from `RenderingCancelledException` (PR 16226 follow-up)
2023-06-15 12:26:27 +02:00
Jonas Jenwald
a591c3de84 Ensure that cleanup during rendering is actually ignored, to prevent a blank canvas
The existing unit-test doesn't work as intended, since the page never actually renders. Note how `cleanup` is *not* allowed to run when parsing and/or rendering is ongoing, however an (old) incorrect condition could prevent rendering from ever starting.

This is very old code, which has been slightly re-factored a couple of times (many years ago), however this doesn't appear to affect e.g. the default viewer since the incorrect behaviour seem highly dependent on "unlucky" timing.
Note also how at the start of the `PDFPageProxy.prototype.render`-method we purposely cancel any pending `cleanup`-call, to prevent unnecessary re-parsing for multiple sequential `render`-calls.

Finally, avoid running `cleanup` when document/page destruction has already started since it's pointless in that case.
2023-06-15 11:39:26 +02:00
Jonas Jenwald
89f29192a5 Actually limit SVGGraphics to GENERIC builds (PR 16226 follow-up)
After PR 16226 the deprecated SVG back-end is now unused in development mode, with the exception of unit-tests, hence we can re-factor how it's exposed in the API to avoid including a useless webpack-closure in e.g. the *built-in* Firefox PDF Viewer.
2023-06-14 21:38:10 +02:00
Jonas Jenwald
a8d4aad8b9 Limit PDFPageProxy.getOperatorList to development mode and GENERIC builds
Given that this API method isn't used anywhere within the PDF.js library itself, except for the unit-tests, we can avoid including what's effectively dead code in e.g. the *built-in* Firefox PDF Viewer.
2023-06-14 21:33:22 +02:00
Jonas Jenwald
225734dd00 [api-minor] Remove the type from RenderingCancelledException (PR 16226 follow-up)
After PR 16226 we're only using `RenderingCancelledException` together with canvas-rendering, hence the `type`-property is no longer necessary.
2023-06-14 15:40:25 +02:00
Jonas Jenwald
fee850737b Enable the unicorn/prefer-optional-catch-binding ESLint plugin rule
According to MDN this format is available in all browsers/environments that we currently support, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#browser_compatibility

Please also see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
2023-06-12 11:46:11 +02:00
Tim van der Meij
9af50dc358
Merge pull request #16541 from Snuffleupagus/inline-image-mask-checks
Improve SMask/Mask lookup when parsing inline images
2023-06-11 13:01:45 +02:00
Jonas Jenwald
1f42aaf21b Improve SMask/Mask lookup when parsing inline images
- Don't attempt to lookup an "SM" entry, since we're only using "SMask" in the `PDFImage` code and I also cannot find any mention in the PDF specification about that being a valid abbreviation for a Soft Mask entry. (There's only a `SM = Smoothness Tolerance` Graphics State parameter, which is obviously something completely different.)

 - Don't lookup the /SMask and /Mask entries unless it's actually an inline image, since it's pointless otherwise.

 - Last, but most importantly, only check for the *existence* of /SMask and /Mask entries but don't actually fetch the data. Note that if either one exists it'll contain a Stream, and those cannot be cached on the `XRef`-instance, which leads to unnecessary parsing/allocations and in this case we're not using the actual data for anything.
2023-06-10 13:19:43 +02:00
Calixte Denizet
1a047f843c [Editor] Add the possibility to update an existing annotation with some new properties when saving or printing 2023-06-09 17:14:53 +02:00
Calixte Denizet
3d0ce1cff2 Concat data when push fails in the CFF compiler 2023-06-09 15:48:01 +02:00
Calixte Denizet
baebf7b26d [Editor] Fix test failures in m-c because of the new FreeText undo/redo stuff 2023-06-08 13:38:52 +02:00
calixteman
22d350cae6
Merge pull request #16528 from calixteman/bug1831574
[Editor] Commit the text when the user hits ctrl+s (bug 1831574)
2023-06-06 12:13:14 +02:00
Calixte Denizet
3d98fb3c0b [Editor] Commit the text when the user hits ctrl+s (bug 1831574) 2023-06-06 11:40:54 +02:00
Calixte Denizet
2f0bb9dc2f [Editor] Allow to undo/redo committed text modifications for FreeText 2023-06-05 21:31:19 +02:00
Calixte Denizet
ba8c996623 [Editor] Guess font size and color from the AS of FreeText annotations 2023-06-05 17:15:17 +02:00
Calixte Denizet
9f861c39f4 [Editor] Connect then annotation layer and the editor one 2023-06-05 14:05:52 +02:00
Jonas Jenwald
046b9050dd Remove unused variables in InkAnnotation.createNewAppearanceStream (issue 16518, PR 16494 follow-up) 2023-06-04 13:51:24 +02:00
Jonas Jenwald
cf3a35e9da Enable the import/no-cycle ESLint plugin rule
Having cyclical imports is obviously not a good idea, and this ESLint plugin rule can help detect those; please see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
2023-06-04 13:44:15 +02:00
Jonas Jenwald
5fad931a3f Enable more import ESLint plugin rules
This patch enables more `import` rules to help prevent bugs/inconsistencies, and most of these rules didn't require code changes; please find additional details here:
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/export.md
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/exports-last.md
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-empty-named-blocks.md
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
 - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
2023-06-04 09:58:25 +02:00
calixteman
63b61ca082
Merge pull request #16508 from calixteman/restore_mk_annotation_layer_an_object
[api-minor] Make the AnnotationLayer an object in order to use it in the AnnotationEditorLayer
2023-06-02 23:12:50 +02:00
Calixte Denizet
4351708ae6 [api-minor] Make the AnnotationLayer an object in order to use it in the AnnotationEditorLayer
It'll be useful to make the Freetext and Ink annotations editable.
2023-06-02 22:44:14 +02:00
Jonas Jenwald
cccdc8dba4
Merge pull request #16513 from Snuffleupagus/issue-7454
Improve handling of mismatching /BaseFont and /FontName entries for non-embedded fonts (issue 7454)
2023-06-02 18:11:05 +02:00
Jonas Jenwald
666e35301b
Merge pull request #16499 from Snuffleupagus/Chrome-92
[api-minor] Update the minimum supported Google Chrome version to 92
2023-06-02 17:16:22 +02:00
Jonas Jenwald
459d26edec Improve handling of mismatching /BaseFont and /FontName entries for non-embedded fonts (issue 7454)
This patch is the result of me going through some old issues regarding non-embedded Wingdings support.

There's a few different things wrong in the referenced PDF document:
 - The /BaseFont and /FontName entries don't agree on the name of the fonts, with one font using `/BaseFont /Wingdings-Regular` and `/FontName /wg09np` which obviously makes no sense.
   To address this we'll compare the font-names against our lists of known ones and ignore /FontName entries that don't make sense iff the /BaseFont entry is a known font-name.
 - The non-embedded Wingdings font also set an incorrect /Encoding, in this case /MacRomanEncoding, which should have been fixed by PR 16465. However this doesn't work since the font has *bogus* font-flags, that fail to categorize the font as Symbolic.
   To address this we'll also compare the font-name against the list of known symbol fonts.
2023-06-02 17:10:25 +02:00
Jonas Jenwald
ea93c507f5 [editor] Initialize KeyboardManager-instances lazily
As far as I can tell there's no particular reason for initializing `KeyboardManager`-instances eagerly, since the user may never use editing, and we can easily do this lazily instead by utilizing shadowed getters.
2023-06-02 16:03:22 +02:00
Jonas Jenwald
9fe0423a4c
Merge pull request #16497 from Snuffleupagus/more-Util-getAxialAlignedBoundingBox
Use the `Util.getAxialAlignedBoundingBox` helper function more
2023-06-02 13:34:10 +02:00
Jonas Jenwald
2db0eff70f Fix incorrect USERACTIVATION_CALLBACKID import (15618 follow-up)
This constant is currently imported from the wrong file, where it doesn't exist; see PR 15618.
2023-06-02 10:02:23 +02:00
Maxence Dalmais
e4ecf59727 export ImageKind type externally 2023-06-02 08:51:18 +02:00
Wojciech Maj
1add9bc131
Fix canvasMaxAreaInBytes type
Fixes #16503
2023-06-01 15:41:43 +02:00
Calixte Denizet
0e610cab04 Try to not omit some values when printing a choice list with several selected items 2023-05-31 21:17:22 +02:00
Calixte Denizet
133d103186 [Editor] Add few more info when saving ink data (thickness, opacity, ...)
Fix the InkList entry: the coordinates were relative to the page and not
to the bounding box of the annotation.
2023-05-31 15:43:07 +02:00
Jonas Jenwald
c60a3ce96a [api-minor] Update the minimum supported Google Chrome version to 92
This patch updates the minimum supported browsers as follows:
 - Google Chrome 92, which was released on 2021-07-20; see https://support.google.com/chrome/a/answer/10314655

Note that nowadays we usually try, where feasible and possible, to support browsers that are about two years old. By limiting support to only "recent" browsers we reduce the risk of holding back improvements of the *built-in* Firefox PDF Viewer, and also (significantly) reduce the maintenance/support burden for the PDF.js contributors.

*Please note:* As always, the minimum supported browser version assumes that a `legacy`-build of the PDF.js library is being used; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2023-05-31 11:03:39 +02:00
Jonas Jenwald
d3c0928121 Use the Util.getAxialAlignedBoundingBox helper function more
There's a couple of spots in the code-base that effectively re-implement this helper function, which seems like unnecessary repetition.
2023-05-31 09:32:19 +02:00
Calixte Denizet
78e6020a6e [OTS] Remove cntrmask instruction with no stem in charstring (bug 1529502) 2023-05-28 19:03:37 +02:00
Calixte Denizet
be5db13005 Reset the formatted value when after a text field has been modified 2023-05-26 10:17:14 +02:00
Calixte Denizet
35a58ed987 Extract all the text of text annotations 2023-05-25 23:11:42 +02:00
calixteman
8d5da54cd5
Merge pull request #16467 from calixteman/non_null_ultimate
Avoid to have a null fallback if none has been provided
2023-05-24 17:00:14 +02:00
Jonas Jenwald
5a7beb9f30 Attempt to improve non-embedded Wingdings font support (bug 1652224)
Now that font-substitution has been implemented, we should be able to do much a better job at supporting non-embedded Wingdings fonts.
Given that this is a Windows-specific font, see https://en.wikipedia.org/wiki/Wingdings, this is however not guaranteed to work (well) on other platforms.
2023-05-24 14:59:13 +02:00
Calixte Denizet
7dce0a27f6 Avoid to have a null fallback if none has been provided 2023-05-24 14:44:36 +02:00
Jonas Jenwald
aeed6f2b67 Ignore named encoding for non-embedded symbol fonts (issue 16464)
The affected font is non-embedded ZapfDingbats, however the PDF document for some inexplicable reason specifies the encoding as "WinAnsiEncoding" (which is obviously wrong).
To work-around this bug in the PDF generator, we'll simply ignore any explicitly specified named encoding for non-embedded symbol fonts.
2023-05-24 10:48:47 +02:00
Jonas Jenwald
a6f9505a39
Merge pull request #16461 from Snuffleupagus/issue-16454
Improve "EI" detection in inline images (PR 12028 follow-up, issue 16454)
2023-05-23 22:23:22 +02:00
calixteman
1886012874
Merge pull request #16462 from calixteman/last_elem_TJ
Take into account the final space if any in the TJ command
2023-05-23 21:26:58 +02:00
Calixte Denizet
d2b4ed3cea [Editor] Improve curve smoothing for Ink tool (bug 1789443)
- Remove the dependency on fit-curve;
- Improve the way to draw the current line in using a Path2D and
  in clearing only the last part of the curve instead of clearing
  all the canvas;
- Smooth the curve when drawing to avoid to have some changes after
  the drawing ends;
- Make the smoothing a bit less agressive.
2023-05-23 17:15:21 +02:00