2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-09-22 10:09:06 +00:00
Commit Graph

286 Commits

Author SHA1 Message Date
Jay Berkenbilt
a85007cb0d Handle more broken files
Space rather than newline after xref, missing /ID in trailer for
encrypted file.  This enables qpdf to handle some files that xpdf can
handle.  Adobe reader can't necessarily handle them.
2013-06-15 12:40:01 -04:00
Jay Berkenbilt
16051788ed Handle /Outlines dictionary being a direct object
Even though this case is not valid according to the spec, it has been
seen, and caused an internal error.
2013-06-14 21:36:04 -04:00
Jay Berkenbilt
a3576a7359 Bug fix: handle generation > 0 when generating object streams
Rework QPDFWriter to always track old object IDs and QPDFObjGen
instead of int, thus not discarding the generation number.  Switch to
QPDF::getCompressibleObjGen() to properly handle the case of an old
object eligible for compression that has a generation of other than
zero.
2013-06-14 14:58:09 -04:00
Jay Berkenbilt
119f2a4b68 Add method to terminate content stream parsing 2013-03-05 13:35:46 -05:00
Jay Berkenbilt
6c7bf114dc Bug fix: properly handle overridden compressed objects
When caching objects in an object stream, only cache objects that
still resolve to that stream.  See Changelog mod from this commit for
details.
2013-02-23 17:51:17 -05:00
Jay Berkenbilt
a5d8783f67 Improve qpdf --check
Fix exit status for case of errors without warnings, continue after
errors when possible, add test case for parsing a file with content
stream errors on some but not all pages.
2013-01-25 11:08:50 -05:00
Jay Berkenbilt
f81152311e Add QPDFObjectHandle::parseContentStream method
This method allows parsing of the PDF objects in a content stream or
array of content streams.
2013-01-20 15:35:39 -05:00
Jay Berkenbilt
f8306913ba Update "C" API with functions for new features 2012-12-31 10:32:32 -05:00
Jay Berkenbilt
9a23c3dcb6 Remove /Crypt from stream filters unconditionally
When writing a new stream, always remove /Crypt even if we are not
otherwise able to filter the stream.
2012-12-31 10:32:32 -05:00
Jay Berkenbilt
4237a29c94 Refactor Dictionary writing code
Original code was written before we could shallow copy objects, so all
the filtering was done by suppressing the output of certain keys and
replacing them with other keys.  Now we can simplify the code greatly
by modifying shallow copies of dictionaries in place.
2012-12-31 10:32:32 -05:00
Jay Berkenbilt
e57c25814e Support for encryption with /V=5 and /R=5 and /R=6
Read and write support is implemented for /V=5 with /R=5 as well as
/R=6.  /R=5 is the deprecated encryption method used by Acrobat IX.
/R=6 is the encryption method used by PDF 2.0 from ISO 32000-2.
2012-12-31 10:32:32 -05:00
Jay Berkenbilt
4fe6f61def Add missing test case from long ago
I noticed a test output file that was not accessed in the test suite
and added a test case for it.
2012-12-31 10:32:32 -05:00
Jay Berkenbilt
774584163f Add ExtensionLevel support to version handling
All version operations are now fully aware of extension levels.
2012-12-31 05:36:50 -05:00
Jay Berkenbilt
35873031a7 Uncompress stream data for some linearization tests
For linearization tests where we are actually comparing the exact
output of the test with a known file, uncompress stream data so we can
see what's there.  This makes looking at future changes a little
easier.
2012-12-27 11:26:06 -05:00
Jay Berkenbilt
7f84239cad Find PDF header anywhere in the first 1024 bytes 2012-12-25 14:43:37 -05:00
Jay Berkenbilt
f256670eba Ignore objects with offset 0 2012-11-20 13:57:37 -05:00
Jay Berkenbilt
041397fdab Allow reading from InputSource and writing to Pipeline
Allowing users to subclass InputSource and Pipeline to read and write
from/to arbitrary sources provides the maximum flexibility for users
who want to read and write from other than files or memory.
2012-09-23 17:42:26 -04:00
Jay Berkenbilt
c1627d0438 Add QPDFWriter::setExtraHeaderText 2012-09-06 15:31:12 -04:00
Jay Berkenbilt
8d2b29ef98 Fix segmentation fault with use of QPDFWriter::setOutputMemory 2012-09-06 14:39:06 -04:00
Jay Berkenbilt
3c4110184c Add specially crafted test cases for EOF error
This replaces a PDF from the wild that I didn't want to include in the
test suite but used to verify the original fix.
2012-08-11 12:36:57 -04:00
Jay Berkenbilt
bde98044f4 Improve password handling
Use --encryption-file-password, if given, in addition to --password as
a source for passwords for files specified in --pages.
2012-07-29 13:22:37 -04:00
Jay Berkenbilt
5878d17f0d Add QPDF_ to some variables used by the test suite
LARGE_FILE_TEST_PATH -> QPDF_LARGE_FILE_TEST_PATH
SKIP_TEST_COMPARE_IMAGES -> QPDF_SKIP_TEST_COMPARE_IMAGES
2012-07-28 19:07:37 -04:00
Jay Berkenbilt
5a02471bb1 Command-line page merging and splitting
Implement --pages ... -- option for qpdf.  Update TODO with remaining
things to document.
2012-07-21 20:33:33 -04:00
Jay Berkenbilt
6bbea4baa0 Implement QPDFObjectHandle::parse
Move object parsing code from QPDF to QPDFObjectHandle and
parameterize the parts of it that are specific to a QPDF object.
Provide a version that can't handle indirect objects and that can be
called on an arbitrary string.

