Jay Berkenbilt
bef2c2222a
C API: qpdf_get_last_string_length
2021-12-09 10:33:31 -05:00
Jay Berkenbilt
73d70902e0
Typos in comments
2021-12-09 10:33:31 -05:00
m-holger
0c705a882b
Minor documentation updates
2021-12-09 10:24:14 -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
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
750aca5b94
First increment of improving handling of weak crypto ( fixes #358 )
2021-11-11 12:24:15 -05:00
Jay Berkenbilt
ec09b91443
Add QIntC::range_check_subtract
2021-11-04 13:53:46 -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
Jay Berkenbilt
8971443e46
QPDF::addPage*: handle duplicate pages more robustly
2021-04-05 10:58:10 -04: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
9fb174b9e9
Major rework of handling form fields when copying pages ( fixes #509 )
2021-03-04 15:08:37 -05:00
Jay Berkenbilt
a2124f992c
Add QPDFMatrix::operator==
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
c9c711a351
Add string to deprecation warning
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
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
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
1886673d7e
Spell check
2021-02-23 10:38:05 -05:00
Jay Berkenbilt
be3a8c0e7a
Keep only referenced form fields in --pages
2021-02-23 08:26:21 -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
aa848126cb
Comment about QPDFMatrix and QPDFObjectHandle::Matrix
2021-02-21 08:06:19 -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
901f1a788c
Enhance QPDFMatrix API
2021-02-21 06:36:30 -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
8873466a5d
Remove outdated comment from QPDFAnnotationObjectHelper.hh
2021-02-17 20:14:20 -05:00
Jay Berkenbilt
a773f4c71d
Add QPDFObjectHandle::parse for strings with context
2021-02-15 11:33:03 -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
2538d84413
Explicitly deprecate old name/number tree constructors
...
Use C++14 [[deprecated]] tag
2021-02-10 16:28:00 -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
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
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
4ae93a73c5
Improve memory safety of dict/array iterators
2021-01-31 07:16:03 -05:00
Jay Berkenbilt
1fec40454e
Add example of name/number trees and dictionary/array iteration
2021-01-30 15:52:16 -05:00
Jay Berkenbilt
de0b11fc47
Add C++ iterator API around array and dictionary objects
2021-01-30 15:15:23 -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
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
9ad6cfd45b
Clarify qpdf_register_progress_reporter's comment
2021-01-19 08:55:23 -05:00
Jay Berkenbilt
6226b69dba
Add warn() to QPDF's public API
2021-01-16 18:41:53 -05:00
Jay Berkenbilt
18340b8835
Spell check
2021-01-04 16:26:58 -05:00
Jay Berkenbilt
bf8fd41fee
Update copyright to 2021
2021-01-04 16:26:58 -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
afb48d23a9
QPDFPageObjectHelper::removeUnreferencedResources works with form XObjects
2021-01-02 11:33:36 -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
4cbf32bfdb
Fix typo in comment
2020-12-30 13:20:42 -05:00
Jay Berkenbilt
c9271335fa
Add QPDFPageObjectHelper::flattenRotation and --flatten-rotation
2020-12-30 13:03:55 -05:00
Jay Berkenbilt
d4d7630cf5
Add pdf-custom-filter example
2020-12-28 13:03:04 -05:00
Jay Berkenbilt
ac042d16cf
Add Pipeline::getNext() to DLL
2020-12-28 13:03:04 -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
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
1fb26f08ad
Fix typo in comment and whitespace issue
2020-12-28 12:57:59 -05:00
Jay Berkenbilt
0675a3f61a
Decide not to allow stream data providers to modify dictionary
2020-12-26 08:48:20 -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
9d64481571
Handle negative numbers in QIntC::range_check (fuzz issue 26994)
2020-11-21 13:43:04 -05: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
fd13fe74ef
TODO and comments item for pipeContentStreams
2020-10-23 16:53:58 -04:00
Jay Berkenbilt
802de87c30
Fix outdated comment in QPDFTokenizer.hh
2020-10-23 06:39:42 -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
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
Jay Berkenbilt
98f6c00dad
Protect numeric conversion against user's locale ( fixes #459 )
2020-10-21 16:42:51 -04:00
Jay Berkenbilt
bed165c9fc
Stop using InputSource::unreadCh
2020-10-18 07:43:05 -04:00
Jay Berkenbilt
18b34a5649
InputSource::unreadCh -- only unread most recently read character
...
This is all that ever worked. The test suite was trying to do
something different from ClosedFileInputSource.
2020-10-16 17:15:39 -04:00
Jay Berkenbilt
496aacd34a
Add missing QPDF_DLL_CLASS for QPDFObject ( fixes #424 )
...
This is needed for some compilers on some platforms, notably current
versions of clang.
2020-04-07 10:35:03 -04:00
Jay Berkenbilt
77198d5310
Delegate random number generation to crypto provider ( fixes #418 )
2020-04-06 11:23:02 -04:00
Jay Berkenbilt
619d294e9d
Remove QUtil::srandom
2020-04-06 09:49:02 -04:00
Jay Berkenbilt
893d38b87e
Allow propagation of errors and retry through StreamDataProvider
...
StreamDataProvider::provideStreamData now has a rich enough API for it
to effectively proxy to pipeStreamData.
2020-04-05 20:07:13 -04:00
Jay Berkenbilt
2100b4ce15
Allow qpdf to be built on systems without wchar_t ( fixes #406 )
2020-04-03 21:39:44 -04:00
Jay Berkenbilt
4f3b89991b
placeFormXObject: allow control of shrink/expand ( fixes #409 )
2020-04-03 21:39:17 -04:00
Jay Berkenbilt
54726930df
Remove redundant methods in QUtil
...
This was being saved until we had to break ABI.
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
8a87a2fbee
Use C++11 features to simplify QIntC
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
a6f1f829db
Use deleted copy/assignment (C++11)
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
5806e5c60c
QPDFPageObjectHelper::placeFormXObject: use std::string const& ( fixes #374 )
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
97de12343b
Performance: remove Members indirection for Pipeline
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
e9eac2a245
Remove extraneous set of braces
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
38afdcea7b
Add QPDFObjectHandle::unsafeShallowCopy
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
07afb668b1
Performance: remove indirection through Members for QPDFObject
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
89f19b7099
Performance: remove Members indirection for QPDFObjectHandle
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
278710fbe8
Refactor QPDFPageObjectHelper::removeUnreferencedResources()
...
Refactor removeUnreferencedResources to prepare for filtering form
XObjects.
2020-03-31 17:39:20 -04:00
Jay Berkenbilt
e5cc065598
Update copyright to 2020
2020-01-26 16:57:27 -05:00
Jay Berkenbilt
a44b5a34a0
Pull wmain -> main code from qpdf.cc into QUtil.cc
2020-01-14 11:40:51 -05:00
Jay Berkenbilt
9a398504ca
Refactor QUtil::read_lines_from_file
...
This commit adds the preserve_eol flags but doesn't implement EOL
preservation yet.
2020-01-13 09:19:53 -05:00
Jay Berkenbilt
127a957aee
Allow runtime inspection/override of crypto provider
2019-11-09 09:53:42 -05:00
Jay Berkenbilt
d1ffe46c04
AES_PDF: move CBC logic from pipeline to AES_PDF implementation
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
c8cda4f965
AES_PDF: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
bb427bd117
SHA2: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
4287fcc002
RC4: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
ce8f9b6608
MD5: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
2de41856a0
QPDFCryptoProvider: initial implementation
2019-11-09 08:18:02 -05:00
Masamichi Hosoda
5a842792b6
Parse Contents in signature dictionary without encryption
...
Various PDF digital signing tools do not encrypt /Contents value in
signature dictionary. Adobe Acrobat Reader DC can handle a PDF with
the /Contents value not encrypted.
Write Contents in signature dictionary without encryption
Tests ensure that string /Contents are not handled specially when not
found in sig dicts.
2019-10-22 16:20:21 -04:00
Masamichi Hosoda
cdc46d78f4
Add QPDFObject::getParsedOffset()
2019-10-22 16:19:06 -04:00
Masamichi Hosoda
50b329ee9f
Add QPDFWriter::getWrittenXRefTable()
2019-10-22 16:16:16 -04:00
Masamichi Hosoda
5cf4090aee
Add QPDFWriter::getRenumberedObjGen()
2019-10-22 16:16:16 -04:00
Masamichi Hosoda
46ac3e21b3
Add QPDF::getXRefTable()
2019-10-22 16:16:16 -04:00
Masamichi Hosoda
5e0ba12687
Fix /Contents value representation in a signature dictionary
...
Table 8.93 "Entries in a signature dictionary" in PDF 1.5 reference
describes that the value of Contents entry is a hexadecimal string
representation when ByteRange is specified.
This commit makes QPDF always uses hexadecimal strings representation
instead of literal strings for it.
2019-10-22 16:16:16 -04:00
Jay Berkenbilt
6d81f01476
Don't assume char is signed in int conversion tests ( fixes #361 )
2019-09-17 12:18:09 -04:00
Jay Berkenbilt
babd12c9b2
Add methods QPDF::anyWarnings and QPDF::closeInputSource
2019-08-31 15:51:20 -04:00
Jay Berkenbilt
4fa7b1eb60
Add remove_file and rename_file to QUtil
2019-08-31 15:51:04 -04:00
Jay Berkenbilt
0787ec9620
spell check
2019-08-31 08:43:18 -04:00
Jay Berkenbilt
ba5fb69164
Make popping pipeline stack safer
...
Use destructors to pop the pipeline stack, and ensure that code that
pops the stack is actually popping the intended thing.
2019-08-27 22:27:47 -04:00
Jay Berkenbilt
ad8081daf5
Fix fuzz issue 15442 (overflow checking in BufferInputSource)
2019-08-27 11:26:25 -04:00
Jay Berkenbilt
5da146c8b5
Track separately whether password was user/owner ( fixes #159 )
2019-08-24 11:01:19 -04:00
Jay Berkenbilt
2794bfb1a6
Add flags to control zlib compression level ( fixes #113 )
2019-08-23 20:34:21 -04:00
Jay Berkenbilt
dac0598b94
Add ability to set zlib compression level globally
2019-08-23 20:34:21 -04:00
Jay Berkenbilt
3f1ab64066
Pass offset and length to ParserCallbacks::handleObject
2019-08-22 22:54:29 -04:00
Jay Berkenbilt
4b2e72c4cd
Test for direct, rather than resolved nulls in parser
...
Just because we know an indirect reference is null, doesn't mean we
shouldn't keep it indirect.
2019-08-22 17:55:16 -04:00
Jay Berkenbilt
4b674b42e4
Mention name tokens in TokenFilter comments
2019-08-22 17:55:16 -04:00
Jay Berkenbilt
225cd9dac2
Protect against coding error of re-entrant parsing
2019-08-22 17:55:16 -04:00
Jay Berkenbilt
42d396f1dd
Handle invalid name tokens symmetrically for PDF < 1.2 ( fixes #332 )
2019-08-19 19:48:27 -04:00
Jay Berkenbilt
e5f504b6c5
Use SparseOHArray in QPDF_Array
2019-08-17 23:02:41 -04:00
Jay Berkenbilt
e83f3308fb
SparseOHArray
2019-08-17 23:02:41 -04:00
Jay Berkenbilt
88c1956705
Update comment in PointerHolder
2019-07-13 21:34:46 -04:00
Thorsten Schöning
8f06da7534
Change list to vector for outline helpers ( fixes #297 )
...
This change works around STL problems with Embarcadero C++ Builder
version 10.2, but std::vector is more common than std::list in qpdf,
and this is a relatively new API, so an API change is tolerable.
Thanks to Thorsten Schöning <6223655+ams-tschoening@users.noreply.github.com>
for the fix.
2019-07-03 20:08:47 -04:00
Jay Berkenbilt
04f45cf652
Treat all linearization errors as warnings
...
This also reverts the addition of a new checkLinearization that
distinguishes errors from warnings. There's no practical distinction
between what was considered an error and what was considered a
warning.
2019-06-23 13:45:45 -04:00
Jay Berkenbilt
6c39aa8763
In shippable code, favor smart pointers ( fixes #235 )
...
Use PointerHolder in several places where manually memory allocation
and deallocation were being used. This helps to protect against memory
leaks when exceptions are thrown in surprising places.
2019-06-22 16:57:52 -04:00
Jay Berkenbilt
85a3f95a89
qpdf: exit 3 for linearization warnings without errors ( fixes #50 )
2019-06-22 16:57:51 -04:00
Jay Berkenbilt
1bde5c68a3
Add QUtil::read_file_into_memory
...
This code was essentially duplicated between test_driver and
standalone_fuzz_target_runner.
2019-06-22 10:14:25 -04:00
Jay Berkenbilt
658b5bb3be
QPDFWriter: clean up overloaded functions
...
In a small number of cases, it makes sense to replace an overloaded
function with a function that takes a default argument. We can do this
now because we've already broken binary compatibility since the last
release.
2019-06-22 10:13:27 -04:00
Jay Berkenbilt
79f6b4823b
Convert remaining public classes to use Members pattern
...
Have classes contain only a single private member of type
PointerHolder<Members>. This makes it safe to change the structure of
the Members class without breaking binary compatibility. Many of the
classes already follow this pattern quite successfully. This brings in
the rest of the class that are part of the public API.
2019-06-22 10:13:27 -04:00
Jay Berkenbilt
864a546af6
Build with -fvisibility=hidden when supported
2019-06-21 22:29:31 -04:00
Jay Berkenbilt
45dac410b5
Remove broken QPDFTokenizer::expectInlineImage
2019-06-21 22:29:31 -04:00
Jay Berkenbilt
25dd3c6750
Remove QPDF::copyForeignObject with unused parameter
2019-06-21 22:29:31 -04:00
Jay Berkenbilt
c6cfd64503
Rename QUtil::strcasecmp to QUtil::str_compare_nocase ( fixes #242 )
2019-06-21 22:29:31 -04:00
Jay Berkenbilt
d71f05ca07
Fix sign and conversion warnings (major)
...
This makes all integer type conversions that have potential data loss
explicit with calls that do range checks and raise an exception. After
this commit, qpdf builds with no warnings when -Wsign-conversion
-Wconversion is used with gcc or clang or when -W3 -Wd4800 is used
with MSVC. This significantly reduces the likelihood of potential
crashes from bogus integer values.
There are some parts of the code that take int when they should take
size_t or an offset. Such places would make qpdf not support files
with more than 2^31 of something that usually wouldn't be so large. In
the event that such a file shows up and is valid, at least qpdf would
raise an error in the right spot so the issue could be legitimately
addressed rather than failing in some weird way because of a silent
overflow condition.
2019-06-21 13:17:21 -04:00
Jay Berkenbilt
f40ffc9d63
Pl_Flate: constructor's out_bufsize is now unsigned int
...
This is the type we need for the underlying zlib implementation.
2019-06-21 13:17:21 -04:00
Jay Berkenbilt
da30764bce
Change QPDFObjectHandle::pipeStreamData's encode_flags type
...
Change from unsigned long to int since we pass enumerated type values
to this field.
2019-06-21 13:17:21 -04:00
Jay Berkenbilt
3608afd5c5
Add new integer accessors to QPDFObjectHandle
2019-06-21 13:17:21 -04:00
Jay Berkenbilt
42306e2ff8
QUtil: add unsigned int/string functions
2019-06-21 13:17:21 -04:00
Jay Berkenbilt
a66828caff
New safe type converters in QIntC
2019-06-21 13:17:21 -04:00
Marco Scarpetta
b405e5e1c9
Fix typo ( #334 )
2019-06-12 14:21:33 -04:00
jbarlow83
2efec4ce7b
Fix C++ exception handling when -fvisibility=hidden ( #302 )
...
Fix C++ exception handling when -fvisibility=hidden
Ensure that QPDFExc and QPDFSystemError are marked visible, so that their typeinfo will not be
suppressed when -fvisibility=hidden.
Details:
https://gcc.gnu.org/wiki/Visibility
2019-03-11 18:28:29 -04:00
Thorsten Schöning
2a852f08b6
[bcc32 Error] QPDF.hh(803): E2247 'QPDF::Members::resolving' is not accessible
...
Full parser context
QPDF.cc(2): #include ..\..\..\..\src\include\qpdf\QPDF.hh
QPDF.hh(48): class QPDF
QPDF.hh(1380): decision to instantiate: QPDF::ResolveRecorder::ResolveRecorder(QPDF *,const QPDFObjGen &)
--- Resetting parser context for instantiation...
QPDF.hh(799): parsing: QPDF::ResolveRecorder::ResolveRecorder(QPDF *,const QPDFObjGen &)
2019-03-11 17:07:01 -04:00
Thorsten Schöning
1449d82ae4
[bcc32 Error] QPDFObjectHandle.hh(911): E2247 'QPDFObjectHandle::Members::obj' is not accessible
...
Full parser context
Pl_QPDFTokenizer.cc(1): #include ..\..\..\..\src\include\qpdf\Pl_QPDFTokenizer.hh
Pl_QPDFTokenizer.hh(29): #include ..\..\..\..\src\include\qpdf/QPDFObjectHandle.hh
QPDFObjectHandle.hh(51): class QPDFObjectHandle
QPDFObjectHandle.hh(1052): decision to instantiate: PointerHolder<QPDFObject> QPDFObjectHandle::ObjAccessor::getObject(QPDFObjectHandle &)
--- Resetting parser context for instantiation...
QPDFObjectHandle.hh(909): parsing: PointerHolder<QPDFObject> QPDFObjectHandle::ObjAccessor::getObject(QPDFObjectHandle &)
2019-03-11 17:07:01 -04:00
Thorsten Schöning
86287acfd9
[bcc32 Error] QPDF.hh(223): E2303 Type name expected
...
Full parser context
QPDF.cc(2): #include ..\..\..\..\src\include\qpdf\QPDF.hh
QPDF.hh(47): class QPDF
2019-03-11 16:57:16 -04:00
Thorsten Schöning
9b3314042a
[bcc32 Error] QPDF.hh(203): E2316 'vector' is not a member of 'std'
...
Full parser context
QPDF.cc(2): #include ..\..\..\..\src\include\qpdf\QPDF.hh
QPDF.hh(46): class QPDF
2019-03-11 16:57:16 -04:00
Jay Berkenbilt
fec5bb124c
Spell check
2019-01-31 21:41:29 -05:00
Jay Berkenbilt
eb49e07c0a
Make inline image token exactly contain the image data
...
Do not include the trailing EI, and handle cases where EI is not
preceded by a delimiter. Such cases have been seen in the wild.
2019-01-31 20:28:44 -05:00
Jay Berkenbilt
5211bcb5ea
Externalize inline images ( fixes #278 )
2019-01-31 10:38:13 -05:00
Jay Berkenbilt
1eb35a355f
Exclude space after ID in image data
2019-01-31 10:38:10 -05:00
Jay Berkenbilt
2b6c79bcae
Improve locating inline image's EI
...
We've actually seen a PDF file in the wild that contained EI
surrounded by delimiters inside the image data, which confused qpdf's
naive code. This significantly improves EI detection.
2019-01-31 09:26:37 -05:00
Jay Berkenbilt
ec9e310c9e
Refactor QPDFTokenizer's inline image handling
...
Add a version of expectInlineImage that takes an input source and
searches for EI. This is in preparation for improving the way EI is
found. This commit just refactors the code without changing the
functionality and adds tests to make sure the old and new code behave
identically.
2019-01-31 09:26:37 -05:00
Jay Berkenbilt
b776dcd2d3
Clean up some private functions
2019-01-29 22:14:20 -05:00
Jay Berkenbilt
2d0885bc11
Clarify documentation for copyForeignObject regarding pages
...
Make explicit that copyForeignObject can be used on page objects and
will copy them properly but not update the pages tree.
2019-01-28 21:53:55 -05:00
Jay Berkenbilt
52f9d326a5
Resolve duplicated page objects ( fixes #268 )
...
When linearizing a file or getting the list of all pages in a file,
detect if the pages tree contains a duplicated page object and, if so,
shallow copy it. This makes it possible to have a one to one mapping
of page positions to page objects.
2019-01-28 20:29:58 -05:00
Jay Berkenbilt
623f5b664e
Convert pages to form XObjects
...
Support conversion of pages to form XObjects and placement of form
XObjects on pages.
2019-01-27 07:50:30 -05:00
Jay Berkenbilt
8cb245739c
Add QPDFObjectHandle::getUniqueResourceName
2019-01-27 07:50:30 -05:00
Jay Berkenbilt
009767d97a
Handle inheritable page attributes
...
Add getAttribute for handling inheritable page attributes, and fix
getPageImages and annotation flattening code to use it.
2019-01-25 22:30:05 -05:00
Jay Berkenbilt
e1271361c5
Add documentation for features since 8.3.0
2019-01-19 15:58:51 -05:00
Jay Berkenbilt
c18ee440a3
mingw workaround for QPDFExc destructor
...
mingw doesn't like it when you don't inline empty virtual destructors.
2019-01-19 10:14:07 -05:00
Jay Berkenbilt
e87d149918
Add QUtil::possible_repaired_encodings
2019-01-17 11:43:56 -05:00
Jay Berkenbilt
6ec22f117d
Modernize encryption API for more granularity
...
Setting encryption permissions for R >= 3 set permission bits in
groups corresponding to menu options in Acrobat 5. The new API allows
the bits to be set individually.
2019-01-17 11:43:56 -05:00
Jay Berkenbilt
4630377731
Add status-reporting transcoders to QUtil
2019-01-17 11:43:56 -05:00
Jay Berkenbilt
8f389f14c0
QUtil::analyze_encoding
2019-01-17 11:43:56 -05:00
Jay Berkenbilt
698485468a
Move remaining existing transcoding to QUtil
2019-01-17 11:43:56 -05:00
Jay Berkenbilt
654c0e8caf
Allow adding the same page more than once in --pages ( fixes #272 )
2019-01-12 10:01:47 -05:00
Jay Berkenbilt
5f128b9a27
Fix version number in comment
2019-01-11 07:46:53 -05:00
Jay Berkenbilt
d24a120c7f
Add QPDF::setImmediateCopyFrom
2019-01-10 22:35:08 -05:00
Jay Berkenbilt
3472f6c984
Update copyrights for 2019
2019-01-07 07:54:55 -05:00
Jay Berkenbilt
fddbcab0e7
Mostly don't require original QPDF for copyForeignObject ( fixes #219 )
...
The original QPDF is only required now when the source
QPDFObjectHandle is a stream that gets its stream data from a
QPDFObjectHandle::StreamDataProvider.
2019-01-07 00:11:15 -05:00
Jay Berkenbilt
fbbb0ee016
Make a static version of QPDF::pipeStreamData
...
This is in preparation of being able to pipe a stream's data without
keeping a copy of its containing qpdf object.
2019-01-07 00:11:15 -05:00