katjas / pdfrenderer Goto Github PK
View Code? Open in Web Editor NEWJava library for rendering PDF documents to the screen using Java2D
License: Other
Java library for rendering PDF documents to the screen using Java2D
License: Other
This file render incorrectly.
sdf010452.pdf
Hi,
I'm trying to convert a pdf file to jpeg using PDFRenderer. This operation works fine in most situations, but I'm facing the following error when I try to convert a pdf file which has multiple page formats:
com.sun.pdfview.PDFParseException: Expected number for first xref entry
at com.sun.pdfview.PDFFile.readTrailer(Unknown Source)
at com.sun.pdfview.PDFFile.parseFile(Unknown Source)
at com.sun.pdfview.PDFFile.(Unknown Source)
at com.sun.pdfview.PDFFile.(Unknown Source)
I'm not sure if the size of pages is causing that, but it seems to be the only different property comparing to the files I'm used to work with.
Since Java 1.7u21 a Security Warning is displayed when mixing signed code is used.
http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/mixed_code.html
I would recommend to add "by default" a new manifest entry into the build.xml
Failed to read PDF with CCITTFaxDecode in case the "DecodeParms" specifies as Array.
for example:
<</Type/XObject
/Subtype/Image
/Width 1664
/Height 2278
/BitsPerComponent 1
/ColorSpace/DeviceGray
/Filter[/CCITTFaxDecode]
/DecodeParms[<</Columns 1664/Rows 2278/K -1 /BlackIs1 false>>]
/Length 260290
>>
stream
Hello
With the attached PDF, that contains a logo, I get the following error
com.sun.pdfview.PDFParseException: Unsupported shader type: 7
at com.sun.pdfview.pattern.PDFShader.getShader(PDFShader.java:139)
at com.sun.pdfview.PDFParser.doShader(PDFParser.java:1231)
at com.sun.pdfview.PDFParser.iterate(PDFParser.java:670)
at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:104)
at java.lang.Thread.run(Unknown Source)
in the console log,
and the logo is not displayed in the result image.
Armand Larregoity
Hi,
I'm using this fork of pdf-renderer to solve some out-of-memory problems I had with the original source.
These problems were solved but I'm is still not capable of printing a certain pdf I have containing the characters àáâãäå. The result is that the characters are not printed and all other a's in the text are not printed as well.
Are you interested in investigating this problem? It would help me a great deal. I could not attach the pdf to this ticket...
Regards,
Jeroen
it seems that there is missing support for pdf with CIDFontType0 subtype font and FontFile3.
is there any way to add this support?
providing compare result from a simple pdf that demonstrating the issue,
the pdf:
sample.pdf
there other pdf file that just showing incorrect characters
e.g.
When I try and convert particular pdfs from GeoPress I get to "JPXDecode failed. No reader available".
Do you plan to support more pdf types? I can give you examples of the pdfs if anyone want them.
The current implementation doesn't render text from form fields.
There are pdf files that wrongly using xref table that start from the value 1 instead of 0.
For example:
xref
1 7
0000000000 65535 f
0000000009 00000 n
0000512165 00000 n
0000512262 00000 n
0000512449 00000 n
0000512507 00000 n
0000512558 00000 n
trailer
Therefore, we may try to "fix" this situation, by "consider" the Object ID as 0 (zero)
only in case the first Object data is:
0000000000 65535 f
Executing PDFFile.getPage(...); throws a NullPointerException
if the page is a PDF Form, more specifically, Acroforms.
at java.util.ArrayList.addAll(ArrayList.java:559)
at com.sun.pdfview.annotation.WidgetAnnotation.getPageCommandsForAnnotation(WidgetAnnotation.java:221)
at com.sun.pdfview.PDFPage.setAnnots(PDFPage.java:673)
at com.sun.pdfview.PDFFile.createPage(PDFFile.java:1710)
at com.sun.pdfview.PDFFile.getPage(PDFFile.java:1588)```
First thanks for the work done. I think a simple usage example would be nice to test this.
I've found a difference in rendering fonts compared to the original version of PDFrenderer.
Here's the output generated by your version:
Here's the output from original PDFrenderer:
For reference, here's the original PDF document: https://dl.dropboxusercontent.com/u/25582411/document.pdf
Thanks!
in case the pdf file, using Font Object with the "FontName" is empty (null) and using the subtype of "CIDFontType2",
then, there is NullPointerException and the pdf not rendered correctly.
Hi,
I am trying to convert a PDF file to jpg images using PDFRenderer. It is converting the file with no exceptions yet all the embedded images in the PDF result in black. I can see the text rendering correctly yet for some reason the images fail.
I tried tracing the code to see what is failing however everything seems to be fine. I even enabled the image debugger and I can confirm that the images are getting drawn correctly, yet when the PDF page is rendered and converted the result is a black square in place of the image.
Here is the file in question: http://1drv.ms/1MMpbzM
When using font id with hex values then blank pages presented due to NPE.
in the follow pdf snap we can see the usage of the HEX values for for font id (and also for the version id)
pay attention for#2E
for . (dot)
and #5F
for _ (underscore)
`%PDF-1.5
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1#2E5
/Pages 2 0 R
/PieceInfo 3 0 R
/PageLabels 4 0 R
endobj
.
.
.
26 0 obj
<<
/ExtGState 48 0 R
/Font 49 0 R
/ProcSet [/PDF /Text]
/XObject 50 0 R
endobj
.
.
.
49 0 obj
<<
/T1#5F0 69 0 R
/T1#5F1 70 0 R
/T1#5F2 71 0 R
/T1#5F3 72 0 R
/T1#5F4 73 0 R
endobj
`
Hello
With the attached PDF, the quote in "l'E-Santé" is not displayed in the image.
Tests_fonts3_armand.pdf
It shows:
instead of
In bringing the project to maven I saw that the creation of the reader via JFrame is missing.
I'm adding it, are you interested? Obviously the next step would be to publish on maven2.
When I finish I create the pull request
It would be nice if the repository included the font files and ICC profiles from Sun's pdf-renderer library.
This way, it would be possible to build the software without having to copy files from another repository.
Missing ICC profile:
com/sun/pdfview/colorspace/sGray.icc
Missing Font folder:
com/sun/pdfview/font/res/
PDFrenderer cannot currently open PDFs using v5 encryption.
Are there any plans to support this? It is my understanding that this is the standard encryption mode in PDF 2.0, which is now almost five years old.
Hi Katja
Could you quickly mention which version of the original pdf-renderer from java.net you were using when creating the fork? I am having a pdf which was displayed correctly with the original pdf-renderer but now throws an exception:
com.sun.pdfview.PDFParseException: Unsupported function type 3.
at com.sun.pdfview.function.FunctionType3.parse(Unknown Source)
at com.sun.pdfview.function.PDFFunction.getFunction(Unknown Source)
at com.sun.pdfview.pattern.ShaderType2.parse(Unknown Source)
at com.sun.pdfview.pattern.PDFShader.getShader(Unknown Source)
at com.sun.pdfview.PDFParser.doShader(Unknown Source)
at com.sun.pdfview.PDFParser.iterate(Unknown Source)
at com.sun.pdfview.BaseWatchable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:680)
By the way, what was the reason for doing a fork instead of submitting the changes to java.net?
See http://java.net/jira/browse/PDF_RENDERER-15.
Here ist the Patch for the Type1Font Class:
diff --git a/src/com/sun/pdfview/font/Type1Font.java b/src/com/sun/pdfview/font/Type1Font.java index 3e26989..807726f 100644 --- a/src/com/sun/pdfview/font/Type1Font.java +++ b/src/com/sun/pdfview/font/Type1Font.java @@ -628,14 +628,14 @@ case 11: // return return; case 12: // ext... - v = (cs[loc++]) & 0xff; + v = ((int)cs[loc++]) & 0xff; if (v == 6) { // s x y a b seac + char a = (char) pop(); char b = (char) pop(); - char a = (char) pop(); float y = pop(); float x = pop(); buildAccentChar(x, y, a, b, gp); - this.sloc = 0; + sloc = 0; } else if (v == 7) { // x y w h sbw wid.y = pop(); wid.x = pop(); @@ -771,8 +771,8 @@ /** * build an accented character out of two pre-defined glyphs. - * @param x the x offset of the accent - * @param y the y offset of the accent + * @param x the x offset of the accent relativ to the sidebearing of the base char + * @param y the y offset of the accent relativ to the sidebearing of the base char * @param a the index of the accent glyph * @param b the index of the base glyph * @param gp the GeneralPath into which the combined glyph will be @@ -782,20 +782,28 @@ GeneralPath gp) { // get the outline of the accent GeneralPath pathA = getOutline(a, getWidth(a, null)); - + // don't manipulate the original glyph + pathA = (GeneralPath) pathA.clone(); try { // undo the effect of the transform applied in read - AffineTransform xformA = this.at.createInverse(); - xformA.translate(x, y); + final AffineTransform xformA = at.createInverse(); pathA.transform(xformA); + // Best x can't be calcualted cause we don't know the left sidebearing of the base character. + // Leaving x=0 gives the best results. + // see Chapter 6 of http://partners.adobe.com/public/developer/en/font/5015.Type1_Supp.pdf + // and the definition of the seac-Command in http://partners.adobe.com/public/developer/en/font/T1_SPEC.PDF + final AffineTransform xformA2 = AffineTransform.getTranslateInstance(0, y); + pathA.transform(xformA2); //<-- goht net fürs 'ä' } catch (NoninvertibleTransformException nte) { - pathA.transform(AffineTransform.getTranslateInstance(x, y)); + pathA.transform(AffineTransform.getTranslateInstance(0, y)); } GeneralPath pathB = getOutline(b, getWidth(b, null)); + // don't manipulate the original glyph + pathB = (GeneralPath) pathB.clone(); try { - AffineTransform xformB = this.at.createInverse(); + AffineTransform xformB = at.createInverse(); pathB.transform(xformB); } catch (NoninvertibleTransformException nte) { // ignore
Hi. I am using the PDFRenderer's old version. I want to use the most recent source code but there is a problem rendering the curved shapes. While rendering a curved shape, a straight line is drawn inside the curved shape.
There is more than one fork of the old PDFRenderer: Katjas and SwissAS. Which one should I use and which is "newer"?
When I process a PDF with crop marks, I see those crop marks in the images of the pages.
On http://www.prepressure.com/pdf/basics/page-boxes it is stated that one should always take the Trimbox whenever you need the actual size of the PDF. By default the TrimBox and CropBox are the same size, but in a PDF with crop marks they are not the same.
In the class PDFFile methode createPage, the MediaBox and the CropBoxe are used and the CropBox is stronger. Shouldn't this be the TrimBox instead?
If a PDF document contains a digital signature badge, this badge is not displayed when rendering the PDF.
With these pdf file
https://drive.google.com/file/d/0Byw-cYW1T3D-cUR5WVR4NWkxWEE/view?usp=sharing
java.lang.RuntimeException: Invalid code encountered.
at com.sun.pdfview.decode.CCITTFaxDecoder.decodeNextScanline(CCITTFaxDecoder.java:703)
at com.sun.pdfview.decode.CCITTFaxDecoder.decodeT41D(CCITTFaxDecoder.java:820)
at com.sun.pdfview.decode.CCITTFaxDecode.decode(CCITTFaxDecode.java:51)
at com.sun.pdfview.decode.CCITTFaxDecode.decode(CCITTFaxDecode.java:17)
at com.sun.pdfview.decode.PDFDecoder.decodeStream(PDFDecoder.java:103)
at com.sun.pdfview.PDFObject.decodeStream(PDFObject.java:331)
at com.sun.pdfview.PDFObject.getStream(PDFObject.java:263)
at com.sun.pdfview.PDFObject.getStream(PDFObject.java:257)
at com.sun.pdfview.PDFImage.getImage(PDFImage.java:225)
at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:273)
at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:643)
at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:570)
at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263)
at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197)
at com.sun.pdfview.PDFPage.getImage(PDFPage.java:228)
With the attached PDF
Test_background3.pdf
we get the following image
instead of
There is no error in the console log.
Armand Larregoity
Hallo Katja,
du hast in der Klasse PDFFont den Teil auskommentiert (Zeile 174) der den eingebetteten TTF-Font verwendet. Damit bekomme ich PDF-Dokument die ich nicht mehr darstellen kann.
In meinem Fall PDF-Dokument mit eingebettetem Calibri Font (als eingebettete Untergruppe). In diesem Fall ermittel er als baseFont="VNZQXL+Calibri". Dazu findet er dann keinen externen Font und als BuiltinFont gibt’s den erst recht nicht.
Ich hab den Teil bei mir wieder aktiviert um das Problem zu beheben. Hast du eine bessere Lösung?
Gruß Marcus
PDF: http://www.pdf995.com/samples/pdf.pdf
Hello i recompile this example https://github.com/clintel/PDFRenderer/blob/master/demos/viewer/com/sun/pdfview/PDFViewer.java with your fork, when i open PDF file with i recive this error
java.lang.ArrayIndexOutOfBoundsException: 2
at com.sun.pdfview.PDFDestination.getDestination(PDFDestination.java:128)
at com.sun.pdfview.PDFFile.getOutline(PDFFile.java:1489)
at com.sun.pdfview.PDFViewer.openPDFByteBuffer(PDFViewer.java:777)
at com.sun.pdfview.PDFViewer.openFile(PDFViewer.java:681)
at com.sun.pdfview.PDFViewer.doOpen(PDFViewer.java:836)
at com.sun.pdfview.PDFViewer$1.actionPerformed(PDFViewer.java:157)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Please create release of PDFrenderer to central maven repository, so that people can use this fine library as a maven dependency. Thanks!
using pdfrender class for convert pdf to image.into there some pdf can not convert iamges properly. also some text are not showing while converting images. also take much time for loading bitmaps
in case opening a large pdf file, that contain images pages, we may encounter OutOfMemoryError: Java heap space.
To fix it, need to call to the dispose() function for the reader object.
need to do it in class PDFImage (and on on class JPXDecode as well)
e.g.
jpegReader.dispose();
I always get an error when trying to print some PDF that contains JBIG2 images. Your library uses an improved version of JPedal's JBig2 decoder API . And bug is exist in this library that you consume (improved version of JPedal's JBig2 ). So please fix this bug.
All information about bug here:
http://stackoverflow.com/a/12316487/921193
Error stacktrace: https://idrsolutions.fogbugz.com/default.asp?support.2.4055.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.