A side effect of this change is that the offset used when reporting
invalid stream length has changed, but since the new value seems like
a better value than the old one, the test suite has been updated
rather than making the code backward compatible.  This only effects
the offset reported for invalid streams that lack /Length or have an
invalid /Length key.

Updated some test code and exmaples to use QPDFObjectHandle::parse.

Supporting changes include adding a BufferInputSource constructor that
takes a string.
2012-07-21 09:06:10 -04:00
Jay Berkenbilt
a101533e0a Add command line option to copy encryption from other file
Add --copy-encryption and --encryption-file-password options to qpdf.
Also strengthen test suite for copying encryption.  The strengthened
test suite would have caught the failure to preserve AES and the
failure to update the file version, which was invalidating the
encrypted data.
2012-07-15 21:15:24 -04:00
Jay Berkenbilt
0575d77d77 Add public QPDFWriter::copyEncryptionParameters
Method to copy encryption parameters from another file.  Adapted from
existing code to copy encryption parameters from the original file.
2012-07-14 09:14:41 -04:00
Jay Berkenbilt
ee3682f106 test_driver: accept optional second file name
This way we don't have to hard-code the name of a second file in the
test driver for tests that require one.
2012-07-14 08:48:30 -04:00
Jay Berkenbilt
1c944e4c89 Have QPDFWriter detect foreign objects while writing
Throw an exception that directs the user to QPDF::copyForeignObject.
2012-07-14 08:07:23 -04:00
Jay Berkenbilt
e7b8f297ba Support copying objects from another QPDF object
This includes QPDF::copyForeignObject and supporting foreign objects
as arguments to addPage*.
2012-07-11 15:54:33 -04:00
Jay Berkenbilt
8a217eb3a2 Add concept of reserved objects
QPDFObjectHandle::{new,is,assert}Reserved, QPDF::replaceReserved
provide a mechanism to add objects to a PDF file when there are
circular references.  This is a prerequisite to copying objects from
one PDF to another.
2012-07-10 23:34:32 -04:00
Jay Berkenbilt
c227249ef1 Added test code for Tobias's changes 2012-07-04 23:19:32 -04:00
Jay Berkenbilt
8318d81ada Fix and test support for files >= 4 GB 2012-06-24 15:56:50 -04:00
Jay Berkenbilt
2a057ac0d4 Add test case for removing a page we don't have 2012-06-23 18:32:14 -04:00
Jay Berkenbilt
a0768e4190 Add QPDF::emptyPDF() and pdf_from_scratch test code 2012-06-21 23:09:05 -04:00
Jay Berkenbilt
d1ebe30ff6 Add QPDFObjectHandle::shallowCopy() 2012-06-21 16:15:09 -04:00
Jay Berkenbilt
1b364ad7b8 Add additional page API test cases 2012-06-21 15:27:32 -04:00
Jay Berkenbilt
3844aedd93 Add testing for page APIs 2012-06-21 15:01:02 -04:00
Jay Berkenbilt
5963267b5f Discard stderr from gs when comparing images.
This works around cases where gs falsely complains about things in the
PDF files or gives warnings that don't harm the output.  See comments
in qpdf.test for details.
2011-12-28 14:02:07 -05:00
Jay Berkenbilt
14fe2e6de3 qpdf_set_info_key, qpdf_get_info_key 2011-08-11 10:48:37 -04:00
Jay Berkenbilt
a42a4068b5 preserve /EncryptMetadata when copying encryption parameters 2011-08-10 19:47:18 -04:00
Jay Berkenbilt
7dc197ef88 implement replace and swap 2011-08-10 12:42:48 -04:00
Jay Berkenbilt
aeb892f99b accept stream keyword with CR only
git-svn-id: svn+q:///qpdf/trunk@1052 71b93d88-0707-0410-a8cf-f5a4172ac649
2011-04-30 21:46:09 +00:00
Jay Berkenbilt
6405d3928f be less conservative when skipping over inline images in content normalization
git-svn-id: svn+q:///qpdf/trunk@1050 71b93d88-0707-0410-a8cf-f5a4172ac649
2011-04-30 18:20:35 +00:00
Jay Berkenbilt
a8f2248729 handle files with object 0 as a real object
git-svn-id: svn+q:///qpdf/trunk@1049 71b93d88-0707-0410-a8cf-f5a4172ac649
2011-01-31 14:59:42 +00:00
Jay Berkenbilt
a72ce95c92 setOutputStreams
git-svn-id: svn+q:///qpdf/trunk@1035 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-10-01 11:02:35 +00:00
Jay Berkenbilt
047bcfcaa6 treat empty objects as null
git-svn-id: svn+q:///qpdf/trunk@1027 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-09-06 02:17:55 +00:00
Jay Berkenbilt
b1e0dcff16 handle stream filter abbreviations from table H.1
git-svn-id: svn+q:///qpdf/trunk@1025 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-09-05 15:00:44 +00:00
Jay Berkenbilt
bd7261da9b getRawStreamData()
git-svn-id: svn+q:///qpdf/trunk@1010 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-09 23:33:40 +00:00
Jay Berkenbilt
2dbc1006fb addPageContents
git-svn-id: svn+q:///qpdf/trunk@995 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-05 21:06:49 +00:00
Jay Berkenbilt
a39e29fb96 fix some file names
git-svn-id: svn+q:///qpdf/trunk@992 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-05 20:23:54 +00:00
Jay Berkenbilt
6f2bd7eb3a newStream
git-svn-id: svn+q:///qpdf/trunk@991 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-05 20:20:52 +00:00
Jay Berkenbilt
11df7809af add pipeline-based stream data replacement function
git-svn-id: svn+q:///qpdf/trunk@990 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-05 19:04:22 +00:00
Jay Berkenbilt
98765c3b5c tested basic stream replacement
git-svn-id: svn+q:///qpdf/trunk@989 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-08-03 02:29:15 +00:00
Jay Berkenbilt
64dc738859 restore missing coverage case
git-svn-id: svn+q:///qpdf/trunk@975 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-06-06 13:28:32 +00:00
Jay Berkenbilt
fc8f93053d don't place restrictions on length of /ID strings
git-svn-id: svn+q:///qpdf/trunk@961 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-04-25 14:55:36 +00:00
Jay Berkenbilt
218900d2c3 flatten scalar references for unreferenced objects
git-svn-id: svn+q:///qpdf/trunk@946 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-03-27 15:42:17 +00:00
Jay Berkenbilt
d01c1ba1c6 better acroread check
git-svn-id: svn+q:///qpdf/trunk@926 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-12-14 19:50:00 +00:00
Jay Berkenbilt
a80d9d176d add C interface for getting software version
git-svn-id: svn+q:///qpdf/trunk@903 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-24 13:23:20 +00:00
Jay Berkenbilt
ace2a031b5 prepare 2.1.rc1 for release
git-svn-id: svn+q:///qpdf/trunk@901 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-24 04:47:17 +00:00
Jay Berkenbilt
f231a37cd6 typo
git-svn-id: svn+q:///qpdf/trunk@834 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-20 01:04:36 +00:00
Jay Berkenbilt
a27b466598 typo
git-svn-id: svn+q:///qpdf/trunk@833 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-20 01:04:01 +00:00
Jay Berkenbilt
ad0ab25d66 fix bug in C API, test invalid password specifically
git-svn-id: svn+q:///qpdf/trunk@832 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-20 00:59:38 +00:00
Jay Berkenbilt
3f8c4c2736 categorize all error messages and include object information if available
git-svn-id: svn+q:///qpdf/trunk@829 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-19 23:09:19 +00:00
Jay Berkenbilt
734ac1e1d2 deal with stream-specific crypt filters
git-svn-id: svn+q:///qpdf/trunk@827 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-19 01:58:31 +00:00
Jay Berkenbilt
70ae58c035 better testing of V4
git-svn-id: svn+q:///qpdf/trunk@826 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-19 01:22:10 +00:00
Jay Berkenbilt
a8715c495b add C API for R4 encryption
git-svn-id: svn+q:///qpdf/trunk@825 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-19 00:36:51 +00:00
Jay Berkenbilt
09175e4578 more testing, bug fix for linearized aes encrypted files
git-svn-id: svn+q:///qpdf/trunk@824 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-19 00:17:11 +00:00
Jay Berkenbilt
94131116a9 more notes, testing of cleartext metadata, some crypt filter fixes
git-svn-id: svn+q:///qpdf/trunk@823 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-18 19:54:24 +00:00
Jay Berkenbilt
c2023db265 Implement changes suggested by Zarko and our subsequent conversations:
- Add a way to set the minimum PDF version
 - Add a way to force the PDF version
 - Have isEncrypted return true if an /Encrypt dictionary exists even
   when we can't read the file
 - Allow qpdf_init_write to be called multiple times
 - Update some comments in headers


