summaryrefslogtreecommitdiff
path: root/pdf
AgeCommit message (Collapse)Author
2012-07-23Provide number of inputs/outpus when loading pdf functionsSebastian Rasmussen
This will allow the loading of pdf functions to validate that a pdf function has the correct number of inputs/outputs. Additionally it will allow for handling pdf functions with incorrect number of inputs/outputs.
2012-07-23Clamp number of pdf function inputs/outputsSebastian Rasmussen
Previously a pdf function having too many inputs or outputs would cause and exception, now they will be handled silently. There are two places pdf functions are used: for shadings and for colorspace tint transforms. In both cases the number of inputs/outputs may never be more than the number of components, i.e. limited to MAXN. Additionally the number of inputs/outputs may never be less than than the number of components, and there is always at least one component.
2012-07-23Remove redundant check in pdf function codeSebastian Rasmussen
BitsPerSample is already screened later in the code for invalid values, including the default value 0 returned by pdf_to_int().
2012-07-23Whitespace fixes in code for pdf functions.Sebastian Rasmussen
2012-07-23Fix encryption key length checkSebastian Rasmussen
Encryption keys lengths are expressed in bits, however one check assumed the length was expressed in bytes.
2012-07-23Prefer larger Width value if more than one is given for each glyph.Tor Andersson
Fixes bug #692267
2012-07-23Fallback case for type 1 fonts without encoding and non-standard glyph names.Tor Andersson
Fixes bug #692289
2012-07-23Tweak some font encoding heuristics.Tor Andersson
Always use BaseFont, always ignore font descriptor's FontName.
2012-07-23Only warn if ToUnicode CMap cannot be loaded.Tor Andersson
2012-07-23Don't encode MS-Symbol encoded fonts by glyph names.Tor Andersson
Fix bug http://code.google.com/p/sumatrapdf/issues/detail?id=1618
2012-07-23Use FT_ENCODING_MS_SYMBOL encoding for symbolic TrueType fonts.Tor Andersson
Fixes http://code.google.com/p/sumatrapdf/issues/detail?id=1815
2012-07-20Give precedence to /Subtype field when deciding on font encodings.Tor Andersson
Fixes bug where Symbol is not embedded but encoded as a TrueType but the built-in font is a Type1. http://code.google.com/p/sumatrapdf/issues/detail?id=1310
2012-07-20Prefer the more specific name if BaseName and FontName differ.Tor Andersson
Also strip the subset prefix.
2012-07-20Pass original font name to fz_new_font from PDF interpreter.Tor Andersson
Improves text device output when using substitute fonts. Fixes bug #693019.
2012-07-20Attempt to load CID fonts with invalid cid collections.Tor Andersson
Warn instead of throwing an error. Fixes file in http://code.google.com/p/sumatrapdf/issues/detail?id=1842
2012-07-18Fix broken pdf_write functionality.Robin Watts
Since I implemented linearisation, any invocation that hasn't used garbage collection has produced broken files, due to every object being marked as freed. This was because I'd forgotten to ever set the use_list markers to be 1. Fixed here.
2012-07-09Remove Symbol,Italic workaround and extend list of alternative names instead.Tor Andersson
2012-07-06Bug 693167: Solve pdfclean -ggg deleting too many objectsRobin Watts
While pdf writing, compactxref would fail to take into account that duplicated objects would have been mapped down to a lower number, and the use_list value for the upper one would be set to zero. Thanks to Zeniko for pointing out this fix.
2012-07-06Improve bounds checking in page tree.Sebastian Rasmussen
2012-07-06Improve bounds checking for image properties.Sebastian Rasmussen
2012-07-06Remove unnecessary check for unsupported crypt revision.Sebastian Rasmussen
2012-07-06Improve bounds checking of encryption key lengthSebastian Rasmussen
2012-07-06Reorder parsing of encryption dict.Sebastian Rasmussen
2012-07-06Make length check for crypt dict entries similar.Sebastian Rasmussen
2012-07-06Defer dereferencing of pdf_crypt until it's needed.Sebastian Rasmussen
2012-07-06Remove debugging functions for release builds.Sebastian Rasmussen
2012-07-05Fix free of uninitialised fontdesc pointer.Robin Watts
If an error occurs early enough we can end up trying to free an uninitialised pointer. Simply set it to NULL to start with. Problem seen with normal1265.pdf
2012-07-05Cope with illegal alpha values (out of range)Robin Watts
normal_457.pdf specifies an alpha value of 1.005, which causes overflows when calculating values. Simply clamp values into the 0..1 range.
2012-07-05Move to static inline functions from macros.Robin Watts
Instead of using macros for min/max/abs/clamp, we move to using inline functions. These are more typesafe, and should produce equivalent code on compilers that support inline (i.e. pretty much everything we care about these days). People can always do their own macro versions if they prefer.
2012-07-05Avoid calling pdf_array_len (and friends) in a loop.Robin Watts
for(i = 0; i < pdf_array_len(x); i++) ... results in lots of calls to pdf_array_len. This is not what we want.
2012-07-05Improve detection of images for pdfwrite.Robin Watts
In pdfwrite we have a flag to say "don't expand images", but this isn't always honoured because we don't know that a stream is an image (for instance the corrupt fax stream used as a thumbnail in normal_439.pdf). Here we update the code to spot that streams are likely to be images based on the filters in use, or on the presence of both Width and Height tags.
2012-07-04Reverse order of Y decomposition of mesh shading.Robin Watts
Solves problem seen in torture.pdf - we now match acrobat. Problem derived from normal_262.pdf
2012-06-28Allow for windows style synthetic font selectors of built-in fonts.Tor Andersson
For example "Symbol,Italic" can be handled as an artificially obliqued "Symbol". Fixes an issue in test file normal_161.pdf
2012-06-27Fix text clipping operations in pdf.Robin Watts
In PDF the text rendering mode can have bit 2 set to mean "add to clipping path". Experiments (and in particular normal_130.pdf) show that the text should be stroked and/or filled BEFORE the path is added to the clipping path.
2012-06-25Warning fixes and various clean ups:Sebastian Rasmussen
Remove unused variable, silencing compiler warning. No need to initialize variables twice. Remove initialization of unread variable. Remove unnecessary check for NULL. Close output file upon error in cmapdump.
2012-06-22Rework pdf_lexbuf to allow for dynamic parsing buffers.Robin Watts
Currently pdf_lexbufs use a static scratch buffer for parsing. In the main case this is 64K in size, but in other cases it can be just 256 bytes; this causes problems when parsing long strings. Even the 64K limit is an implementation limit of Acrobat, not an architectural limit of PDF. Change here to allow dynamic buffers. This means a slightly more complex setup and destruction for each buffer, but more importantly requires correct cleanup on errors. To avoid having to insert lots more try/catch clauses this commit includes various changes to the code so we reuse pdf_lexbufs where possible. This keeps the speed up.
2012-06-18Fix indentation and white space errors.Tor Andersson
2012-06-15Support UserUnit for scaling PDF pages.Tor Andersson
2012-06-13Tweak pdf_new_{rect,matrix,xobject} to avoid warnings.Robin Watts
These functions currently call pdf_array_put, but this fails to extend the array. Change to use pdf_array_push instead.
2012-06-13Remove unnecessary function and improve namingPaul Gardiner
2012-06-12A few general utility functions added for the sake of the forms workPaul Gardiner
2012-06-12Followup to commit 120dadb; improved error handling during interpretation.Robin Watts
After commit 120dadb, it's far too easy to get into a seemingly infinite loop while processing a corrupt file. We fix this by changing the process to abort when we receive an invalid keyword. Also, we add another layer of nesting to pdf_run_stream to avoid us push/popping an fz_try level on every keyword.
2012-06-11Fix Bug 693099: Render failure due to corrupt jpeg data.Robin Watts
The file supplied with the bug contains corrupt jpeg data on page 61. This causes an error to be thrown which results in mudraw exiting. Previously, when image decode was done at loading time, the error would have been thrown under the pdf interpreter rather than under the display list renderer. This error would have been caught, a warning given, and the program would have continued. This is not ideal behaviour, as there is no way for a caller to know that there was a problem, and that the image is potentially incomplete. The solution adopted here, solves both these problems. The fz_cookie structure is expanded to include a 'errors' count. Whenever we meet an error during rendering, we increment the 'errors' count, and continue. This enables applications to spot the errors count being non-zero on exit and to display a warning. mupdf is updated here to pass a cookie in and to check the error count at the end; if it is found to be non zero, then a warning is given (just once per visit to each page) to say that the page may have errors on it.
2012-05-31Add linearization to pdf_write function.Robin Watts
Extend mupdfclean to have a new -l file that writes the file linearized. This should still be considered experimental When writing a pdf file, analyse object use, flatten resource use, reorder the objects, generate a hintstream and output with linearisaton parameters. This is enough for Acrobat to accept the file as being optimised for Fast Web View. We ought to add more tables to the hintstream in some cases, but I doubt anyone actually uses it, the spec is so badly written. Certainly acrobat accepts the file as being optimised for 'Fast Web View'. Update fz_dict_put to allow for us adding a reference to the dictionary that is the sole owner of that reference already (i.e. don't drop then keep something that has a reference count of just 1). Update pdf_load_image_stream to use the stm_buf from the xref if there is one. Update pdf_close_document to discard any stm_bufs it may be holding. Update fz_dict_put to be pdf_dict_put - this was missed in a renaming ages ago and has been inconsistent since.
2012-05-23Bring xref object and stream mutation functions back from the dead.Tor Andersson
Needs more work to use the linked list of free xref slots.
2012-05-11Split part of fz_document interface for pdf_document into separate file.Tor Andersson
Make a separate constructor function that does not link in the interpreter, so we can save space in the mubusy binary by not including the font and cmap resources.
2012-05-10Combine all small tools into mubusy and remove the separate executables.Tor Andersson
2012-05-10Fix whitespace errors.Tor Andersson
2012-05-10mupdfclean - update to allow renumbering of encrypted objectsRobin Watts
mupdfclean (or more correctly, the pdf_write function) currently has a limitation, in that we cannot renumber objects when encryption is being used. This is because the object/generation number is pickled into the stream, and renumbering the object causes it to become unreadable. The solution used here is to provide extended functions that take both the object/generation number and the original object/generation number. The original object numbers are only used for setting up the encryption. pdf_write now keeps track of the original object/generation number for each object. This fix is important, if we ever want to output linearized pdf as this requires us to be able to renumber objects to a very specific order. We also make a fix in removeduplicateobjects that should only matter in the case where we fail to read an object correctly.
2012-05-08Bug 693028 - improve mupdf viewer handling of broken page streamsRobin Watts
Currently, if a page stream cannot be read, mupdf gives an alert box and then exits. This is annoying when reading a large pdf. Here we change the code to only exit if a page is completely broken; in the case of missing page contents, or missing links, we give a warning and just render the best we can. Also, update a couple of error messages to be less misleading.