Jay Berkenbilt
7fa5d1773b
Implement top-level qpdf json parsing
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
8d42eb2632
Add scaffolding for QPDF JSON reactor
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
4fe2e06b47
Add --create-from-json and --update-from-json arguments
...
Also add stubs for top-level QPDF methods (createFromJSON,
updateFromJSON)
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
60ec94a7c3
Add QUtil::is_long_long
2022-05-16 13:39:26 -04:00
Jay Berkenbilt
4c7cfd5cbc
JSON reactor: improve handling of nested containers
...
Call the parent container's item method before calling the child
item's start method so we can easily know the current nesting level
when nested items are added.
2022-05-14 17:35:06 -04:00
Jay Berkenbilt
e9390aeaaa
Add --to-json option
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
c76536dd9a
Implement JSON v2 output
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
15272662f6
Fix typo in json output key name
...
moddify -> modify. Also carefully spell checked all remaining keys by
splitting them into words and running a spell checker, not just
relying on visual proofreading. That was the only one.
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
1bc8abfdd3
Implement JSON v2 for Stream
...
Not fully exercised in this commit
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
16f4f94cd9
Prepare code for JSON v2
...
Update getJSON() methods and calls to them
2022-05-07 11:12:01 -04:00
Jay Berkenbilt
948de60990
Objects json: write incrementally and in numeric order
...
The following script was used to adjust test data:
----------
#!/usr/bin/env python3
import json
import sys
import re
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
if 'objects' not in data:
continue
trailer = None
to_sort = []
for k, v in data['objects'].items():
if k == 'trailer':
trailer = v
else:
m = re.match(r'^(\d+) \d+ R', k)
if m:
to_sort.append([int(m.group(1)), k, v])
newobjects = {x[1]: x[2] for x in sorted(to_sort)}
if trailer is not None:
newobjects['trailer'] = trailer
data['objects'] = newobjects
print(json_dumps(data))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
1615d7feaf
Make JSON::writeNext public
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
dc9b7287cd
Top-level json: write incrementally
...
This commit just changes the order in which fields are written to the
json without changing their content. All the json files in the test
suite were modified with this script to ensure that we didn't get any
changes other than ordering.
----------
#!/usr/bin/env python3
import json
import sys
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
newdata = {}
for i in ('version', 'parameters', 'pages', 'pagelabels',
'acroform', 'attachments', 'encrypt', 'outlines',
'objects', 'objectinfo'):
if i in data:
newdata[i] = data[i]
print(json_dumps(newdata))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
a3c9980395
Add next to Pl_String and fix comments
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
b361c5ce19
Add --test-json-schema command-line option
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
7604ac5cb2
QPDFJob: have doJSON write to a pipeline
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
0500d4347a
JSON: add blob type that generates base64-encoded binary data
2022-05-06 19:14:52 -04:00
Jay Berkenbilt
05fda4afa2
Change JSON parser to parse from an InputSource
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e5f3910c3e
Add new FileInputSource constructors
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e259635986
JSON: add write methods and implement unparse() in terms of those
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
f4206a0938
Add new Pl_String Pipeline
2022-05-03 18:54:51 -04:00
Jay Berkenbilt
16139d97c8
Add new Pl_OStream Pipeline
2022-05-03 18:54:51 -04:00
Jay Berkenbilt
f1c6bb97db
Add new Pipeline convenience methods
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
59f3e09edf
Make Pipeline::write take an unsigned char const* (API change)
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
62bf296a9c
Make assert handling less error-prone
...
Prevent my future self or other contributors from using assert in
tests and then having that assert not do anything because of the
NDEBUG macro.
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
8d2a0eda5a
Add reactors to the JSON parser
2022-05-01 19:55:52 -04:00
Jay Berkenbilt
e34dbbfa18
Spell check
2022-05-01 12:56:22 -04:00
Jay Berkenbilt
8ccd3a8a89
Mark weak encryption with API changes ( fixes #576 )
2022-04-30 17:24:15 -04:00
Jay Berkenbilt
2213ed0c3d
Remove deprecated (pre-8.4.0) encryption APIs
2022-04-30 17:23:58 -04:00
Jay Berkenbilt
ce19471f18
Add comments around non-security-related uses of MD5
2022-04-30 14:15:07 -04:00
Jay Berkenbilt
c365a26e9d
Revert "Remove QPDFObjectHandle::replaceOrRemoveKey"
...
This reverts commit dc059560e7
.
I changed my mind. There's no harm in leaving it deprecated for a
release cycle.
2022-04-30 14:15:07 -04:00
Jay Berkenbilt
dc059560e7
Remove QPDFObjectHandle::replaceOrRemoveKey
...
See ChangeLog for rationale for not deprecating it as originally
planned.
2022-04-30 13:39:45 -04:00
Jay Berkenbilt
e80fad86e9
Add new QPDFObjectHandle methods for more fluent programming
2022-04-29 20:09:10 -04:00
Jay Berkenbilt
4be2f36049
Deprecate replaceOrRemoveKey -- it's the same as replaceKey
2022-04-24 09:31:32 -04:00
Jay Berkenbilt
4925f0d18c
Have dictionary/streams mutators take const& where possible
2022-04-24 09:05:50 -04:00
Jay Berkenbilt
68e721981a
Add new QPDF::warn that takes most of QPDFExc's arguments
2022-04-23 18:25:43 -04:00
Jay Berkenbilt
22b35c4928
Expose QUtil::get_next_utf8_codepoint
2022-04-23 18:25:43 -04:00
Jay Berkenbilt
80ed3076a0
Remove deprecated name/number tree constructors
...
Remove the name/number tree object helper constructors that don't take
a QPDF&.
2022-04-16 13:13:15 -04:00
Jay Berkenbilt
496ca2e4dc
Remove QPDFAcroFormDocumentHelper::copyFieldsFromForeignPage
2022-04-16 13:12:07 -04:00
Jay Berkenbilt
cdd0b4fb7d
Use = default and = delete where possible in classes
2022-04-16 11:39:14 -04:00
Jay Berkenbilt
2a7d2b63c2
Make ABI-breaking changes that don't modify API at all
...
* Merge overloaded functions by adding default values
* Remove non-const methods that are identical to const methods
2022-04-16 10:41:46 -04:00
Jay Berkenbilt
e2d6f035c0
Fix comments in PointerHolder.hh
2022-04-10 17:33:25 -04:00
Jay Berkenbilt
a249f89715
Typo: warn -> warning
2022-04-10 17:27:30 -04:00
Jay Berkenbilt
5f4675bb24
Mark non-ABI symbols in exported class with QPDF_DLL_PRIVATE
2022-04-10 16:54:23 -04:00
Jay Berkenbilt
5525c93124
Use QPDF_DLL_CLASS with Pipeline and InputSource subclasses
...
This enables RTTI so we can use dynamic_cast on them across the shared
object boundary.
2022-04-10 16:52:57 -04:00
Jay Berkenbilt
90cfe80bac
Clean up/fix DLL.h
...
* Change DLL_EXPORT to libqpdf_EXPORTS (internal to the build). The
new name is cmake's default, is more conventional, and is less
likely to clash with other symbols.
* Add QPDF_DLL_PRIVATE for non-Windows
* Make logic around when to define QPDF_DLL et al more explicit
* Add detailed comments
2022-04-10 16:52:36 -04:00
Jay Berkenbilt
8c504c9a90
Tweak for clang-format and emacs font-lock
2022-04-10 12:49:50 -04:00
Jay Berkenbilt
ef2b84c6c3
Enable PointerHolder warning and define POINTERHOLDER_IS_SHARED_POINTER
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
a68703b07e
Replace PointerHolder with std::shared_ptr in library sources only
...
(patrepl and cleanpatch are my own utilities)
patrepl s/PointerHolder/std::shared_ptr/g {include,libqpdf}/qpdf/*.hh
patrepl s/PointerHolder/std::shared_ptr/g libqpdf/*.cc
patrepl s/make_pointer_holder/std::make_shared/g libqpdf/*.cc
patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g libqpdf/*.cc
patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh
git restore include/qpdf/PointerHolder.hh
cleanpatch
./format-code
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
ae819b5318
Rewrite PointerHolder as derived from std::shared_ptr
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
ec21910066
Bump version to 11.0.0, indicating ABI-breaking changes
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
12f1eb15ca
Programmatically apply new formatting to code
...
Run this:
for i in **/*.cc **/*.c **/*.h **/*.hh; do
clang-format < $i >| $i.new && mv $i.new $i
done
2022-04-04 08:10:40 -04:00
Jay Berkenbilt
b8aff90997
Add cmake configuration files
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
6b114684c2
DLL.h: remove distinction between QPDF_DLL_CLASS and QPDF_DLL for mingw
2022-03-08 12:05:06 -05:00
Jay Berkenbilt
5f329e6206
Remove Version.h -- it was never used
2022-02-27 20:01:32 -05:00
Jay Berkenbilt
03bc6535bd
generate_auto_job: protect generated files from formatting
2022-02-26 09:17:51 -05:00
Jay Berkenbilt
48467ccdc1
Pl_DCT.hh -- protect order of includes for code formatting
2022-02-26 08:32:55 -05:00
Jay Berkenbilt
78ad4ad180
Bump version to 10.6.3
2022-02-26 07:15:14 -05:00
Jay Berkenbilt
38d8362c09
Prepare 10.6.2 release
2022-02-15 19:36:39 -05:00
Jay Berkenbilt
b63e17fffb
Fix lgtm warning
2022-02-15 19:30:34 -05:00
Jay Berkenbilt
a478cbb6dc
Silently/transparently recognize UTF-16LE as UTF-16 ( fixes #649 )
...
The PDF spec only allows UTF-16BE, but most readers seem to accept
UTF-16LE as well, so now qpdf does too.
2022-02-15 16:13:12 -05:00
Jay Berkenbilt
2b8d0f385b
Prepare 10.6.1 release
2022-02-11 09:36:17 -05:00
Jay Berkenbilt
d6fe473029
Prepare 10.6.0 release
2022-02-08 16:54:03 -05:00
Jay Berkenbilt
ec778ef98b
Add additional comments about new accessor methods
2022-02-08 16:49:43 -05:00
Jay Berkenbilt
d501e1c0d4
Only update output version from files used as input
...
If we're opening a PDF file to copy its encryption information or
attachments, its version doesn't need to influence the output version.
2022-02-08 13:49:22 -05:00
Jay Berkenbilt
f91b21c7d4
Preserve input PDF version on pages/split-pages ( fixes #610 )
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
cfd5147d92
Add QPDF::getVersionAsPDFVersion
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
8082af09be
Add PDFVersion class
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
014dcb02c9
Revert an incorrect correction
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
cb769c62e5
WHITESPACE ONLY -- expand tabs in source code
...
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-08 11:51:15 -05:00
m-holger
716381f65a
Fix doc typos
2022-02-08 11:50:58 -05:00
Jay Berkenbilt
68e4aec054
Clarify qpdf's representation of names in the API
...
Clarify that names are to appear in canonical form with PDF escaping
resolved when used in non-parsing QPDFObjectHandle APIs and their C
API counterparts. See https://github.com/qpdf/qpdf/discussions/625 .
2022-02-08 09:09:23 -05:00
Jay Berkenbilt
c62e8e2b28
Update for clean compile with POINTERHOLDER_TRANSITION=2
2022-02-07 17:38:22 -05:00
Jay Berkenbilt
40f1946df8
Replace PointerHolder arrays with shared_ptr arrays where possible
...
Replace PointerHolder arrays wherever it can be done without breaking ABI.
2022-02-07 17:38:22 -05:00
Jay Berkenbilt
dd4f30226f
Rework PointerHolder transition to make it smoother
...
* Don't surprise people with deprecation warnings
* Provide detailed instructions and support for the transition
2022-02-07 17:38:20 -05:00
Jay Berkenbilt
df2f5c6a36
Add QUtil::make_shared_array to help with PointerHolder transition
2022-02-07 14:08:46 -05:00
Jay Berkenbilt
cfaae47dc6
Add getBufferSharedPointer() to Pl_Buffer and QPDFWriter
2022-02-07 12:53:28 -05:00
Jay Berkenbilt
6a2456f732
Comment, ChangeLog, release note for new contribution
2022-02-06 11:27:02 -05:00
m-holger
5901fcad4c
C-API expose QPDFObjectHandle::getKeyIfDict
2022-02-06 11:21:15 -05:00
m-holger
8371060340
Add method QPDFObjectHandle::getKeyIfDict
2022-02-06 11:21:15 -05:00
m-holger
2ed5f49a79
C-API expose QPDFObjectHandle::getValueAs... accessors
2022-02-05 19:40:30 -05:00
Jay Berkenbilt
af3f74de8c
Stop using std::iterator ( fixes #618 )
...
Create the typedefs directly in iterators rather than deriving from
the deprecated std::iterator class.
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
7fb22740e1
Add operator ""_qpdf for creating QPDFObjectHandle literals
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
b48a0ff0e8
Add qpdf_empty_pdf to C API
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
8cf7f2bfb5
API contract: qpdf_get_qpdf_version() returns a static
2022-02-05 11:24:56 -05:00
Jay Berkenbilt
5f3f78822b
Improve use of std::unique_ptr
...
* 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-05 11:24:56 -05:00
m-holger
e58b1174c7
Add new QPDFObjectHandle::getValueAs... accessors
2022-02-05 11:24:35 -05:00
Jay Berkenbilt
cfaa2de804
Update copyright for 2022
2022-02-04 16:36:22 -05:00
Jay Berkenbilt
8eab616d62
Add qpdf version macros to qpdf/DLL.h
2022-02-04 13:41:01 -05:00
Jay Berkenbilt
abc300f05c
Replace containers of PointerHolder with containers of std::shared_ptr
...
None of these are in the public API.
2022-02-04 13:12:37 -05:00
Jay Berkenbilt
f0c2e0ef1e
JSON: use std::shared_ptr internally
2022-02-04 13:12:37 -05:00
Jay Berkenbilt
9044a24097
PointerHolder: deprecate getPointer() and getRefcount()
...
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-02-04 13:12:37 -05:00
Jay Berkenbilt
f727bc9443
PointerHolder: add get() and use_count() for forward compatibility
...
PointerHolder will be replaced with shared_ptr, so let people start
moving.
2022-02-04 13:12:37 -05:00
m-holger
95e7d36b7a
C-API add two binary UTF8 funtions
...
add qpdf_oh_new_binary_unicode_string and qpdf_oh_get_binary_utf8_value
2022-02-04 13:10:51 -05:00
m-holger
e813176bc0
Fix some doc typos
2022-02-02 14:07:32 -06:00
Jay Berkenbilt
42bff9f458
QPDFJob: let initializeFromArgv just take argv, not argc
...
Let argv be a null-terminated array. There is already code that
assumes this, and it makes it easier to construct the arguments.
2022-02-01 13:50:58 -05:00
Jay Berkenbilt
a0d9d9923c
Finish QPDFJob examples and add tests for them
2022-02-01 13:50:58 -05:00
Jay Berkenbilt
b02d37bc0a
Make QPDFArgParser accept const argv
...
This makes it much more convention to use the initializeFromArgv
functions since you can use string literals.
2022-02-01 13:50:58 -05:00
Jay Berkenbilt
bc4e2320e7
Add qpdfjob-c.h -- simple C API around parts of QPDFJob
2022-02-01 09:04:55 -05:00
Jay Berkenbilt
b42f3e1d15
Move more code from qpdf.cc into QPDFJob
2022-02-01 09:04:55 -05:00
Jay Berkenbilt
cc5485dac1
QPDFJob: documentation
2022-02-01 09:04:55 -05:00
Jay Berkenbilt
5a7bb3474e
generate_auto_job: generate overloaded config decls for optional
...
For optional parameter/choices, generate an overloaded config method
that takes no arguments. This makes it possible to convert from a bare
argument to one that takes an optional parameter without breaking
binary compatibility.
2022-02-01 09:04:55 -05:00
Jay Berkenbilt
e3506253f1
Add optional version to --json
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
caa00556cf
Change filename or path to file in json and QPDFJob
...
Use "file" consistently for specifying a file path. We use "filename"
when adding attachments for a completely different purpose.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
f99e0af49c
QPDFJob: rename function that returns job schema
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
1355d95d08
QPDFJob: partial mode for initializeFromJson
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
28278e27ea
Keep JSONHandler and QPDFArgParser private
...
Since the functionality of argument parsing has moved into QPDFJob,
these classes no longer need to be public. Their methods still have to
be in the library's binary interface so they can be tested in libtests.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
8a9100f674
QPDFJob: add checkConfiguration to Config
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
0364024781
Use QPDFUsage exception for cli, json, and QPDFJob errors
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2e4e25a934
Fix some comments
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
98f25fdfa1
QPDFJob: make easy things private
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
ac56e013d6
Add missing QPDF_DLL
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
a87dcba13f
QPDFJob: generate declarations of trivial config methods
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
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
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
8dea480c9f
Allow optional fields in json "schema" checks
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
37105710ee
Implement JSONHandler for recursively processing JSON
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e8e8f6f43c
Add JSON::parse
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
b4bd124be4
QPDFArgParser: support adding/printing help information
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
3ab25d595b
Fix doc typos caught by m-holger -- thanks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f1d805badc
Add QPDFArgParser::copyFromOtherTable
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f8eee83515
Expose QPDFArgParser::usage
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
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
8a5ba5686c
Add some doc comments for QPDFObjectHandle dictionary methods
2022-01-30 12:09:54 -06:00
m-holger
0f9086e509
Fix doc typos
2022-01-30 12:09:54 -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
af91b5b584
Add QUtil::file_can_be_opened
2021-12-29 13:41:02 -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
e19114df7a
Remove unneeded paragraph from comments
2021-12-18 11:05:51 -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
c40f8b5329
Make object types available to C API
2021-12-17 12:38:52 -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
3f9d50b526
Change name of formal parameters from data to qpdf
2021-12-16 11:51:15 -05:00
Jay Berkenbilt
1c62c2a342
C API: expose functions for indirect objects ( fixes #588 )
2021-12-10 14:57:35 -05:00
Jay Berkenbilt
8e0b153332
Expose QPDFObjectHandle::addTokenFilter ( fixes #580 )
2021-12-10 13:37:07 -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
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
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