Julian Smith [Thu, 2 Nov 2023 15:56:37 +0000 (15:56 +0000)]
scripts/wrap/__main__.py: use pipcl.py's support for python build flags.
This fixes finding of python-config on some macos systems.
This commit is a subset of master commit
da3c74cd0d3 "scripts/wrap/: fixed
pyodide builds and simplified windows python search.". We haven't cherry-picked
the whole commit because this would require other Pyodide-related changes that
are not suitable for 1.23.x.
Robin Watts [Wed, 18 Oct 2023 00:23:26 +0000 (17:23 -0700)]
PyMuPDF issue 2608: CMAP mrange with surrogate chars.
The file given in the bug contains a CMAP with a bfrange entry:
<63> <73> <
D835DF08>
i.e. a range where the code 'base' is given as a surrogate pair.
We parse this, and because the base definition is longer than
the single 16 bit value, we break the range down into a series
of single char ranges.
We add these single char ranges (using pdf_map_one_to_many)
incrementing the last value in the range by 1 each time.
Unfortunately, pdf_map_one_to_many spots the surrogates, and
rewrites the data it is passed. And the data is then reused
for the next call into pdf_map_one_to_many.
The fix, implemented here, is to make pdf_map_one_to_many take
a local copy of the values before it modifies them.
This solves the problem.
Julian Smith [Thu, 12 Oct 2023 18:13:09 +0000 (19:13 +0100)]
scripts/pipcl.py: various improvements.
Cope if Windows python executable path contains spaces.
Use global log level.
Instead of passing `verbose` args between fns, we now have a global
`g_verbose` and fns log0(), log1(), log2(). log1() only outputs if
g_verbose >= 1 etc.
Command-line `--verbose` increments `g_verbose`.
PIPCL_VERBOSE sets initial verbose leve.
Fix for wheel creation and multi-line license text.
Allow fn_sdist to specify a different name of file within the sdist.
Fix finding python-config on macos python-3.12 builds.
Reorder things so when we select the last matching candidate, it is the
best match.
Julian Smith [Fri, 6 Oct 2023 13:19:25 +0000 (14:19 +0100)]
scripts/: minor changes.
scripts/jlib.py:build(): show change to command.
scripts/wrap/cpp.py: reinit_singlethreaded(): disable diagnostic as it isn't
necessary.
scripts/wrap/__main__.py: use make -j by default. We now default to `make -j N`
where `N` is the number of cpus, from Python's multiprocessing.cpu_count().
Julian Smith [Sat, 23 Sep 2023 09:15:17 +0000 (10:15 +0100)]
Fixes for Python wheel creation with new pipcl.py.
pyproject.toml:
Added setuptools, required by updated pipcl.py.
setup.py:
Update to match new pipcl.py and fix version number to pass pipcl's
improved checking with pep-440.
scripts/pipcl.py:
Fix handling of multiline license text.
Julian Smith [Thu, 21 Sep 2023 20:56:47 +0000 (21:56 +0100)]
scripts/pipcl.py: updated to latest version in PyMuPDF.
We need the latest pipcl.PythonFlags() to allow builds on macos with basic
python installation.
Julian Smith [Tue, 5 Sep 2023 07:42:52 +0000 (08:42 +0100)]
scripts/: New/improved C++ wrappers, misc other improvements to wrappers.
Rewrote unsafe fz_search_page2() custom method:
Our custom wrapper for fz_search_page() was unsafe because it was treating
`int *hit_mark` as a single int out-param, when in fact it will write to an
array of `max` ints.
New wrapper returns a std::vector of a new struct fz_search_page2_hit
containing quad and mark members, so can be wrapped easily by SWIG.
Tested by --test-python.
Added custom wrapper fz_highlight_selection2().
New custom wrapper returns std::vector<fz_quad> so works with SWIG. In
--test-cpp, added a test of the new wrapper and enabled use of asserts.
Fix Win32 debug builds:
Exclude locking assert/debug fns from SWIG, as they aren't available in
release builds (and are not useful to SWIG-generated bindings anyway).
Also add fz_lock_debug_lock() and fz_lock_debug_unlock() to windows.dev if
we are doing a debug build, to avoid link errors.
Minor changes:
scripts/wrap/swig.py: ignore any error from informational call of `which`.
scripts/wrap/cpp.py: Improve diagnostic if clang not found.
scripts/wrap/__main__.py: allow --test-csharp-gui to work for any current
directory.
scripts/jlib.py: build(): added asserts to track down occasional errors.
Fixed `scripts/mupdfwrap.py --venv` on openbsd.
scripts/wrap/swig.py: Improved a C# diagnostic.
scripts/wrap/cpp.py: add debug diagnostics to Director `use_virtual_*()`
methods.
scripts/wdev.py: allow override of VS year etc using environment variables.
scripts/wrap/cpp.py: possible fix for reported clang problem. Looks like
clang can use a different placeholder name for anonymous structs.
Moved C++ code for --test-cpp into a separate file,
scripts/mupdfwrap_test.cpp.
Tor Andersson [Thu, 19 Oct 2023 16:07:26 +0000 (18:07 +0200)]
Use CropBox as origin for fitz space in PDF documents.
This means the default fitz space coordinates for the default page bounding box
for all document types will have their origin at the top left.
Tor Andersson [Thu, 28 Sep 2023 14:47:23 +0000 (16:47 +0200)]
Change default to use CropBox rather than MediaBox.
Sebastian Rasmussen [Thu, 5 Oct 2023 04:06:53 +0000 (06:06 +0200)]
Bug 707083: Remember to retain colorspaces when filtering in-line images.
Sebastian Rasmussen [Wed, 4 Oct 2023 00:50:30 +0000 (02:50 +0200)]
Bug 707074: Detect cycles in structure trees.
Without this detection this code could end up executing forever in case
structure elements were broken and referenced each other in a loop.
Also do away with the O(N^2) search and do an O(N) search at
the expense of deeper recursion and larger stack frames.
Sebastian Rasmussen [Thu, 28 Sep 2023 13:44:45 +0000 (15:44 +0200)]
jni: Add API to check if annotation has a Rect property or not.
Tor Andersson [Thu, 14 Sep 2023 14:29:00 +0000 (16:29 +0200)]
Add fixed padding to Ink annotations.
Avoid unselectable bboxes when the stroke is a tiny dot.
Sebastian Rasmussen [Mon, 11 Sep 2023 22:51:33 +0000 (00:51 +0200)]
Bump version for patch release 1.23.4.
Sebastian Rasmussen [Wed, 6 Sep 2023 21:23:31 +0000 (23:23 +0200)]
jni/android: Avoid manipulating device object during a raised exception.
Sebastian Rasmussen [Tue, 5 Sep 2023 11:51:19 +0000 (13:51 +0200)]
Bump version for patch release 1.23.3.
Sebastian Rasmussen [Mon, 4 Sep 2023 00:06:24 +0000 (02:06 +0200)]
Bug 706863: Trigger repair if trailer info and xref length are not the same.
The file from this bug has a trailer entry /Size 232, indicating
that objects are numbered 0..231, while the xref starts with
xref\n0 233, indicating that objects are numbered 0..232. The
offset in xref entry for object 231 does point to a viable PDF
object, but the offset in xref entry for object 232 points to the
offset of the xref table itself, i.e. the last object cannot be
parsed successfully!
The pdfref17 states that the /Size value is 1 greater than the
highest object number used in the file and that any object in a
cross-reference section whose number is greate that this value is
ignored and considered missing.
Previously MuPDF kept /Size in the trailer unchanged, indicating
objects 0..231, but sized the in-memory xref to be able to
contain objects 0..232. Loading and viewing the document works
fine since PDF object 232 0 R is not actually referenced
anywhere.
When saving objects 0..231 were written to the output file
successfully, but once object 232 was being loaded into memory
this failed, causing the entire save operation to fail.
After this commit, by validating the xref size a repair is
triggered, causing both the xref and the trailer /Size key to be
ignored in preference to scanning the file for objects and
rebuilding both the xref table and the trailer.
Robin Watts [Thu, 31 Aug 2023 17:47:51 +0000 (18:47 +0100)]
Bump version for patch release 1.23.2.
Julian Smith [Thu, 31 Aug 2023 14:54:39 +0000 (15:54 +0100)]
scripts/wrap/: added support for building with tesseract.
We build base C library with tesseract if build directory contains
`-tesseract-`.
Robin Watts [Thu, 31 Aug 2023 12:11:53 +0000 (13:11 +0100)]
VS: Add DebugPythonTesseract and ReleasePythonTesseract configs
For building pymupdf with tesseract support on windows.
Tor Andersson [Wed, 30 Aug 2023 12:27:47 +0000 (14:27 +0200)]
Bump version for patch release 1.23.1.
Julian Smith [Tue, 29 Aug 2023 22:41:54 +0000 (00:41 +0200)]
Add missing leptonica file causing link error in python bindings.
Sebastian Rasmussen [Wed, 23 Aug 2023 11:29:34 +0000 (13:29 +0200)]
Bug 707022: Revert "Draw ink annotations with butt line caps like Acrobat."
That commit corrected ink annotation appearances to confirm to the
rendering done by older versions of Acrobat Reader.
Newer and current versions of Acrobat Reader renders ink annotation
strokes not using butt line caps, but round line caps.
Sebastian Rasmussen [Wed, 16 Aug 2023 22:38:05 +0000 (00:38 +0200)]
Bug 706864: Cache non-decrypted encryption dict/ID after repair.
When opening a document a non-decrypted encryption dict/ID are read, then
the rest of the document. If a repair is triggered it used to throw away
all cached objects to avoid caching non-decrypted strings/streams.
This is the correct decision of all objects except the encryption dict/ID.
If at a later point the PDF document is saved with encryption kept then
all objects will be saved using the encryption key from the non-decrypted
encryption dictionary/ID determined when opening the document, but when
saving the encryption dictionary itself it will not get any special
treatment, thus its owner/user password strings are decrypted. This
decrypted encryption dict and ID are then saved to the output file.
This means that the owner/user password strings no longer correspond
to the ones in the original document. So when mupdf-gl tries to reopen
the output file it will ask for a password, but the original owner/user
password's will not work.
This is fixed by caching the encryption dictionary and ID in non-decrypted
form after repairing the document and clearing out all the non-decrypted
objects. Doing that leaves the objects in memory until it is time to save
the document, causing the encryption dictionary to be saved in non-decrypted
form, which means that the owner/user password strings are left unchanged,
and thus mupdf-gl will accept the original owner/user passwords when reopening
the file.
For the file in this particular bug the owner password is unknown while the
user password is the default password (i.e. the empty string).
Sebastian Rasmussen [Thu, 24 Aug 2023 16:46:41 +0000 (18:46 +0200)]
End implicit operation also for Popups, Links and Signatures and check boxes.
Previously the implicit operation for these types of annotations were
not ended, which left a stray implicit operation which would never be
ended.
The same issue was present in the code called when toggling checkbox widgets.
Later on if an application such as AppKit, called pdf_undoredo_state(),
it would throw an exception because an operation is ongoing.
Tor Andersson [Tue, 22 Aug 2023 13:53:32 +0000 (15:53 +0200)]
Fix FZ_VERBOSE_EXCEPTIONS.
Tweak macros to avoid trailing commas if "format" argument is last.
Fix crash when formatting "rethrow" message in fz_rethrow_if.
Tor Andersson [Mon, 21 Aug 2023 10:20:18 +0000 (12:20 +0200)]
Ensure variable is initialized.
Set annot to null. If pdf_create_annot_raw fails, we still want to be able to
safely free it.
Sebastian Rasmussen [Thu, 17 Aug 2023 19:29:36 +0000 (21:29 +0200)]
gl: Avoid double drop of outline/doc when reloading documents.
If a document was encrypted with the default password, and the user
saved the document with new encryption/password, the saving of the new
file would work fine, but once the file was being reloaded the outline
was dropped an a new password was requested. Once the password was
entered the file was reloaded again, causing the same outline to be
dropped a second time. This commit avoids this by setting the outline
pointer to NULL when the outline is dropped.
Robin Watts [Wed, 16 Aug 2023 11:34:24 +0000 (12:34 +0100)]
Handle exceptions while ensuring incremental/local objects.
Sebastian Rasmussen [Tue, 15 Aug 2023 15:27:22 +0000 (17:27 +0200)]
java: Make sure to include inner classes in jar-file.
Thanks to Thomas Hirsch for pointing this out.
Sebastian Rasmussen [Mon, 14 Aug 2023 12:44:30 +0000 (14:44 +0200)]
Use the correct file drop callback even upon exception.
Sebastian Rasmussen [Mon, 14 Aug 2023 12:36:03 +0000 (14:36 +0200)]
Handle memory allocation error in pkcs7 code.
Sebastian Rasmussen [Sun, 6 Aug 2023 22:28:53 +0000 (00:28 +0200)]
Avoid printing useless, possibly invalid bitmap signature.
Fixes oss-fuzz issue 61237
Sebastian Rasmussen [Sun, 13 Aug 2023 12:35:22 +0000 (14:35 +0200)]
Bug 707021: DefaultColorSpaces constructor is not static.
Sebastian Rasmussen [Fri, 11 Aug 2023 01:48:34 +0000 (03:48 +0200)]
Add forgotten exception rethrow.
Sebastian Rasmussen [Thu, 10 Aug 2023 23:19:38 +0000 (01:19 +0200)]
Do not use freed pdf_sanitize stack entry after freeing it.
Robin Watts [Mon, 14 Aug 2023 11:05:27 +0000 (12:05 +0100)]
Fix problem with ImageProb2.pdf and ImageProb2y.pdf.
insert_weight must not be called with the source location being
out of range.
This fixes oss-fuzz issues 60349, 61290 and 61502.
Robin Watts [Mon, 14 Aug 2023 11:03:36 +0000 (12:03 +0100)]
Revert the reversion of the fix for Bug 706764
Bug 706764: OSS-Fuzz 59600: Fix scaled pixmap weight generation.
This reverts commit
9a35f1652ed34ea6aaa7daef36de219b1ed8a3ce.
The next commit will address the issue with ImageProb2.pdf and
ImageProb2y.pdf. Kept separate for clarity.
Julian Smith [Thu, 10 Aug 2023 21:08:37 +0000 (22:08 +0100)]
Makerules scripts/wrap/__main__.py: fix cross-building to arm64 on MacOS.
Makerules:
On MacOS when building for arm64, we need to set HAVE_LIBCRYPTO to
no, otherwise we try to link arm64 with x86 libcrypto when building
mutool etc.
scripts/wrap/__main__.py:
On MacOS we need to include $ARCHFLAGS in our c++ command.
Sebastian Rasmussen [Fri, 4 Aug 2023 12:55:30 +0000 (14:55 +0200)]
Revert "Bug 706764: OSS-Fuzz 59600: Fix scaled pixmap weight generation."
This reverts commit
8ad9e2393c695e8d8b850a2b735b4a6d02e05a26.
The bugfix introduced a crash in ImageProb2.pdf and ImageProb2y.pdf
in the cluster. Misbehaving on a real file is worse than misbehaving
on a fuzzed file, so for the time being we back this one out until
we have a proper fix that doesn't cause issues for normal files.
Tor Andersson [Fri, 4 Aug 2023 12:55:43 +0000 (14:55 +0200)]
mupdf-gl: Fix '-r' resolution option.
It went "missing" when the -Y UI scale option was added.
Tor Andersson [Mon, 31 Jul 2023 12:38:24 +0000 (14:38 +0200)]
Update CHANGES.
Jamie Lemon [Mon, 31 Jul 2023 15:07:59 +0000 (16:07 +0100)]
Documentation: Latest WASM fixes reflected.
Sebastian Rasmussen [Tue, 1 Aug 2023 12:57:50 +0000 (14:57 +0200)]
Fix compilation warning about different return types.
Tor Andersson [Fri, 28 Jul 2023 15:04:26 +0000 (17:04 +0200)]
java: Add support for explicit MediaBox/CropBox/ArtBox in Page.
Tor Andersson [Wed, 26 Jul 2023 12:05:40 +0000 (14:05 +0200)]
mutool: Separate resolveLink and resolveLinkDestination.
Tor Andersson [Tue, 25 Jul 2023 15:31:06 +0000 (17:31 +0200)]
wasm: Outline iterator.
Julian Smith [Thu, 27 Jul 2023 15:53:16 +0000 (16:53 +0100)]
scripts/jlib.py: system(): avoid encoding exceptions on Windows.
If writing command output to a stream such as sys.stdout, and this
stream has a non-utf8 encoding such as cp1252 on Windows, we could get
encoding errors because some utf-8 characters cannot be represented in
cp1252.
So instead of system() using its `encoding` arg (default 'utf8') as the
encoding for all outputs, for outputs that have a `.write()` method we
assume there is an `.encoding` value, and use that. Other outputs such
as plain callables, use the `encoding` arg.
So we now create zero or more incremental decoders, setting up each one
with the `errors` arg so that it will not raise.
Julian Smith [Thu, 27 Jul 2023 21:25:36 +0000 (22:25 +0100)]
scripts/wrap/state.py: fix --test-cpp with debug Windows builds.
When compiling the test code, need to set extra flags to match DLLs,
e.g. `/MDd` activates debug versions of things like std::string, which
have a different size.
Julian Smith [Sun, 23 Jul 2023 21:09:37 +0000 (22:09 +0100)]
scripts/wrap/__main__.py: fix windows x32 builds and improve --test-cpp.
Workaround a problem where `pip install libclang` seems to fail to
install in a new 64-bit venv if we are in a 32-bit venv inside 64-bit
venv created by pip itself.
--test-cppnow now also checks mupdf::fz_lookup_metadata2().
Julian Smith [Thu, 27 Jul 2023 15:50:52 +0000 (16:50 +0100)]
scripts/wrap/state.py: allow `-d build/shared-debug` to work on Windows.
We automatically append current cpu and python version if not specified,
e.g. to get `build/shared-debug-x64-py3.11`.
Tor Andersson [Tue, 25 Jul 2023 10:21:40 +0000 (12:21 +0200)]
Support -b ArtBox argument to mutool convert.
Tor Andersson [Wed, 26 Jul 2023 12:04:49 +0000 (14:04 +0200)]
pdf: Initialize chapter field of fz_location when resolving links.
Sebastian Rasmussen [Wed, 26 Jul 2023 00:13:43 +0000 (02:13 +0200)]
Bug 706942: Handle indirect PDF null objects.
Sebastian Rasmussen [Sun, 23 Jul 2023 22:21:17 +0000 (00:21 +0200)]
Check remaining data size before parsing bmp array header.
This fixes oss-fuzz 59390.
Sebastian Rasmussen [Sun, 23 Jul 2023 21:45:57 +0000 (23:45 +0200)]
Fix image leak in PSD parser.
This fixes oss-fuzz 59841.
Sebastian Rasmussen [Tue, 18 Jul 2023 09:57:32 +0000 (11:57 +0200)]
Support use of legacy annotation dash pattern.
Julian Smith [Wed, 19 Jul 2023 19:51:53 +0000 (20:51 +0100)]
platform/win32/mupdfcpp.vcxproj: fixed Windows debug builds of C++ bindings.
The debug .dll and .lib files previously omitted MuPDF global data.
Julian Smith [Wed, 19 Jul 2023 17:32:51 +0000 (18:32 +0100)]
docs/src/language-bindings.rst: improve and simplify build instructions.
It looks like pypi.org's swig can generate C# bindings and works
on OpenBSD, so no need for --swig-windows-auto or other special
instructions to use system package manager's swig.
`-b m` is now skipped on Windows (rather than giving an error) so we can
use same command as on Unix when building C++ bindings.
Added examples of setting LD_LIBRARY_PATH or PATH etc when using
bindings.
Clarify that C# on MacOS is not yet supported.
Fix bad highlighting in Windows shell example.
Julian Smith [Wed, 19 Jul 2023 17:29:42 +0000 (18:29 +0100)]
setup.py scripts/wrap/: Simplified builds by always using pip's swig.
It seems that we can now always use pypi.org's swig.
scripts/wrap/swig.py:
Assume swig is available, even on windows. We now document that
builds should be in a venv in which swig has been installed, so
there's no need to recommend --swig-windows-auto.
scripts/wrap/__main__.py:
Improve diagnostic if we don't know where mono is.
Create default mupdf::FzDocument in --test-cpp.
Avoid confusing behaviour if `--venv` is not first arg. We now show
an error message if `--venv` is not first arg - it effectively
discards any prior args.
setup.py:
Don't use --swig-windows-auto - we now always require swig in venv.
Robin Watts [Wed, 19 Jul 2023 11:37:11 +0000 (12:37 +0100)]
Bug 706854: Avoid calling fz_advance_glyph for out of range gid.
We use gid == -1 to signify no glyph (for records where we have
multiple unicodes to a single glyph). Avoid calling fz_advance_glyph
in this case.
Robin Watts [Tue, 18 Jul 2023 15:28:04 +0000 (16:28 +0100)]
Bug 706760: Fix the sanitize filter's handling of '0 w'.
We were setting the default values of the sanitize filters
'pending' and 'sent' graphics states incorrectly, meaning that
'0 w' would never be sent through unless we previously set
w to something non-zero.
Robin Watts [Tue, 18 Jul 2023 13:56:33 +0000 (14:56 +0100)]
Bug 706756: Avoid image filter compression bombs.
The PDF spec allows us to specify a JPEG stream as the source
for a content stream. Effectively this can be a compression
bomb (not least because a JPEG continues to output 'empty'
data to the size that it is specified to be, even if the
underlying data runs out).
So, here, where we open streams for lexing, we refuse to open
streams with compression schemes that can only be images
(JPG, JPX, Fax).
Julian Smith [Wed, 19 Jul 2023 10:11:33 +0000 (11:11 +0100)]
scripts/wrap/cpp.py: fixed clang parse on MacOS.
Clang cannot find <string> on MacOS so we create a fake std:string
similar to our fake std::vector<>.
Julian Smith [Tue, 18 Jul 2023 20:31:53 +0000 (21:31 +0100)]
scripts/wrap/__main__.py: Improved -b's -j option.
`-b -j 0 ...` will use `-j N` where N is multiprocessing.cpu_count().
Julian Smith [Tue, 18 Jul 2023 17:29:40 +0000 (18:29 +0100)]
scripts/wrap/cpp.py: fixed bug in generation and parse of extra.h.
We were not writing to extra.h until after parsing it, so first run on a
clean tree would not include the extra fns.
Julian Smith [Thu, 13 Jul 2023 22:04:39 +0000 (23:04 +0100)]
docs/src/language-bindings.rst: improved build instructions.
We now have different sections for building the C++, Python and C#
bindings, and within these group by different OS where they differ.
Added more details about building the C++ bindings.
Small improvement to file tree description.
Included info about extra fns.
Julian Smith [Wed, 12 Jul 2023 10:18:35 +0000 (11:18 +0100)]
scripts/wrap/ platform/win32/: improve how we add custom functions/methods to language bindings.
Instead of adding specific C++, Python or C# functions when creating
language bindings, we add extra functions to the MuPDF C API before
we parse it with clang. This ensures that we automatically generate
low-level, class-aware and class-member versions of these new functions.
The new functions are written in C++. Where it is useful they return
std::string or std::vector so as to give a good interface in the C++,
Python and C# language bindings.
We exclude the new functions from windows_mupdf.def and instead directly
tag them with `FZ_FUNCTION`. (We would otherwise have to add C++ mangled
names to windows_mupdf.def.)
scripts/wrap/classes.py: removed some custom functions that are
superceded by the new system.
scripts/wrap/__main__.py: ignore `-b m` on Windows instead of error so
that we can use the same command to build the C++ bindings on Windows
and Unix.
platform/win32/mupdfcpp.vcxproj*: added new extra.cpp source file.
scripts/mupdfwrap_test.cs: new, C# test code that was previously
embedded as a string in scritps/wrap/__main__.py.
Fixed some wrapper code to use rename.*() fns rather than hard-coding
names of wrapper fns/methods.
Robin Watts [Mon, 17 Jul 2023 18:39:11 +0000 (19:39 +0100)]
Bug 706825: Fix rasterizer to cope with legal empty bboxes.
We define any bbox that has x1 <= x0 or y1 <= y0 to be empty.
The rasterizer was getting confused by cases where y1 < y0.
So, 'sanitize' the bbox at any appropriate point.
Also simplify the bbox calculations in a couple of places in
the draw device.
Robin Watts [Tue, 18 Jul 2023 10:30:51 +0000 (11:30 +0100)]
Bug 706822: Followup. Clip lines in other edgebuffer case.
Thanks to Sebastian for pointing out that the same problem can
occur in the 'any part of a pixel' rendering too.
Robin Watts [Mon, 17 Jul 2023 17:22:14 +0000 (18:22 +0100)]
Bug 706822: Clip stupidly sized lines before inserting to edgebuffer.
Converting a float to a fixed that overflows gives INT_MIN
(0x80000000) which can make future calculations negative
when they should be positive. This trips asserts (or in release
builds, crashes).
Sanitize the values here.
Robin Watts [Mon, 17 Jul 2023 16:14:16 +0000 (17:14 +0100)]
Bug 706859: Keep fz layer up to date with changes in pdf pages.
When we pdf_insert_page or pdf_delete_page, we modify the pdf
page tree, but don't adjust the list of opened pages that the
fz layer is holding.
Make those modifications here.
Robin Watts [Mon, 17 Jul 2023 13:33:42 +0000 (14:33 +0100)]
Fix some windows builds.
The java winmake.bat was asking for ViewerCore.js rather than
ViewerCore.java.
Some OpenSSL and Java builds were confused as to project
dependencies in the solution.
Robin Watts [Mon, 17 Jul 2023 12:15:45 +0000 (13:15 +0100)]
Bug 706895: Cope with NULL X509 pointer in PKCS7 code.
Julian Smith [Mon, 3 Jul 2023 22:45:50 +0000 (23:45 +0100)]
docs/src/language-bindings.rst: also include info about building on MacOS.
Also made small improvement to file tree description.
Julian Smith [Fri, 23 Jun 2023 12:31:00 +0000 (13:31 +0100)]
scripts/wrap/__main__.py: fix bindings builds on pyodide/wasm and 32-bit Windows.
If $OS is `wasm` or `wasm-mt`, use em++ for compiling and linking
instead of c++.
If $PYODIDE_BUILD is set:
Get includes and link flags from $PYO3_CROSS_INCLUDE_DIR and
$PYO3_CROSS_LIB_DIR instead of using python-config (which is not
available).
Link libmupdfcpp.so with `-sSIDE_MODULE` amd link _mupdf.so with
`-sMAIN_MODULE`.
Don't specify -Wl,-rpath*.
In 32-bit Windows builds:
Fixed --test-cpp for 32 bit windows builds.
Cope with libclang failing: When handling `-b 0` to generate
C++ code, if we are running under 32-bit python on windows and
clang.cindex fails, run ourselves in a separate process in a new
venv with 64-bit python and `-b 0`.
Also moved '-b 0' code into separate fn.
General:
Changed --venv to make its own venv name containing python version
and cpu bits, so builds with different python versions can co-exist.
In `-b`, added `-j N` sub-arg, copied into the `make` command when
building C shared libraries with `-b m`.
Julian Smith [Tue, 4 Jul 2023 11:20:22 +0000 (12:20 +0100)]
scripts/wdev.py scripts/wrap/state.py: fixed detection of 32-bit Python.
Julian Smith [Wed, 21 Jun 2023 08:57:58 +0000 (09:57 +0100)]
Makefile Makerules: Allow shared-library builds for Pyodide/wasm.
Don't override HAVE_LIBCRYPTO or OS if they have been set in the
environment. (`=` and `:=` do not overwrite items set by make
command-line args `make foo=bar ...`, but they do overwrite variables
that have been set from the environment.)
If $OS is 'wasm-mt', build shared libraries with `-sSIDE_MODULE` and
executables with `-sMAIN_MODULE`, as required by wasm/pyodide.
Build `source/tools/%.o` files with $(LIB_CFLAGS) so things work with
`-fPIC` for wasm builds.
If $PYODIDE_ROOT set, don't set HAVE_OBJCOPY, because emsdk's ld does
not support `-b binary`. Also add `-sTOTAL_MEMORY=48MB` to LDFLAGS to
allow link to work.
Don't override $HAVE_LIBCRYPTO if already set, so it can be set in
environment before make is run.
Update c++-* targets' to use `scripts/mupdfwrap.py`'s modified `--venv`
arg.
Robin Watts [Mon, 17 Jul 2023 11:57:09 +0000 (12:57 +0100)]
Bug 706896: Throw from pdf_count_pages on negative numbers.
Never return a negative number of pages.
Robin Watts [Mon, 17 Jul 2023 10:25:53 +0000 (11:25 +0100)]
Update harfbuzz for more symbol renamings.
Thanks to https://github.com/DavidLazarescu for helping to track
this down.
Sebastian Rasmussen [Fri, 14 Jul 2023 16:34:12 +0000 (18:34 +0200)]
gl: Update generated trace scripts to new APIs.
Robin Watts [Fri, 14 Jul 2023 15:12:39 +0000 (16:12 +0100)]
Update Harfbuzz with renaming header.
Avoids our use of harfbuzz clashing with other callers.
Tor Andersson [Fri, 14 Jul 2023 11:52:21 +0000 (13:52 +0200)]
mutool run: Clean up memory when calling quit().
Robin Watts [Fri, 14 Jul 2023 11:51:35 +0000 (12:51 +0100)]
Continued fixes for joining pdf_journal_entries.
There are 2 places in pdf_end_operation where we join entries.
As such, we need to resolve_undo() both of them, rather than
just one.
Also, in resolve_undo, when we found 2 changes to the same
object, I was keeping the 'before' state from the later change,
which is precisely the wrong thing to do! Fix that.
Also drop the 'before' buffer from later changes to avoid leaks.
Robin Watts [Thu, 13 Jul 2023 15:26:46 +0000 (16:26 +0100)]
Fix problem when joining pdf_journal_entries (implicit or nested).
We carefully create pdf_journal_entries so that they only ever
mention a given object number once.
We were then breaking this invariant by merging pdf_journal_entries
whenever we close a nested (or implicit) operation.
Add a new function to ensure we resolve such issues on a merge.
Also, tweak the logic in prepare_object_for_alteration to take note
of the new pending list.
Tor Andersson [Fri, 7 Jul 2023 12:30:28 +0000 (14:30 +0200)]
Add support for CropBox, TrimBox, BleedBox, and ArtBox.
Clip page contents to CropBox if it is smaller than the MediaBox.
Add a new function fz_bound_page_box to request bounds for using a box other
than the default MediaBox.
Add a "box" argument to PDF-specific pdf_new_pixmap_from... helper functions.
The "fitz" coordinate space is unchanged; it is still left-handed with the
origin based on the MediaBox.
Tor Andersson [Mon, 10 Jul 2023 10:38:48 +0000 (12:38 +0200)]
Add method to redact a single annotation.
Tor Andersson [Fri, 7 Jul 2023 15:12:09 +0000 (17:12 +0200)]
Fix pdf_filter_re call to fz_rectto.
Tor Andersson [Thu, 6 Jul 2023 22:45:42 +0000 (00:45 +0200)]
wasm: Fix new Font(name, buffer, index) argument order.
Sebastian Rasmussen [Tue, 11 Jul 2023 15:04:08 +0000 (17:04 +0200)]
Encapsulate document saving into an operation.
Saving a document may create a new xref stream object.
This happened outside any existing operation, which used to cause
an assert in the journaling code. By encapsulating the saving
code in a PDF operation this is avoided.
Sebastian Rasmussen [Tue, 4 Jul 2023 12:06:40 +0000 (14:06 +0200)]
Fix java build on Windows.
Sebastian Rasmussen [Sat, 8 Jul 2023 16:12:59 +0000 (18:12 +0200)]
Handle parsing file paths without destinations.
This is used for Launch actions.
Sebastian Rasmussen [Fri, 7 Jul 2023 09:21:34 +0000 (11:21 +0200)]
Support adding URL-based file specifications.
This fixes Coverity issue 321989 because pdf_add_filespec()
can no longer be called with filename being NULL.
Sebastian Rasmussen [Fri, 7 Jul 2023 09:36:08 +0000 (11:36 +0200)]
Remove unused function causing a Coverity complaint.
This fixes Coverity issue 321988.
Jamie Lemon [Thu, 6 Jul 2023 21:32:54 +0000 (22:32 +0100)]
wasm: Aligns docs more with latest fixes.
Tor Andersson [Wed, 28 Jun 2023 14:08:50 +0000 (16:08 +0200)]
wasm: Fixes and more bindings.
--
Add this._doc to PDFObject, PDFPage, PDFAnnot.
We need this for passing to PDFOBJ(doc, obj) in order to create
PDF dictionaries and arrays from native Javascript objects.
--
Compile with WASM_ASYNC_COMPILATION=0 to avoid the need for "await" or
a "ready" callback.
--
Lots of new functions and methods exposed.
Lots of fixes to existing bindings.
Tor Andersson [Tue, 4 Jul 2023 14:15:13 +0000 (16:15 +0200)]
mutool run: Add PDFDocument.prototype.getEmbeddedFiles method.
Tor Andersson [Tue, 4 Jul 2023 14:14:53 +0000 (16:14 +0200)]
mutool run: Remove bad code that created globals for the class prototypes.
Sebastian Rasmussen [Sun, 22 Jan 2023 13:50:34 +0000 (14:50 +0100)]
js/java/c/gl: Add interfaces to format GoToR remote link destinations.
Sebastian Rasmussen [Fri, 23 Jun 2023 01:22:50 +0000 (03:22 +0200)]
pdf: Move internal link related functions to internal header.