Jay Berkenbilt
7eeaf58bb7
More doc tweaks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
7097f29019
More editorial changes from m-holger + spell check
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0e909bab8e
Improve top-level help information
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0364024781
Use QPDFUsage exception for cli, json, and QPDFJob errors
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f3d68aa5a0
Incorporate editorial changes from m-holger
2022-01-30 13:11:03 -05:00
m-holger
7dd5f31230
Fix typos in manual
...
Fix typos in cli.rst
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c62ab2ee9f
QPDFJob: use pointers instead of references for Config
...
Why? The main methods that create them return smart pointers so that
users can initialize them when needed, which you can't do with
references. Returning pointers instead of references makes for a more
uniform interface.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
03f3369f35
QPDFJob: use manually named end functions for Config classes
...
Use named functions rather than just end() for clarity.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
9013b7ca91
QPDFJob: move placeholder json to a separate source file
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
edef2cd330
QPDFJob: make remaining members private
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f2409f4fca
Minor cleanup
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
01969c78a8
QPDFJob: move private members into Members
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
cf6c56a463
QPDFJob: use config API in place-holder json
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2c7b583b3a
QPDFJob: move input/output handling into config
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1258054543
QPDFJob: eliminate most access to QPDFJob members from ArgParser
...
All that's left now is input and output handling.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
901e3e4fbf
QPDFArgParser: remove unused copyFromOtherTable
...
This was used, but it no longer is, so let's not keep the extra
complexity around.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
700dfa40d3
QPDFJob: convert encryption handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b5d41b16b8
QPDFJob: convert under/overlay and rotate
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1cc532dc91
QPDFJob: move some helpers from ArgParser to QPDFJob
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
95d127641c
QPDFJob: move more top-level trivial handlers into config
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
41c5af8f26
QPDFJob: convert pages
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
9373881cca
Add QPDFJob::ConfigError exception
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0a354af02c
QPDFJob: convert AddAttachment handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
bf255ccc89
QPDFJob: convert password in two tables
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
21c897aad0
QPDFJob: convert a flag in other than the main table
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f60526aff9
QPDFJob: start changing generation for trivial config handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b4b0df0df9
QPDFJob: convert trivial functions to config API
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
79187e585a
QPDFJob: begin configuration API with verbose
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
160e869d1e
Mark trivial arg functions
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
558f043d91
QPDFJob: TRUE -> true
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
fcdbc8a102
Move doFinalChecks to QPDFJob::checkConfiguration
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c4e56fa5f4
QPDFJob: make createsOutput callable before run()
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
564dc03607
QPDFJob: start real API
...
Create QPDFJob_options.cc to hold API implementation functions.
Reorganize a little in preparation for moving public member variables
private and creating the real QPDFJob API that will be used by callers
as well as the argv/json initialization methods.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1d099ab743
QPDFJob: placeholder for initializeFromJson
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1c8d53465f
Incorporate job schema generation into generate_auto_job
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b9cd693a5b
QPDFJob: allocate QPDFArgParser on stack
...
The previous commits have removed all references to memory from
QPDFArgParser from QPDFJob. This commit removes the constraint that
QPDFArgParser remain in scope. This is a prerequisite to allowing JSON
as an alternative way to initialize QPDFJob and to initialize it
directly using a public API.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
d526d4c17f
QPDFJob: convert Under/Overlay to use shared pointers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
88891a75a2
QPDFJob: convert Under/Overlay ranges to strings
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e48bfce930
QPDFJob: convert PageSpec to used shared pointer
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e4905983d2
QPDFJob: convert outfilename to shared pointer
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e5edfc786f
QPDFJob: convert infilename to shared pointer
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
ee7824cf28
QPDFJob: convert encryption_file args to shared pointers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
021db6f226
QPDFJob: convert password to shared pointer
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1a8c2eb93b
QPDFJob: use std::shared_ptr over PointerHolder where possible
...
Also fix QPDFArgParser
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
76c4f78b5c
Add QUtil::make_shared_cstr
...
Replace most of the calls to QUtil::copy_string with this instead.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
67f9d0b7d5
cli.rst: remove () from end of short help
...
This is used to generate a schema for the job json, which can't
contain `)"` because it breaks the R"(...)" syntax in C++. While C++
accepts R"anything(...)anything" to avoid this, as of this writing,
MSVC 2019 doesn't understand that. For now, just avoid it by removing
parentheses from the end of short help.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
8dea480c9f
Allow optional fields in json "schema" checks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
ec85e56c3f
Add missing help topic for inspection
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1db0a7ffce
JSONHandler: rework dictionary and array handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
acf8d18b6e
Editorial changes to cli.rst
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
cf8405d91e
Fix json schema for objects to include dictionary key
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2e58541493
Use JSON::parse to initialize schema for json mode
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
37105710ee
Implement JSONHandler for recursively processing JSON
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
a6df6fdaf7
CLI doc: use tables where helpful
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e8e8f6f43c
Add JSON::parse
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b9af421ef7
Add missing \f support for JSON string encoder
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
aa0a379b37
Add JSON::isDictionary and JSON::isArray
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
5c5e5ca29b
Document how to add a command-line argument
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c8729398dd
Generate help content from manual
...
This is a massive rewrite of the help text and cli.rst section of the
manual. All command-line flags now have their own help and are
specifically index. qpdf --help is completely redone.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b4bd124be4
QPDFArgParser: support adding/printing help information
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
5303130cf9
Fix comment on duplicated top-level json keys
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
53ba65eb59
QPDFArgParser: handle optional choices including help
...
Handle optional choices in addition to required choices. Refactor the
way help options are added to completion to make it work with optional
help choices.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
a301cc5373
Minor code cleanup
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
3ab25d595b
Fix doc typos caught by m-holger -- thanks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
4577df4b5d
QPDFJob increment: generate option table initialization
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f1d805badc
Add QPDFArgParser::copyFromOtherTable
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c3e9b64e7f
QPDFJob increment: generate handler declarations
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
6e70d99b58
QPDFJob increment: generate choices variables in init
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
cb684ec4d3
QPDFJob increment: generate table names
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f8eee83515
Expose QPDFArgParser::usage
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
8dcf6da259
QPDFJob: remove non-check from doFinalChecks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c216854607
Add basic framework for QPDFJob code generation
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
bd89aac360
QPDFJob increment: move arg parsing into QPDFJob
...
Move ArgParser from qpdf.cc into QPDFJob.cc. It still works with
millions of public member variables, but now qpdf.cc is minimal and
just calls stable library functions.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
12396702af
QPDFJob: reorder functions, no other changes
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2394dd8519
QPDFJob increment: static functions to member functions
...
Convert remaining static functions that take QPDFJob& as a parameter
to member functions. Utility functions that don't take QPDFJob& remain
static functions and can probably just stay that way since the keep
extra complexity out of QPDFJob.hh.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e2975b9ed0
QPDFJob: de-templatize do_process and do_process_once
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2f631997f2
QPDFJob increment: remove std::cout, std::cerr, whoami
...
Remove remaining temporary duplication of hard-coded values and direct
access to std::cout, std::cerr, and whoami in favor of parameters in
QPDFJob. This moves a few more static methods into QPDFJob member
functions.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1ddf5b4b4b
QPDFJob increment: get rid of exit, handle verbose
...
Remove all calls to exit() from QPDFJob. Handle code that runs in
verbose mode to enable it to make use of output streams and message
prefix (whoami) from QPDFJob. This removes temporarily duplicated exit
code logic and most access to whoami/std::cout outside of QPDFJob
proper.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0910e767ad
QPDFJob increment: basic QPDFJob structure
...
Move most of the methods called from qpdf.cc after argument parsing
into QPDFJob. In this increment, enough QPDFJob API has been added to
handle the branch of QPDFJob::run() that creates output with an
appropriate division between qpdf.cc and QPDFJob.
There are temporary bits of code to enable everything to compile and
pass the test suite, including some duplication and hard-coded values.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
52817f0a45
Implement QPDFArgParser based on ArgParser from qpdf.cc
2022-01-30 13:11:02 -05:00
m-holger
0f9086e509
Fix doc typos
2022-01-30 12:09:54 -06:00
m-holger
8eca9d8fd9
Fix QPDFObjectHandle::isOrHasName
...
Ensure isOrHasName returns true if object is an array and the name is
present anywhere in the array.
2022-01-27 09:35:39 -06:00
m-holger
07db3200cb
Remove some if statements and simplify some boolean expressions
...
Use QPDFObjectHandle::isNameAndEquals, isDictionaryOfType and
isStreamOfType.
2022-01-27 07:31:12 -06:00
m-holger
710d2e54f0
Allow testing for subtype without specifying type in isDictionaryOfType etc
...
Accept empty string as type parameter in
QPDFObjectHandle::isDictionaryOfType and isStreamOfType
to allow for dictionaries with optional type.
2022-01-27 07:31:12 -06:00
m-holger
1b1b471ca9
Make a few whitespace fixes from last commit
...
Commit by ejb@ql.org using m-holger as author so git annotate gives
proper credit for changes.
2022-01-22 09:14:53 -05:00
m-holger
8593b9fdf7
Add new convenience methods QPDFObjectHandle::isNameAndEquals, etc
...
Add methods isNameAndEquals, isDictionaryOfType, isStreamOfType
2022-01-22 08:10:28 -06:00
Jay Berkenbilt
370710657a
Add missing characters from PDF doc encoding ( fixes #606 )
2022-01-11 15:55:19 -05:00
Jay Berkenbilt
77c31305fe
Fix signed/unsigned char warning ( fixes #604 )
2022-01-11 06:51:31 -05:00
Jay Berkenbilt
af91b5b584
Add QUtil::file_can_be_opened
2021-12-29 13:41:02 -05:00
Jay Berkenbilt
04745320d6
Prepare 10.5.0 release
2021-12-20 14:51:46 -05:00
Jay Berkenbilt
d866f48081
Change names of qpdf_object_type_e enumerations
...
They have to be ot_* rather than qpdf_ot_* for compatibility.
* Different enumerated types are not assignment-compatible in C++, at
least with strict compiler settings
* While you can do `constexpr ot_xyz = ::qpdf_ot_xyz` in QPDFObject.hh to
make QPDFObject::ot_xyz work, QPDFObject::object_type_e::ot_xyz will
only work if the enumerated type names are the same.
2021-12-20 14:51:45 -05:00
Jay Berkenbilt
ea73bf72e0
Further improvements to handling binary strings
2021-12-19 14:30:45 -05:00
Jay Berkenbilt
ddbe59179e
C API: simplify new error handling and improve documentation
2021-12-17 15:59:47 -05:00
m-holger
f6293bd94c
C-API expose QPDFObjectHandle::getTypeCode and getTypeName ( fixes #597 )
2021-12-17 14:24:43 -05:00
Jay Berkenbilt
feafcc4e88
C API: add several stream functions ( fixes #596 )
2021-12-17 13:28:11 -05:00
Jay Berkenbilt
fee7489ee4
Add Pl_Buffer::getMallocBuffer
2021-12-17 12:38:52 -05:00
Jay Berkenbilt
9bb6f570ec
C API: add functions for working with pages ( fixes #594 )
2021-12-16 15:07:48 -05:00
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
Jay Berkenbilt
8ed3e8c79b
NNTree: rework iterators to be more memory efficient
...
Keep a std::pair internal to the iterators so that operator* can
return a reference and operator-> can work, and each can work without
copying pairs of objects around.
2021-01-26 09:12:23 -05:00
Jay Berkenbilt
e7e20772ed
name/number trees: remove
2021-01-26 09:12:23 -05:00
Jay Berkenbilt
5816fb44b8
name/number trees: insertAfter
2021-01-25 15:39:10 -05:00
Jay Berkenbilt
16a9bb3f6f
name/number trees: newEmpty, increment/decrement end()
2021-01-25 15:39:10 -05:00
Jay Berkenbilt
b5614f611d
Implement repair and insert for name/number trees
2021-01-24 19:31:45 -05:00
Jay Berkenbilt
04edfe9fad
QPDFObjectHandle::newUnicodeString to uses UTF-16 only when needed
...
Use the first of ASCII, PDFDocEncoding, or UTF-16 that is capable of
encoding the string.
2021-01-24 03:27:28 -05:00
Jay Berkenbilt
63e5cb533d
Use new QPDF{Name,Number}TreeObjectHelper API
2021-01-24 03:27:28 -05:00
Jay Berkenbilt
d61ffb65d0
Add new constructors for name/number tree helpers
...
Add constructors that take a QPDF object so we can issue warnings and
create new indirect objects.
2021-01-24 03:27:26 -05:00
Jay Berkenbilt
ba814703fb
Use QPDFNameTreeObjectHelper's iterator directly
2021-01-24 03:25:11 -05:00
Jay Berkenbilt
5f0708418a
Add iterators to name/number tree helpers
2021-01-24 03:22:59 -05:00
Jay Berkenbilt
4a1cce0a47
Reimplement name and number tree object helpers
...
Create a computationally and memory efficient implementation of name
and number trees that does binary searches as intended by the data
structure rather than loading into a map, which can use a great deal
of memory and can be very slow.
2021-01-24 03:22:51 -05:00
Jay Berkenbilt
6226b69dba
Add warn() to QPDF's public API
2021-01-16 18:41:53 -05:00
Jay Berkenbilt
fc88837d4b
Treat /EmbeddedFiles as a proper name tree
...
If we ever had an encrypted file with different filters for
attachments and either the /EmbeddedFiles name tree was deep or some
of the file specs didn't have /Type, we would have overlooked those as
attachment streams. The code now properly handles /EmbeddedFiles as a
name tree.
2021-01-11 10:50:44 -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
0fed040392
Prepare version 10.1.0
2021-01-04 16:59:55 -05:00
Jay Berkenbilt
18340b8835
Spell check
2021-01-04 16:26:58 -05:00
Jay Berkenbilt
dc92574c10
Fix some pipelines to be safe if downstream write fails (fuzz issue 28262)
2021-01-04 15:17:35 -05:00
Jay Berkenbilt
ba6b6aacf1
Fix outdated comment
2021-01-03 15:59:49 -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
bedf35d6a5
Bug fix: avoid extraneous pipeline finish calls with multiple contents
...
Avoid calling finish() multiple times on the pipeline passed to
pipeContentStreams. This commit also fixes a bug in which qpdf was not
exiting with the proper exit status if warnings found while splitting
pages; this was exposed by a test case that changed.
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
6154221edb
QPDFPageObjectHelper: filterPageContents -> filterContents + form XObject
2021-01-02 11:33:36 -05:00
Jay Berkenbilt
63ea46193d
QPDFPageObjectHelper: getPageImages -> getImages
2021-01-02 11:33:36 -05:00
Jay Berkenbilt
e7a8554563
QPDFPageObjectHelper::getPageImages: support form XObjects
2021-01-02 11:33:36 -05:00
Jay Berkenbilt
1562d34c09
Add QPDFObjectHandle::isFormXObject
2021-01-01 07:36:10 -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
3f9191a344
Add ostream << for QPDFObjGen
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
1a62cce940
Restructure optimize to allow skipping parameters of filtered streams
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
09027344b9
Refactor: separate code that determines whether to filter a stream
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
39bfa01307
Implement user-provided stream filters
...
Refactor QPDF_Stream to use stream filter classes to handle supported
stream filters as well.
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
573b6eb8b1
Provide qpdf write progress reporting from C API ( fixes #487 )
2020-12-20 14:43:24 -05:00
Jay Berkenbilt
2050977099
Add QPDFObjectHandle manipulation to C API
2020-11-28 19:48:07 -05:00
Jay Berkenbilt
78b9d6bfd4
Prepare 10.0.4 release
2020-11-21 13:50:02 -05:00
Jay Berkenbilt
bd79138c84
Treat direct page as runtime rather than logic error (fuzz issue 27393)
2020-11-11 09:50:43 -05:00
Jay Berkenbilt
47f4ebcdac
Ignore unused field in xref entry, avoiding range error ( fixes #482 )
2020-11-04 07:46:46 -05:00
Jay Berkenbilt
fbe40b800d
Prepare 10.0.3 release
2020-10-31 13:47:03 -04:00
Jay Berkenbilt
6971f78ff6
Fix stack overflow on direct root (fuzz issue 26761)
2020-10-31 13:10:39 -04:00
Jay Berkenbilt
ffe6af6f77
Add comments explaining the foreign object copying code
...
These are the comments I would have liked to have been able to read
while fixing #449 and #478 .
2020-10-31 12:14:26 -04:00
Jay Berkenbilt
96767fb104
Fix foreign stream copying bug ( fixes #478 )
...
This reverts an incorrect fix to #449 and codes it properly. The real
problem was that we were looking at the local dictionaries rather than
the foreign dictionaries when saving the foreign stream data. In the
case of direct objects, these happened to be the same, but in the case
of indirect objects, the object references could be pointing anywhere
since object numbers don't match up between the old and new files.
2020-10-31 12:14:26 -04:00
Jay Berkenbilt
da7540794a
Prepare 10.0.2 release
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
09bd1fafb1
Improve efficiency of number to string conversion
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
bcea54fcaa
Revert removal of unreadCh change for performance
...
Turns out unreadCh is much more efficient than seek(-1, SEEK_CUR).
Update comments and code to reflect this.
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
b30deaeeab
Avoid merging adjacent tokens when concatenating contents ( fixes #444 )
2020-10-23 08:00:04 -04:00
Jay Berkenbilt
8a11feacc3
Avoid leak by resolving object streams more than once (fuzz issue 23642)
2020-10-22 15:39:36 -04:00
Jay Berkenbilt
30bb4c64ee
Minor code cleanup
...
* Return rather than exiting from realmain in qpdf.cc
* Remove extraneous blank line
* Don't assign temporary to const reference
2020-10-22 15:39:36 -04:00
Jay Berkenbilt
232f5fc9f3
Handle jpeg library fuzz false positives
...
The jpeg library has some assembly code that is missed by the compiler
instrumentation used by memory sanitization. There is a runtime
environment variable that is used to work around this issue.
2020-10-22 06:31:52 -04:00
Jay Berkenbilt
c1684eae91
Check for overflow in page labels (fuzz issue 23599)
2020-10-22 05:49:24 -04:00
Jay Berkenbilt
7f4a4df919
Add range_check method to QIntC
2020-10-22 05:48:40 -04:00
Jay Berkenbilt
24196c08cb
Fix loop detection error (fuzz issue 23172)
2020-10-22 05:48:35 -04:00