Commit Graph

339 Commits

Author SHA1 Message Date
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 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 73752683c9 Fix overlay/underlay on page with no resources (fixes #527) 2021-11-03 16:00:05 -04:00
Jay Berkenbilt 7ed991343b Better diagnostics when --pages is not closed (fixes #555) 2021-11-02 16:22:37 -04:00
Jay Berkenbilt df38fe8e48 Fix string bounds checking in completion code (fixes #441) 2021-05-13 13:06:58 -04:00
Jay Berkenbilt 30ac51bc78 Exclude unreferenced objects in object streams (fixes #520) 2021-05-08 09:42:09 -04:00
Jay Berkenbilt 8971443e46 QPDF::addPage*: handle duplicate pages more robustly 2021-04-05 10:58:10 -04: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 addc0672d1 Tweak form copying to avoid gratuitous field renames
When copying a page from the original file to the output in --pages,
don't alter the fields or annotations for the first copy of each page.
2021-03-05 05:31:15 -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 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 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 9e00be7ffa Remove warning that gives false positives in some normal cases 2021-02-23 08:26:21 -05:00
Jay Berkenbilt 039eb4a253 Fix input file = output file test for split pages 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 50037fb33d Fix test case to not leave stray files behind 2021-02-22 19:51:36 -05:00
Jay Berkenbilt 83216e640c Preserve form fields when splitting pages (fixes #340) 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 a9ae8cadc6 Add transformAnnotations and fix flattenRotations to use it 2021-02-21 17:13:09 -05:00
Jay Berkenbilt 7540d2082a Explicitly override inherited rotate in flattenRotations 2021-02-21 14:58:45 -05:00
Jay Berkenbilt 92fbc6fdf5 QPDFObjectHandle::copyStream 2021-02-21 06:36:30 -05:00
Jay Berkenbilt 35dd11f356 Allow --rotate=0 2021-02-20 16:29:34 -05:00
Jay Berkenbilt 0a52e60ece Use QUtil::path_basename 2021-02-18 09:59:03 -05:00
Jay Berkenbilt dfce581754 Add numeric argument to --collate
This takes pages from the file in groups of n with default = 1. This
partially fixes the enhancement in issue #505 but doesn't implement
the entire suggestion.
2021-02-17 20:07:45 -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 accb891b4f Add attachment information to the json output 2021-02-10 15:46:18 -05:00
Jay Berkenbilt 832d792e4e Add CLI support for working with attachments 2021-02-10 10:03:27 -05:00
Jay Berkenbilt ad34b9c278 Implement helpers for file attachments 2021-02-10 06:57:37 -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 3de67173de Better fix to insecure password check (fixes #501) 2021-02-04 20:44:05 -05:00
Jay Berkenbilt 63158cf546 Add --password-file=filename option (fixes #499) 2021-02-04 16:48:53 -05:00
Jay Berkenbilt 21b0f4acfc Require --allow-insecure to create certain encrypted files (fixes #501)
For now, --allow-insecure allows creation of files with the owner
passwords empty or matching the user password.
2021-02-04 15:57:13 -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 e7e20772ed name/number trees: remove 2021-01-26 09:12:23 -05:00
Jay Berkenbilt b5614f611d Implement repair and insert for name/number trees 2021-01-24 19:31:45 -05:00
Jay Berkenbilt 6fe7b704c7 Warn rather than segv on access after closing input source (fixes #495) 2021-01-06 10:11:34 -05:00
Jay Berkenbilt 891751f618 Remove unreferenced resources only from relevant pages 2021-01-04 15:17:35 -05:00
Jay Berkenbilt 3be58f49e5 Make more QPDFPageObjectHelper methods work with form XObject 2021-01-02 14:08:53 -05:00
Jay Berkenbilt 98da4fd835 Externalize inline images now includes form XObjects 2021-01-02 14:08:17 -05:00
Jay Berkenbilt a139d2b36d Add several methods for working with form XObjects (fixes #436)
Make some more methods in QPDFPageObjectHelper work with form
XObjects, provide forEach methods to walk through nested form
XObjects, possibly recursively. This should make it easier to work
with form XObjects from user code.
2021-01-02 12:29:31 -05:00
Jay Berkenbilt c9271335fa Add QPDFPageObjectHelper::flattenRotation and --flatten-rotation 2020-12-30 13:03:55 -05:00
Jay Berkenbilt 12ecd2019a Add QPDFObjectHandle::setFilterOnWrite 2020-12-28 12:58:19 -05:00
Jay Berkenbilt 858c7b89bc Let optimize filter stream parameters instead of making them direct
Also removes preclusion of stream references in stream parameters of
filterable streams and reduces write times by about 8% by eliminating
an extra traversal of the objects.
2020-12-28 12:58:19 -05:00
Jay Berkenbilt cc8895078a Add QPDFObjectHandle::makeDirect(bool allow_streams) 2020-12-26 08:48:18 -05:00
Jay Berkenbilt 2050977099 Add QPDFObjectHandle manipulation to C API 2020-11-28 19:48:07 -05:00
Jay Berkenbilt a7ef572c84 Small enhancement to --pages argument parsing 2020-11-09 11:12:34 -05:00
Jay Berkenbilt 47f4ebcdac Ignore unused field in xref entry, avoiding range error (fixes #482) 2020-11-04 07:46:46 -05:00