summaryrefslogtreecommitdiff
path: root/pdf
AgeCommit message (Collapse)Author
2012-01-10Automatically load page tree when accessing a page/page count.Sebastian Rasmussen
2012-01-10Fix many spelling errors.Sebastian Rasmussen
2012-01-09Update fz_try/fz_catch to be fz_try/{fz_always}/fz_catch.Robin Watts
Add explanations of how to use the macros in fitz.h. Also included are 2 different formulations, with different strengths/ weaknesses for reference. Will remove these shortly, but I want a reference to them in git. Workaround bug in Mac OS Lion gcc (clang works fine).
2012-01-09Fix bug where pdf function was used after being dropped.Sebastian Rasmussen
2012-01-07Empty object store when freeing xref.Sebastian Rasmussen
Fixes a bug where objects remained in the store and would keep stable pointers to the freed xref, later on those objects could lead to false positive hits.
2012-01-07Fix compilation warningsSebastian Rasmussen
Add missing newline and remove excessive arguments.
2012-01-06PDF fixes/tweaks.Robin Watts
Fix 2 places where we were filling a stroked pattern rather than stroking it. Cope with being asked to run a NULL buffer. If running a stream fails, warn and return what we have, rather than giving up entirely. Should really set a return code for each render. Only look at the Print flag bit for Print renders. Only look at the View flag bit for view renders. If we find an unexpected ) or > during object parsing, warn and continue rather than giving up entirely. If optional content groups are broken, render the rest of the page anyway. Previously indirect objects that point to another indirection would cause a failure; now attempt to resolve these. We set an arbitrary limit of 10 such redirections to avoid infinite loops.
2012-01-06Various fixes to avoid arithmetic problems.Robin Watts
Various fixes to avoid overflow problems, division by zeros, use of uninitialised variables etc. All from/suggested by Zenikos patch.
2012-01-06pdf_repair tweaks; fail in fewer cases.Robin Watts
When repairing, if we hit a problem after having found a root object live with that root object rather than giving up completely. Also fix a memory leak, and cope better with trailing crap. Thanks to Zeniko for these.
2012-01-06Ignore decode arrays for indexed jpx images.Robin Watts
We can't do them properly at the moment, so don't try to do them at all - only makes stuff worse for now. Thanks to Zeniko for this.
2012-01-06Various memory leak fixes.Robin Watts
In error cases, ensure we free objects correctly. Thanks to Zeniko for finding the problems (and many of the solutions!)
2012-01-06Add 'marking' functions for dictionaries.Robin Watts
In various places in the code, we add markers (".seen") to dictionaries as we traverse them to ensure that we don't go into infinite loops. Adding a dictionary entry is bad as it's a) an expensive operation, b) a potentially destructive one, and c) produces another possible point of failure (as mallocs can fail). Instead, add a flag to each dict to allow them to be marked/unmarked and use that instead. Thanks to Zeniko for pointing out various places that could usefully be protected against infinite recursion.
2012-01-04Bug 692739: Add ability to abort time consuming actionsRobin Watts
A new 'cookie' parameter is added to page rendering/interpretation functions. Supply this as NULL to get existing behaviour. If you supply a non-NULL cookie, then this is taken as a pointer to a struct that can be used for simple, non-thread locked communication between caller and library. The entire struct should be memset to zero before entry, except for specific flags (thus coping with future extensions to this struct). The abort flag should be zero on entry. It will be checked periodically by the library - if the caller sets it non-zero (via another thread) then the current operation will be aborted. No guarantees are given as to how often this will be checked, or how fast it will be responded to. The progress_max field will be set to an integer (-1 for unknown) representing the number of 'things' to do. The progress field will count up from 0 to this number as time goes by. No guarantees are made as to the accuracy of this information, but it should be useful for offering some sort of progress bar etc. Note that progress_max may increase during the job. In general, callers should be careful to accept out of range or invalid data in this structure as this is deliberately accessed 'unlocked'.
2011-12-30Correct off by 1 error in outline handling.Robin Watts
When the page number is given by an int, rather than an indirect reference number in a link destination, the page number is already 0 based. Remove the adjustment that I'd been incorrectly doing.
2011-12-30Outline fixesRobin Watts
When reading an XYZ link destination, I was writing Z over X. While fixing this, change to cryptic enums rather than unexplained magic numbers. When reading the outlines out of a pdf file, better to actually store them in a linked list rather than just dropping them.
2011-12-28Silence warning in pdf_cmap_parse.cRobin Watts
2011-12-28Outline/link destination tweaks.Robin Watts
Move 'kind' into the fz_link_dest structure (as this makes more sense). Put an fz_link_dest rather than just a page number into the outlines structure. Correct parsing of actions and dests from pdf outlines.
2011-12-23Remove stray error check. Optional functions in shadings are optional.Tor Andersson
2011-12-23Generalise pdf_links to be fz_links.Robin Watts
Move to a non-pdf specific type for links. PDF specific parsing is done in pdf_annots.c as before, but the essential type (and handling functions for that type) are in a new file fitz/base_link.c. The new type is more expressive than before; specifically all the possible PDF modes are expressable in it. Hopefully this should allow XPS links to be represented too.
2011-12-23Add some fz_vars to fix exception behaviour.Robin Watts
gcc 4.4.5 gives helpful warnings about variables that can become unset due to setjmp/longjmp usage. Fix that here. Thanks to Sebras.
2011-12-22Fix Bug 692756: SEGVs in pdf_annot and pdf_outlineRobin Watts
A couple of bits of the code SEGV in the event that values are NULL. Fixed here by converting a do...while to a while, and adding an extra guard in the if. Thanks to Gaetan Bisson for the report, and patch.
2011-12-22More MemSqueezing fixes.Robin Watts
2011-12-20More memsqueezing fixes.Robin Watts
One of the previous memsqueezing fixes (specifically that in close_dctd) appears to cause the Memento fork bases squeezing process to stop. This appears to be because old code would do a NULL dereference causing a SEGV. This would somehow NOT be picked up by the signal handler, and the child would exit. If the code is fixed to avoid the SEGV the code then somehow goes on to do something (not in the close_dctd code) that makes the mem squeeze process grind to a halt - but NOT in the same instance of the executable. I am at a loss to explain this, but would rather the code stays as it is (being as far as I can see correct) for now.
2011-12-19More Memory squeezing fixesRobin Watts
2011-12-19Removed unused variable.Robin Watts
2011-12-17More memsqueezing fixes.Robin Watts
2011-12-17Change stream 'close' functions to facilitate error cleanup.Robin Watts
Rather than passing a stream to a close function, just pass context and state - that's all that is required. This enables us to call close to cleanup neatly if the stream fails to allocate.
2011-12-16More memsqueezing fixes.Robin Watts
2011-12-16More MemSqueezing fixes.Robin Watts
2011-12-16More memsqueezing fixes.Robin Watts
2011-12-16More memsqueezing fixes.Robin Watts
2011-12-16Mote memsqueezing fixes.Robin Watts
2011-12-16Add fz_malloc_struct, and make code use it.Robin Watts
The new fz_malloc_struct(A,B) macro allocates sizeof(B) bytes using fz_malloc, and then passes the resultant pointer to Memento_label to label it with "B". This costs nothing in non-memento builds, but gives much nicer listings of leaked blocks when memento is enabled.
2011-12-15More Memsqueezing fixes.Robin Watts
2011-12-15Another memsqueezing bug.Robin Watts
2011-12-15Another Memsqueezing bug.Robin Watts
2011-12-15Various Memsqueezing fixes.Robin Watts
Fixes for leaks (and SEGVs, division by zeros etc) seen when Memsqueezing.
2011-12-15Fix warnings/errors on unix builds.Robin Watts
Fix warnings/errors thrown up by the last few commits (which were only tested on windows).
2011-12-15Don't count ROM data in size of fontdescs.Robin Watts
The substitute fonts used in a fontdesc are held in ROM, and as such should not count towards the size of a fontdesc. Simple fix; remove the lines that adds that in.
2011-12-15Remove stray whitespace.Tor Andersson
2011-12-15Remove 'soft limit' on pixmaps in favour of fz_store.Robin Watts
Change the fz_store to be limited to 256 Megs. Remove the soft limit for pixmaps; the store will automatically throw old resources away to stay below the limit.
2011-12-15Rework pdf_store to fz_store, a part of fz_context.Robin Watts
Firstly, we rename pdf_store to fz_store, reflecting the fact that there are no pdf specific dependencies on it. Next, we rework it so that all the objects that can be stored in the store start with an fz_storable structure. This consists of a reference count, and a function used to free the object when the reference count reaches zero. All the keep/drop functions are then reimplemented by calling fz_keep_sharable/fz_drop_sharable. The 'drop' functions as supplied by the callers are thus now 'free' functions, only called if the reference count drops to 0. The store changes to keep all the items in the store in the linked list (which becomes a doubly linked one). We still make use of the hashtable to index into this list quickly, but we now have the objects in an LRU ordering within the list. Every object is put into the store, with a size record; this is an estimate of how much memory would be freed by freeing that object. The store is moved into the context and given a maximum size; when new things are inserted into the store, care is taken to ensure that we do not expand beyond this size. We evict any stored items (that are not in use) starting from the least recently used. Finding an object in the store now takes a reference to it already. LOCK and UNLOCK comments are used to indicate where locks need to be taken and released to ensure thread safety.
2011-12-09Reinstate some missing fz_vars.Robin Watts
2011-12-09Fix pdfdraw "repairing" every document.Robin Watts
When adding the exception handling in, I'd mis-indented some code. This caused all the file to be read.
2011-12-09Squash 2 warnings (fz_obj * != int).Robin Watts
2011-12-08Stylistic changes when testing pointer values for NULL.Tor Andersson
Also: use 'cannot' instead of 'failed to' in error messages.
2011-12-08Remove deprecated error handling code.Tor Andersson
2011-12-08Remove remaining fz_error_note calls in the pdf code.Tor Andersson
2011-12-08Throw exceptions for read errors.Tor Andersson
2011-12-08Move from volatile to fz_var.Robin Watts
When using exceptions (which are implemented using setjmp/longjmp), we need to be careful to ensure that variable values get written back before any exception happens. Previously we've done that using volatile, but that produces nasty warnings (and unduly limits the compilers freedom to optimise). Here we introduce a new macro fz_var that passes the address of the variable out of scope. This means that the compiler has to ensure that any changes to its value are written back to memory before calling any out of scope function.