aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFWriter.cc
AgeCommit message (Collapse)Author
2022-04-04Programmatically apply new formatting to codeJay Berkenbilt
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
2022-02-08Preserve input PDF version on pages/split-pages (fixes #610)Jay Berkenbilt
2022-02-08WHITESPACE ONLY -- expand tabs in source codeJay Berkenbilt
This comment expands all tabs using an 8-character tab-width. You should ignore this commit when using git blame or use git blame -w. In the early days, I used to use tabs where possible for indentation, since emacs did this automatically. In recent years, I have switched to only using spaces, which means qpdf source code has been a mixture of spaces and tabs. I have avoided cleaning this up because of not wanting gratuitous whitespaces change to cloud the output of git blame, but I changed my mind after discussing with users who view qpdf source code in editors/IDEs that have other tab widths by default and in light of the fact that I am planning to start applying automatic code formatting soon.
2022-02-07Update for clean compile with POINTERHOLDER_TRANSITION=2Jay Berkenbilt
2022-02-07Add getBufferSharedPointer() to Pl_Buffer and QPDFWriterJay Berkenbilt
2022-02-05Improve use of std::unique_ptrJay Berkenbilt
* Use unique_ptr in place of shared_ptr in some cases * unique_ptr for arrays does not require a custom deleter * use std::make_unique (c++14) where possible
2022-02-04Add a blank line after the first header included in each sourceJay Berkenbilt
2022-02-04Replace containers of PointerHolder with containers of std::shared_ptrJay Berkenbilt
None of these are in the public API.
2022-02-04PointerHolder: deprecate getPointer() and getRefcount()Jay Berkenbilt
Use get() and use_count() instead. Add #define NO_POINTERHOLDER_DEPRECATION to remove deprecation markers for these only. This commit also removes all deprecated PointerHolder API calls from qpdf's code except in PointerHolder's test suite, which must continue to test the deprecated APIs.
2022-01-30Add QUtil::make_shared_cstrJay Berkenbilt
Replace most of the calls to QUtil::copy_string with this instead.
2022-01-27Remove some if statements and simplify some boolean expressionsm-holger
Use QPDFObjectHandle::isNameAndEquals, isDictionaryOfType and isStreamOfType.
2021-05-09Performance fix on preserveObjectStreamsJay Berkenbilt
2021-05-08Exclude unreferenced objects in object streams (fixes #520)Jay Berkenbilt
2020-12-28Add QPDFObjectHandle::setFilterOnWriteJay Berkenbilt
2020-12-28Let optimize filter stream parameters instead of making them directJay Berkenbilt
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-28Refactor: separate code that determines whether to filter a streamJay Berkenbilt
2020-10-31Fix stack overflow on direct root (fuzz issue 26761)Jay Berkenbilt
2020-10-22Minor code cleanupJay Berkenbilt
* Return rather than exiting from realmain in qpdf.cc * Remove extraneous blank line * Don't assign temporary to const reference
2020-04-16Fix warnings reported by -Wshadow=local (fixes #431)Jay Berkenbilt
2020-04-03Internally use unsafeShallowCopy where we canJay Berkenbilt
2020-01-26In qdf mode, don't write extra XRef streams (fixes #386)Jay Berkenbilt
fix-qdf assumes there is exactly one XRef stream and that it is at the end of the file.
2019-11-09Allow /P in encryption dictionary to be positive (fixes #382)Jay Berkenbilt
Even though this is disallowed by the spec, files like this have been encountered in the wild.
2019-10-22Parse Contents in signature dictionary without encryptionMasamichi Hosoda
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-22Add QPDFWriter::getWrittenXRefTable()Masamichi Hosoda
2019-10-22Add QPDFWriter::getRenumberedObjGen()Masamichi Hosoda
2019-10-22Fix /Contents value representation in a signature dictionaryMasamichi Hosoda
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-08-29Don't encrypt trailer, fixes fuzz issue 15983Jay Berkenbilt
Ordinarily the trailer doesn't contain any strings, so this is usually a non-issue, but if the trailer contains strings, linearizing and encrypting with object streams would include encrypted strings in the trailer, which would blow out the padding because encrypted strings are longer than their cleartext counterparts.
2019-08-28Detect stream in object stream, fixing fuzz 16214Jay Berkenbilt
It's detected in QPDFWriter instead of at parse time because I can't figure out how to construct a test case in a reasonable time. This commit moves the fuzz file into the regular test suite for a QTC coverage case.
2019-08-28Make popping pipeline stack saferJay Berkenbilt
Use destructors to pop the pipeline stack, and ensure that code that pops the stack is actually popping the intended thing.
2019-08-24Add flags to control zlib compression level (fixes #113)Jay Berkenbilt
2019-08-22Remove array null flatteningJay Berkenbilt
For some reason, qpdf from the beginning was replacing indirect references to null with literal null in arrays even after removing the old behavior of flattening scalar references. This seems like a bad idea.
2019-06-23Allow set*EncryptionParameters before filename iset (fixes #336)Jay Berkenbilt
2019-06-22In shippable code, favor smart pointers (fixes #235)Jay Berkenbilt
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-22QPDFWriter: clean up overloaded functionsJay Berkenbilt
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-21Fix bugs found by fuzz testsJay Berkenbilt
* Several assertions in linearization were not always true; change them to run time errors * Handle a few cases of uninitialized objects * Handle pages with no contents when doing form operations * Handle invalid page tree nodes when traversing pages
2019-06-21Fix sign and conversion warnings (major)Jay Berkenbilt
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-15Fix problems found in fuzz corpusJay Berkenbilt
2019-06-09Handle empty DecodeParams array for (fixes #331)Jay Berkenbilt
On read, ignore /DecodeParms when empty list; on write, delete it. Some files have been found that include an empty list for /DecodeParms, but this is not technically compliant with the spec, and the only sensible interpretation is to treat it as if there are no decode parameters.
2019-01-29Fix logic for when to compress object and xref streams (fixes #271)Jay Berkenbilt
2019-01-17Modernize encryption API for more granularityJay Berkenbilt
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-04Add QPDFWriter::getFinalVersion (fixes #266)Jay Berkenbilt
2019-01-04Fix dangling references (fixes #240)Jay Berkenbilt
On certain operations, such as iterating through all objects and adding new indirect objects, walk through the entire object structure and explicitly resolve any indirect references to non-existent objects. That prevents new objects from springing into existence and causing the previously dangling references to point to them.
2018-08-12Remove some extraneous null pointer checks (fixes #234)Jay Berkenbilt
There were a few places in the code that were checking that a pointer wasn't null before deleting it, even though C++ has always allowed delete 0. Most of the code did not perform these checks.
2018-08-05Fix infinite loop on small files with progress reporting (fixes #230)Jay Berkenbilt
Turns out you can keep adding zero to a number over and over again and it just doesn't get any bigger. Who would have known?
2018-06-22Add progress reporting for QPDFWriter (fixes #200)Jay Berkenbilt
2018-06-22Correct incorrect commentJay Berkenbilt
2018-05-12newline before endstream fix for object streams (fixes #205)Jay Berkenbilt
2018-02-19Implement TokenFilter and refactor Pl_QPDFTokenizerJay Berkenbilt
Implement a TokenFilter class and refactor Pl_QPDFTokenizer to use a TokenFilter class called ContentNormalizer. Pl_QPDFTokenizer is now a general filter that passes data through a TokenFilter.
2018-02-19Add option to save pass 1 of lineariziationJay Berkenbilt
This is useful only for debugging the linearization code.
2018-02-05Fix linearization for files with nonstandard ID lengthJay Berkenbilt