git-svn-id: svn+q:///qpdf/trunk@748 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-05 00:42:48 +00:00
Jay Berkenbilt
c1e53f1480 bug fix: more gracefully handle xref stream with too many entries
git-svn-id: svn+q:///qpdf/trunk@747 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-10-04 23:56:56 +00:00
Jay Berkenbilt
6bdac26369 finished testing C API
git-svn-id: svn+q:///qpdf/trunk@734 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-09-27 20:33:17 +00:00
Jay Berkenbilt
8d7bb3ff50 add methods for getting encryption data
git-svn-id: svn+q:///qpdf/trunk@733 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-09-27 20:05:38 +00:00
Jay Berkenbilt
40f4b1ef52 more tests of C API
git-svn-id: svn+q:///qpdf/trunk@732 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-09-27 18:28:51 +00:00
Jay Berkenbilt
65bf77fa35 more tests of C API
git-svn-id: svn+q:///qpdf/trunk@728 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-09-27 16:55:24 +00:00
Jay Berkenbilt
fe6771e0e5 add many new tests to exercise C api
git-svn-id: svn+q:///qpdf/trunk@727 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-09-27 16:01:45 +00:00
Jay Berkenbilt
a1c0aaf03a windows fixes
git-svn-id: svn+q:///qpdf/trunk@684 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-07-15 03:47:44 +00:00
Jay Berkenbilt
a1fbb4bd97 update test suite
git-svn-id: svn+q:///qpdf/trunk@675 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-05-03 20:03:21 +00:00
Jay Berkenbilt
6f216135ab fix test count
git-svn-id: svn+q:///qpdf/trunk@666 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-03-09 16:57:49 +00:00
Jay Berkenbilt
9ac249e7e7 add damaged stream test case
git-svn-id: svn+q:///qpdf/trunk@664 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-03-09 16:39:33 +00:00
Jay Berkenbilt
f62bec3ee5 update test suite to handle original object ID comments
git-svn-id: svn+q:///qpdf/trunk@663 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-03-09 16:27:13 +00:00
Jay Berkenbilt
2af08ee398 checkpoint -- will have to finish another day
git-svn-id: svn+q:///qpdf/trunk@661 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-03-09 01:11:06 +00:00
Jay Berkenbilt
599daddb47 decode streams on check, always exit abnormally when warnings are detected
git-svn-id: svn+q:///qpdf/trunk@660 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-03-08 19:00:19 +00:00
Jay Berkenbilt
0b2288c19d special exit status in --check mode with warnings and no errors
git-svn-id: svn+q:///qpdf/trunk@650 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-02-21 02:38:33 +00:00
Jay Berkenbilt
35d72c822e better recovery for appended files with damaged cross-reference tables
git-svn-id: svn+q:///qpdf/trunk@648 71b93d88-0707-0410-a8cf-f5a4172ac649
2009-02-21 02:31:08 +00:00
Jay Berkenbilt
c7477e205e remove locale assumptions
git-svn-id: svn+q:///qpdf/trunk@612 71b93d88-0707-0410-a8cf-f5a4172ac649
2008-05-05 02:08:54 +00:00
Jay Berkenbilt
9a0b88bf77 update release date to actual date
git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649
2008-04-29 12:55:25 +00:00