summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-annot.c
AgeCommit message (Collapse)Author
2015-04-01fix bug #695895. Uninitialized variable in pdf_parse_file_specfredrossperry
2015-03-24Rework handling of PDF names for speed and memory.Robin Watts
Currently, every PDF name is allocated in a pdf_obj structure, and comparisons are done using strcmp. Given that we can predict most of the PDF names we'll use in a given file, this seems wasteful. The pdf_obj type is opaque outside the pdf-object.c file, so we can abuse it slightly without anyone outside knowing. We collect a sorted list of names used in PDF (resources/pdf/names.txt), and we add a utility (namedump) that preprocesses this into 2 header files. The first (include/mupdf/pdf/pdf-names-table.h, included as part of include/mupdf/pdf/object.h), defines a set of "PDF_NAME_xxxx" entries. These are pdf_obj *'s that callers can use to mean "A PDF object that means literal name 'xxxx'" The second (source/pdf/pdf-name-impl.h) is a C array of names. We therefore update the code so that rather than passing "xxxx" to functions (such as pdf_dict_gets(...)) we now pass PDF_NAME_xxxx (to pdf_dict_get(...)). This is a fairly natural (if widespread) change. The pdf_dict_getp (and sibling) functions that take a path (e.g. "foo/bar/baz") are therefore supplemented with equivalents that take a list (pdf_dict_getl(... , PDF_NAME_foo, PDF_NAME_bar, PDF_NAME_baz, NULL)). The actual implementation of this relies on the fact that small pointer values are never valid values. For a given pdf_obj *p, if NULL < (intptr_t)p < PDF_NAME__LIMIT then p is a literal entry in the name table. This enables us to do fast pointer compares and to skip expensive strcmps. Also, bring "null", "true" and "false" into the same style as PDF names. Rather than using full pdf_obj structures for null/true/false, use special pointer values just above the PDF_NAME_ table. This saves memory and makes comparisons easier.
2015-02-26tweak pdf_parse_file_specRobin Watts
pdf_parse_file_spec sometimes extracts the wrong path from a FileSpec: E.g. the /DOS path should never be returned under Unix systems, neither should be the old /Mac paths. For consistency, this patch also converts filesystem paths under Windows into a format applications will expect (e.g. from "/C/path/..." to "C:\path\..."). Finally, pdf_parse_file_spec is exposed to callers (SumatraPDF requires that for manually processing FZ_ANNOT_FILEATTACHMENT and embedded files).
2015-02-17Add ctx parameter and remove embedded contexts for API regularity.Tor Andersson
Purge several embedded contexts: Remove embedded context in fz_output. Remove embedded context in fz_stream. Remove embedded context in fz_device. Remove fz_rebind_stream (since it is no longer necessary). Remove embedded context in svg_device. Remove embedded context in XML parser. Add ctx argument to fz_document functions. Remove embedded context in fz_document. Remove embedded context in pdf_document. Remove embedded context in pdf_obj. Make fz_page independent of fz_document in the interface. We shouldn't need to pass the document to all functions handling a page. If a page is tied to the source document, it's redundant; otherwise it's just pointless. Fix reference counting oddity in fz_new_image_from_pixmap.
2015-02-17Rename fz_close_* and fz_free_* to fz_drop_*.Tor Andersson
Rename fz_close to fz_drop_stream. Rename fz_close_archive to fz_drop_archive. Rename fz_close_output to fz_drop_output. Rename fz_free_* to fz_drop_*. Rename pdf_free_* to pdf_drop_*. Rename xps_free_* to xps_drop_*.
2014-05-19Make unresolvable link destinations warnings instead of errors.Tor Andersson
See bug 693314 (file Z23-04.pdf) for an example file.
2014-03-25Break dependency of pdf-annot.c to graphics library.Tor Andersson
2014-03-19Add routine to clean pdf content streams for pages.Robin Watts
New routine to filter the content streams for pages, xobjects, type3 charprocs, patterns etc. The filtered streams are guaranteed to be properly matched with q/Q's, and to not have changed the top level ctm. Additionally we remove (some) repeated settings of colors etc. This filtering can be extended to be smarter later. The idea of this is to both repair after editing, and to leave the streams in a form that can be easily appended to. This is preparatory to work on Bates numbering and Watermarking. Currently the streams produced are uncompressed.
2014-02-25Support text (aka sticky note) annotationsPaul Gardiner
2014-02-14Add function for creating form fields (widgets)Paul Gardiner
This feature is being implemented mostly for the purpose of permitting the addition to a page of invisible signatures. Also change pdf_create_annot to make freshly created annotations printable by default.
2013-11-14Fix slip with use of tail pointer for the annotations listPaul Gardiner
pdf_load_annots was leaving the tail pointer pointing at the automatic variable head in the case of the page having no annotations.
2013-11-08Use an end pointer for the annotation list to avoid unnecessary iterationPaul Gardiner
2013-11-06Place newly created annotations at the end of the annotation listPaul Gardiner
This fixes bug 694755. Thank you to Michael Cadihac for the patch
2013-11-05Fix bug 694730: Wrong bbox in one-point ink annotationPaul Gardiner
Zero and one-point case both lead to an empty rectangle, but the one-point case needs expanding but wasn't because fz_expand_rect treats an empty rectangle as a special case (as it should)
2013-09-27tweak pdf_parse_actionSimon Bünzli
* Destination names are a name and not a string * Expose whether a /Launch action points to a path or a URI
2013-09-03Silence warning.Tor Andersson
2013-08-24Support named destinations in remote link annotations.Sebastian Rasmussen
Previously there was a bug when parsing GoToR link annotations that had a named destination. mupdf incorrectly attempted to resolve the destination in the current document. Now the destination name is present in the link objects returned to the application so it can resolve any names for GoToR links in the remote document instead.
2013-08-24Link annotation code rearranged for aesthetic reasons.Sebastian Rasmussen
2013-07-30For freetext annotations, distinguish device and page space correctly.Paul Gardiner
2013-07-29Add support for freetext annotationsPaul Gardiner
This initial commit doesn't entirely complete the task: 1) There are a couple of ucs<->winansi conversions left out, 2) The text displayed by the appearance string can slightly overflow the annotation rectangle.
2013-07-26Clean up whitespace.Tor Andersson
2013-07-22Collect together all code to do with appearance-stream creationPaul Gardiner
2013-07-19Initial work on progressive loadingRobin Watts
We are testing this using a new -p flag to mupdf that sets a bitrate at which data will appear to arrive progressively as time goes on. For example: mupdf -p 102400 pdf_reference17.pdf Details of the scheme used here are presented in docs/progressive.txt
2013-07-12Throw exception on invalid page objects when looking up page numbers.Tor Andersson
Also handle exceptions when parsing link destinations.
2013-07-03Avoid fz_throw/message on every annotation without appearance.Robin Watts
Annotations can sometimes not have appearance streams (such as Links). Avoid spewing messages to the console about this. Also avoids overhead of throw/catch each time.
2013-07-03Avoid spurious, broken-annotation warning when appearance stream missingPaul Gardiner
2013-06-28Ensure altered objects are moved to the incremental xref sectionPaul Gardiner
2013-06-28Optimise xref-section extension and improve linked list creationPaul Gardiner
2013-06-26Silence compiler warnings.Tor Andersson
2013-06-25Fix potential memory leakPaul Gardiner
2013-06-25Rid the world of "pdf_document *xref".Robin Watts
For historical reasons lots of the code uses "xref" when talking about a pdf document. Now pdf_xref is a separate type this has become confusing, so replace 'xref' with 'doc' for clarity.
2013-06-25Update pdf_obj's to have a pdf_document field.Robin Watts
Remove the fz_context field to avoid the structure growing.
2013-06-24Update annotation handling in preparation for incremental updatePaul Gardiner
When incremental update is in place, functions that alter one structure may have the side-effect of altering another: i.e., updating an annotation may require the Annots array or even the page to be cloned. This commit makes the existing annotation code hardy to this eventuallity. It also cleans up a slight mess of the past where not all annotation-altering functions had access to the pdf_annot struture, instead having to work with just the pdf object.
2013-06-20Rearrange source files.Tor Andersson