Jay Berkenbilt
245ca28066
Use value rather than reference captures where possible
2021-12-16 11:47:07 -05:00
Jay Berkenbilt
af2a71aa2c
Handle bitstream overflow errors more gracefully ( fixes #581 )
...
* Make it a runtime error, not a logic error
* Include additional information
* Capture it properly in checkLinearization
2021-12-10 15:37:35 -05:00
Jay Berkenbilt
1c62c2a342
C API: expose functions for indirect objects ( fixes #588 )
2021-12-10 14:57:35 -05:00
Jay Berkenbilt
72c10d8617
C API: overhaul error handling
...
* Handle error conditions that occur when using the object handle
interfaces. In the past, some exceptions were not correctly
converted to errors or warnings.
* Add more detailed information to qpdf-c.h
* Make it possible to work more explicitly with uninitialized objects
2021-12-10 12:16:02 -05:00
Jay Berkenbilt
3340dbe976
Use a specific error code for type warnings and clarify docs
2021-12-10 11:15:49 -05:00
Jay Berkenbilt
b2b2a175c4
Add missing unit test for register progress reporter in C API
...
It was exercised in the pdf-linearize example but not in qpdf-ctest.
2021-12-10 09:11:56 -05:00
Jay Berkenbilt
1faa21502f
Refactor trap_errors to use std::function
2021-12-09 10:33:31 -05:00
Jay Berkenbilt
e3cc171d02
C API: qpdf_oh_is_initialized
2021-12-09 10:33:31 -05:00
Jay Berkenbilt
bef2c2222a
C API: qpdf_get_last_string_length
2021-12-09 10:33:31 -05:00
m-holger
b4fc9eb700
C-API expose new_object as qpdf_oh_new_object
2021-12-02 13:59:58 -05:00
Jay Berkenbilt
720ce9e8f3
Improve testing and error handling around operating before processing
2021-11-29 07:42:36 -05:00
Jay Berkenbilt
ac17308cf6
Initialize QPDF::Members::file ( fixes #584 )
2021-11-29 07:16:34 -05:00
m-holger
4630b8567c
Ensure qpdf_oh handles returned by C-API functions are unique.
...
Return new qpdf_oh from qpdf_oh_wrap_in_array when input is already an array.
Update some doc comments in qpdf-c.h.
2021-11-19 13:31:59 +00:00
Jay Berkenbilt
ce7db05d22
Prepare 10.4.0 release
2021-11-16 15:44:09 -05:00
Jay Berkenbilt
750aca5b94
First increment of improving handling of weak crypto ( fixes #358 )
2021-11-11 12:24:15 -05:00
Jay Berkenbilt
f45dacf4cb
Make recovery logic flexible about where objects end ( fixes #573 )
...
Don't assume endobj is at the beginning of the line. This means we are
looking at tokens for every line, but the odds of n n obj appearing in
the middle of the object are likely much lower than endobj not being
at the beginning of the line or missing entirely. This will probably
have a negative impact on recovery time for very large files.
Hopefully it will be worth it.
2021-11-07 15:27:22 -05:00
Jay Berkenbilt
3794f8e2ad
Support OpenSSL 3 ( fixes #568 )
2021-11-04 18:24:54 -04:00
Jay Berkenbilt
a84a0b2487
Add range check in QPDFNumberTreeObjectHelper (fuzz issue 37740)
2021-11-04 14:03:24 -04:00
Jay Berkenbilt
4a648b9a00
Fix bug in merging resources /DR from foreign AcroForm ( fixes #548 )
...
When making resources indirect in from_dr, the code was using the
wrong owning QPDF, forgetting that from_dr had already been copied
using CopyForeignObject.
2021-11-04 12:29:42 -04:00
Jay Berkenbilt
9b28933647
Check object ownership when adding
...
When adding a QPDFObjectHandle to an array or dictionary, if possible,
check if the new object belongs to the same QPDF. This makes it much
easier to find incorrect code than waiting for the situation to be
detected when the file is written.
2021-11-04 12:29:42 -04:00
Jay Berkenbilt
33a47d5c3c
Make QPDF::findPage public ( fixes #516 )
...
This was originally not public because I wanted to get rid fo the
pages cache, but I recently realized there were deep reasons not to do
that, and the author of pikepdf wanted this, so I decided to make it
public.
2021-11-03 09:43:17 -04:00
Jay Berkenbilt
532a4f3d60
Detect recoverable but invalid zlib data streams ( fixes #562 )
2021-11-03 09:43:17 -04:00
Fredrik Fornwall
e0775238b8
Fix QPDFEFStreamObjectHelper::{get,set}Subtype
...
The /Subtype entry that specifies the mime type of an embedded file is
inside the embedded file stream dictionary directly, not it in the
parameter dictionary.
See Table 45 and 46 in the PDF 1.7 specification:
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=112
2021-09-10 10:02:24 -04:00
Jay Berkenbilt
3cacb27a90
Performance fix on preserveObjectStreams
2021-05-09 07:51:14 -04:00
Jay Berkenbilt
bddebdb0ea
Prepare 10.3.2 release
2021-05-08 10:41:14 -04:00
Jay Berkenbilt
30ac51bc78
Exclude unreferenced objects in object streams ( fixes #520 )
2021-05-08 09:42:09 -04:00
Zdenek Dohnal
16c19e9424
libqpdf/Pl_AES_PDF.cc: remove duplicated if branch
...
Check for this->encrypt seems to be moved to plugged crypto
implementations, so it can be removed from Pl_AES_PDF.cc.
2021-04-29 09:42:38 -04:00
Jay Berkenbilt
36c7c20819
Fix timezone portability issue ( fixes #515 )
2021-04-17 18:12:55 -04:00
Jay Berkenbilt
8971443e46
QPDF::addPage*: handle duplicate pages more robustly
2021-04-05 10:58:10 -04:00
Jay Berkenbilt
ec48820c3c
Fix loop detection in NNTree
2021-04-05 07:59:02 -04:00
Jay Berkenbilt
258675fc99
Move ABI comment to the right place
2021-04-03 11:43:08 -04:00
Jay Berkenbilt
a77f58142d
Remove some assertions that are not necessarily true ( fixes #514 )
...
Operations that add the same object to multiple places in the pages
tree are throwing exceptions and then later causing assertion
failures. The assert calls shouldn't be there.
2021-03-21 19:35:23 -04:00
Jay Berkenbilt
3f05429cc5
Prepare 10.3.1 release
2021-03-11 12:59:41 -05:00
Jay Berkenbilt
85884c363c
Allow /DR to be direct in /AcroForm
...
Also handle direct annotation, though this is much less likely.
2021-03-11 11:43:38 -05:00
Jay Berkenbilt
dc65b88457
Prepare 10.3.0 release
2021-03-05 06:15:48 -05:00
Jay Berkenbilt
cb6e53136f
QPDFAcroFormDocumentHelper: add missing analyze calls
2021-03-04 18:11:44 -05:00
Jay Berkenbilt
0b77f2cf26
Revert non-binary-compatible handleWarning change -- see TODO (ABI)
2021-03-04 15:59:46 -05:00
Jay Berkenbilt
f68e25c7f2
Don't use handleWarning, which is being reverted
2021-03-04 15:59:45 -05:00
Jay Berkenbilt
9fb174b9e9
Major rework of handling form fields when copying pages ( fixes #509 )
2021-03-04 15:08:37 -05:00
Jay Berkenbilt
887f35efaa
When resolving font from /DR, copy it into resources
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
a2124f992c
Add QPDFMatrix::operator==
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
552303a94a
Check for reserved after dereference
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
d7ffdfa994
Add optional conflict detection to mergeResources
...
Also improve behavior around direct vs. indirect resources.
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
e17585c2d2
Remove unreferenced: ignore names that are not Fonts or XObjects
...
Converted ResourceFinder to ParserCallbacks so we can better detect
the name that precedes various operators and use the operators to sort
the names into resource types. This enables us to be smarter about
detecting unreferenced resources in pages and also sets the stage for
reconciling differences in /DR across documents.
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
a15ec6967d
Enhancements to ParserCallbacks
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
1bb209a9bf
Add QPDF::numWarnings
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
37fcc5ff71
Create ResourceFinder from NameWatcher in QPDFPageObjectHelper
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
b444ab3352
Fix typos in coverage cases
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
fa2516df71
Fix behavior for finding /Q, /DA, and /DR for form fields
...
If not found in the field hierarchy, /Q and /DA are supposed to be
looked up in the document-level form dictionary. /DR is supposed to
only come from the document dictionary.
2021-03-03 17:05:19 -05:00
Jay Berkenbilt
a4d6589ff2
Have QPDFObjectHandle notice when replaceObject was called
...
This results in a performance penalty of 1% to 2% when replaceObject
and swapObjects are never called and a somewhat larger penalty if they
are called, but it's worth it to avoid very confusing behavior as
discussed in depth in qpdf#507.
2021-02-25 07:32:46 -05:00
Jay Berkenbilt
ec6719fd25
Always call dereference() before querying obj pointer
2021-02-25 07:31:26 -05:00
Jay Berkenbilt
b5e937397c
Prepare 10.2.0 release
2021-02-23 10:41:58 -05:00
Jay Berkenbilt
1886673d7e
Spell check
2021-02-23 10:38:05 -05:00
Jay Berkenbilt
9e00be7ffa
Remove warning that gives false positives in some normal cases
2021-02-23 08:26:21 -05:00
Jay Berkenbilt
be3a8c0e7a
Keep only referenced form fields in --pages
2021-02-23 08:26:21 -05:00
Jay Berkenbilt
83216e640c
Preserve form fields when splitting pages ( fixes #340 )
2021-02-22 18:42:06 -05:00
Jay Berkenbilt
1f35ec9988
Add methods for copying form fields
2021-02-22 18:42:06 -05:00
Jay Berkenbilt
8e8c0d8290
Add new placeFormXObject that takes a matrix reference
2021-02-22 18:42:06 -05:00
Jay Berkenbilt
61d41e2e88
Add copyAnnotations, use with overlay/underlay ( fixes #395 )
2021-02-22 18:42:06 -05:00
Jay Berkenbilt
7b3cbacf5d
Change from QPDF{Array,Dict}Items to aitems() and ditems()
2021-02-22 11:05:39 -05:00
Jay Berkenbilt
a9ae8cadc6
Add transformAnnotations and fix flattenRotations to use it
2021-02-21 17:13:09 -05:00
Jay Berkenbilt
a76decd2d5
Add QPDFObjGen::unparse
2021-02-21 16:21:52 -05:00
Jay Berkenbilt
7540d2082a
Explicitly override inherited rotate in flattenRotations
2021-02-21 14:58:45 -05:00
Jay Berkenbilt
e899926e0d
Use QPDFMatrix inside flattenRotations
2021-02-21 14:58:45 -05:00
Jay Berkenbilt
92fbc6fdf5
QPDFObjectHandle::copyStream
2021-02-21 06:36:30 -05:00
Jay Berkenbilt
60afe4142e
Refactor: separate copyStreamData from replaceForeignIndirectObjects
2021-02-21 06:36:30 -05:00
Jay Berkenbilt
15269f36d8
addFormField: update cache rather than invalidating
2021-02-21 06:36:30 -05:00
Jay Berkenbilt
901f1a788c
Enhance QPDFMatrix API
2021-02-21 06:36:30 -05:00
Jay Berkenbilt
05eb5826d8
Fix isPagesObject and isPageObject
...
There are lots of things with /Kids that are not pages. Repair the
pages tree, then do a reliable check.
2021-02-20 19:42:41 -05:00
Jay Berkenbilt
35dd11f356
Allow --rotate=0
2021-02-20 16:29:34 -05:00
Jay Berkenbilt
71e8627285
Add const versions of QPDFMatrix::transform*
2021-02-19 18:35:19 -05:00
Jay Berkenbilt
de8929a41c
Add QPDFAcroFormDocumentHelper::addFormField
2021-02-18 12:25:48 -05:00
Jay Berkenbilt
5cec6b4c3d
Add QPDFPageObjectHelper::getMatrixForFormXObjectPlacement
2021-02-18 12:25:48 -05:00
Jay Berkenbilt
0765872295
Form field for non-widget just returns null
2021-02-18 10:25:07 -05:00
Jay Berkenbilt
0b1623d07d
Add QUtil::path_basename
2021-02-18 09:59:03 -05:00
Jay Berkenbilt
a773f4c71d
Add QPDFObjectHandle::parse for strings with context
2021-02-15 11:33:03 -05:00
Jay Berkenbilt
7eb903d9aa
Use functional replaceStreamData
2021-02-14 14:42:24 -05:00
Jay Berkenbilt
efbb21673c
Add functional versions of QPDFObjectHandle::replaceStreamData
...
Also fix a bug in checking consistency of length for stream data
providers. Length should not be checked or recorded if the provider
says it failed to generate the data.
2021-02-14 14:42:24 -05:00
Jay Berkenbilt
e2593e2efe
Move QPDFMatrix into the public API
2021-02-13 02:30:00 -05:00
Jay Berkenbilt
07f40bd254
QUtil::double_to_string: trim trailing zeroes with option to disable
2021-02-13 02:30:00 -05:00
Jay Berkenbilt
8fbc8579f2
Allow zone information to be omitted from timestamp strings
2021-02-11 14:26:55 -05:00
Jay Berkenbilt
df067c9ab6
Add autoconf test for localtime_r
2021-02-11 14:26:55 -05:00
Jay Berkenbilt
1b3f84f967
Require C++14 instead of C++11
2021-02-10 16:27:58 -05:00
Jay Berkenbilt
9fcf61b2f6
Fix loop in QPDFOutlineDocumentHelper (fuzz issue 30507)
2021-02-10 16:27:44 -05:00
Jay Berkenbilt
4d1f2fdcac
Update to new name/number tree API
2021-02-10 15:46:20 -05:00
Jay Berkenbilt
1f4771cd0d
Minor clean up of Windows headers
2021-02-10 07:36:18 -05:00
Jay Berkenbilt
ad34b9c278
Implement helpers for file attachments
2021-02-10 06:57:37 -05:00
Jay Berkenbilt
bf0e6eb302
Add QUtil methods for dealing with PDF timestamp strings
2021-02-09 17:50:24 -05:00
Jay Berkenbilt
bfbeec5497
Make newly created name/number trees indirect objects
2021-02-08 06:49:56 -05:00
Jay Berkenbilt
553ac7f353
Add QUtil::pipe_file and QUtil::file_provider
2021-02-07 19:41:34 -05:00
Jay Berkenbilt
e076c9bf08
Remove erroneous handling of /EFF for stream decryption
...
I thought /EFF was supposed to be used as a default for decrypting
embedded file streams, but actually it's supposed to be advice to a
conforming writer about handling new ones. This makes sense since the
findAttachmentStreams code, which is not actually needed, was never
right.
2021-02-06 17:08:41 -05:00
Jay Berkenbilt
ac2b3b96e1
Make wrong object stream type a warning
2021-02-06 14:29:11 -05:00
Jay Berkenbilt
faa2e3ddfd
Handle older PDFs whose form XObjects inherit resources ( fixes #494 )
...
When removing unreferenced resources, notice if a page (recursively)
contains a form XObject with unreferenced resources, and count any
such resources as referenced by the page.
2021-02-02 18:06:05 -05:00
Jay Berkenbilt
81025e4998
Refactor removal of unreferenced resources
...
Refactor in preparation for resolving unresolved resources in form
xobjects from page.
2021-02-02 18:06:05 -05:00
Jay Berkenbilt
9c9ce64eec
Handle strings in inline image dictionaries
...
We need to use token.getRawValue, not token.getValue
2021-01-31 07:50:03 -05:00
Jay Berkenbilt
178f995fc2
Recover from exceptions during filtering for inline images
2021-01-31 07:49:08 -05:00
Jay Berkenbilt
4ae93a73c5
Improve memory safety of dict/array iterators
2021-01-31 07:16:03 -05:00
Jay Berkenbilt
de0b11fc47
Add C++ iterator API around array and dictionary objects
2021-01-30 15:15:23 -05:00
Jay Berkenbilt
35e7859bc7
Make QPDFObjectHandle::is* return false for uninitialized objects
2021-01-29 15:46:54 -05:00
Jay Berkenbilt
50decc9bb8
name/number tree: explicitly declare default destructors
2021-01-29 15:46:54 -05:00