summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
2018-02-27Add fz_translate_rect helper function.Tor Andersson
2018-02-27Add convenience functions to create point/rect/matrix.Tor Andersson
In the absence of C99 (fz_rect){0,0,1,1} syntax, this will have to do.
2018-02-27Remove typedef in favor of explicit enum keyword.Tor Andersson
Avoids the silliness of fz_annot_type pdf_annot_type().
2018-02-27Don't use constants larger than will fit in a signed int in enum.Tor Andersson
2018-02-13Add fz_begin_layer/fz_end_layer.Robin Watts
Call these from the PDF interpreter. Make the DisplayList and Trace devices cope. Use these in the SVG output device.
2018-02-12Expose detailed PDF permissions.Tor Andersson
2018-02-12Don't pollute global namespace with __printflike.Tor Andersson
Use a FZ_PRINTFLIKE macro instead.
2018-02-07Fix uninitialised variable warning in fz_peek_bytePaul Gardiner
2018-02-02Signature support: code-style and typo fixesPaul Gardiner
2018-02-02Signature support: decouple mupdf from the pkcs7 implementationPaul Gardiner
The mupdf build included an implimentation of the pkcs7 functions that are needed for signing documents and verifying signatures, the implementation being either an openssl-based one, or a stub that returned errors. This commit removes the pkcs7 functions from the main mupdf library. For the sake of verification, there wasn't really a need for the pkcs7 functions to be part of mupdf. It was only the checking function that used them. The checking function is now provided as a helper, outside of the main build. The openssl-based pkcs7 functions area also supplied as a helper. Users wishing to verify signatures can either use the checking function directly, or use the source on which to base their own. Document signing requires more integration between mupdf and pkcs7 because part of the process is performed at time of signing and part when saving the document. Mupdf already had a pdf_pkcs7_signer object that kept information between the two phases. That object has now been extended to include the pkcs7 functions involved in signing, and the signing function now requires such an object, rather than a file path to a certificate. The openssl-based pkcs7 helper provides a function that, given the path to a certificate, will return a pdf_pkcs7_signer object. The intention is that different implementations can be produced for different platforms, based on cryptographic routines built into the operationg system. In each case, for the sake of document signing, the routines would be wrapped up as a pdf_pkcs7_signer object.
2018-02-02Signature support: break out function for obtaining hash bytesPaul Gardiner
2018-02-02Signature support: simplify pkcs7 api by the removal of byte ranges.Paul Gardiner
Rather than provide a stream and an explicitly defined set of byte ranges within that stream, provide a stream that gives access to just the bytes in the ranges.
2018-02-02Generalise the null filter to handle more than a single range.Paul Gardiner
This is needed to simplify the way the bytes for hashing are passed to pkcs7 functions.
2018-02-02Signature support: separate pkcs7 specifics into a separate file.Paul Gardiner
Previously, pdf-pkcs7.c contained mishmash of functions required for creating and checking signatures, with no separation between the parts relating to pdf and those relating to pkcs7. This commit introduces pdf_signature.c which contains the pdf specifics, leaving pdf-pkcs7.c to be purely pkcs7 functions. This should more easily allow the use of pkcs7 solutions other than openssl. The pkcs7 api is declared in pdf-pkcs7.h. It is entirely free of mupdf specifics, other than using an fz_stream to specify the bytes to be hashed.
2018-02-02Signature support: use an enum to report errors.Paul Gardiner
Previously, errors were reported with a boolean function return with a char buffer filled out with the reason in the failure case. Now an enum is used to report the various failure cases. The function pdf_check_signature has been left as is so that existing apps will not need changing.
2018-01-31Add pdf_debug_obj function to quickly print objects from gdb command line.Tor Andersson
2018-01-31Add convenience functions to set dict/array values by primitives.Tor Andersson
2018-01-31Rename confusing fz_stream close callback to drop.Tor Andersson
2018-01-31Add buffering to fz_output.Tor Andersson
2018-01-19Perform signature verification via fz_streamPaul Gardiner
Previously, signature verification worked only for file-based documents and the file path had to be passed into the verification function.
2018-01-19Perform document signing via fz_stream and fz_outputPaul Gardiner
This change achieves two goals. It allows signing to be performed even when the document is obtained other than from a disk file. It also reestablishes to a working state signing of file-based documents, a feature that was broken due to complete_signatures being called after certain tables, avaialble via the output options object, had been destroyed.
2018-01-19Add fz_output_as_streamPaul Gardiner
This provides a way for some output streams to also be read, a feature needed for the sake of document signing. Currently this is supported only for file output.
2018-01-10Add colorspace type enum and use it instead of hardcoded checks on N.Tor Andersson
2018-01-10Don't allow reading from a 'dead' fz_stream.Tor Andersson
Once a stream has thrown an exception or reached EOF, don't allow further reading. The EOF flag is reset when fz_seek is invoked.
2018-01-10Handle exceptions in fz_peek_byte the same way as in fz_read_byte.Tor Andersson
2018-01-05Enable saving of encrypted PDF files.Robin Watts
We need both RC4 and AES encryption. RC4 is a straight reversable stream, and our AES library knows how to encrypt as well as decrypt, so it's "just" a matter of calling them correctly. We therefore expose a generic "encrypt this data" routine (and a matching "how long will the data be once encrypted" routine) within pdf-crypt.c. We then extend our our PDF object output routines to call these. This is enough to get encrypted data preserved over calls to mutool clean. Unfortunately the created files aren't readable, due to 2 further problems, also fixed here. Firstly, mutool clean does not preserve the Encrypt entry in the trailer. This is a simple fix. Secondly, we are required NOT to encrypt the Encrypt entry. This requires us to spot the crypt entry and to special case it.
2018-01-04Add portable pseudo-random number generator based on the lrand48 family.Tor Andersson
2017-12-13PDF object numbers need not be int64_t, int is sufficient.Sebastian Rasmussen
This is true because they are now limited below PDF_MAX_OBJECT_NUMBER.
2017-12-13Define constant INT64_MAX where int64_t is declared.Sebastian Rasmussen
2017-12-13Bugs 698804/698810/698811: Keep PDF object numbers below limit.Sebastian Rasmussen
This ensures that: * xref tables with objects pointers do not grow out of bounds. * other readers, e.g. Adobe Acrobat can parse PDFs written by mupdf.
2017-12-13Parse XML using pool allocator.Tor Andersson
This needs adding a fz_xml_doc type to hold the pool.
2017-12-13Add 'clean' option to pdfclean to clean (but not sanitize) content streams.Tor Andersson
This goes well with the 'mutool clean -d' decompression option to debug content streams, without doing the sanitize optimization pass.
2017-11-23Bump version number to 1.12.0.Tor Andersson
2017-11-23Make time stamps 64-bit integers.Tor Andersson
Future proof the API for the Year 2038 problem.
2017-11-22Remove unused annotation function.Tor Andersson
2017-11-22jni/js: Add support for annotation modification dates.Sebastian Rasmussen
2017-11-22jni/js: Use correct text encoding in annotation author and contents.Fred Ross-Perry
Also clarify that a copy of author/contents is returned, and that the caller must free them.
2017-11-22Add pdf_new_text_string utility function.Tor Andersson
Create a PDF 'text string' type string from a UTF-8 input string. If the input is plain ASCII, keep it as is, otherwise re-encode it as UTF-16BE.
2017-11-22jni: Make sure to dirty annotation whenever it changes.Fred Ross-Perry
2017-11-14Ensure that after_text functions get ctm.Robin Watts
Also wrap their contents in q/Q, so they can't screw up the rest of the stream.
2017-11-10Remove fz_android_fprintf.Tor Andersson
Use android logging for throw/warn like we do with OutputDebugString on windows.
2017-11-10Purge obsolete NDK_PROFILER code.Tor Andersson
2017-11-09Bug 698353: Avoid having our API depend on DEBUG/NDEBUG.Robin Watts
Currently, our API uses static inlines for fz_lock and fz_unlock, the definitions for which depend on whether we build NDEBUG or not. This isn't ideal as it causes problems when people link a release binary with a debug lib (or vice versa). We really want to continue to use static inlines for the locking functions as used from MuPDF, as we hit them hard in the keep/drop functions. We therefore remove fz_lock/fz_unlock from the public API entirely. Accordingly, we move the fz_lock/fz_unlock static inlines into fitz-imp.h (an internal header), together with the fz_keep_.../fz_drop_... functions. We then have public fz_lock/fz_unlock functions for any external callers to use that are free of compilications. At the same time, to avoid another indirection, we change from holding the locking functions as a pointer to a struct to a struct itself.
2017-11-08Clean up and speed up text searching.Tor Andersson
2017-11-08Select and copy structured text by lines.Tor Andersson
2017-11-08Remove broken bidi reordering code.Tor Andersson
TODO: Implement visual to logical reordering on the fly when building the structured text line.
2017-11-08Move static inline function out of header.Tor Andersson
2017-11-06Expose text filtering through pdf_clean interface.Robin Watts
2017-11-06Use text state handling in pdf_filter_processor to filter text.Robin Watts
2017-11-06Extract text state handling from run pdf_processor.Robin Watts
So it can be used in the filter pdf_processor too.