HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › Rendering chart image in PDF
- This topic has 3 replies, 3 voices, and was last updated Jul 22, 2009
20:06:42 by PD4ML.
-
AuthorPosts
-
July 22, 2009 at 16:27#26229
Hello.
I’m converting HTML source to PDF format. The HTML contains some references to a servlet that creates piechart image. It appears that PD4ML recognizes the call to the servlet in the HTML, and the debug info provides image size information about the piechart image.
However, PD4ML reports that the image type is unknown and does not render the piechart in the PDF document. What can I do to rectify this? Find the debug information below:
version: PD4ML 351b1 Pro (eval)
.text { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; color: #000000; text-decoration: none}
.bold { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; line-height: normal; font-weight: bold; font-variant: normal; text-transform: none; color: #000000; text-decoration: none}
.title { font-family: Arial, Helvetica, sans-serif; font-size: 9pt; font-style: normal; line-height: normal; font-weight: bold; font-variant: normal; text-transform: none; color: #000000; text-decoration: none}
.underlined { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; color: #000000; text-decoration: underline}
.7pttxt { font-family: Arial, Helvetica, sans-serif; font-size: 7pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; text-transform: none; color: #000000; text-decoration: none}
–>org.w3c.css.sac.CSSException: Encountered “.7pttxt” at line 6, column 1.
Was expecting one of:
…
“.” …
“:” …
“*” …
“[” …
…
“” …
“@page” …
“@media” …
“@font-face” …
…
… at com.steadystate.css.parser.SACParser.parseStyleSheet(SACParser.java:60)
at org.zefer.html.doc.d.d.new(Unknown Source)
at org.zefer.html.doc.d.c.o00000(Unknown Source)
at org.zefer.html.doc.PD4MLHtmlParser.buildDocument(Unknown Source)
at org.zefer.pd4ml.PD4ML.super(Unknown Source)
at org.zefer.pd4ml.PD4ML.render(Unknown Source)
at org.zefer.pd4ml.PD4ML.render(Unknown Source)
at com.ameritrade.jasom.documentdelivery.client.mytests.TestHtmlToPdf.generatePDF(TestHtmlToPdf.java:129)
at com.ameritrade.jasom.documentdelivery.client.mytests.TestHtmlToPdf.main(TestHtmlToPdf.java:98)
image not yet in cache: http://xxxxxx/gifs/intellistor/F_Intellistor/F38_9-20-02.gif
not yet in cache: http://xxxxxx/gifs/intellistor/F_Intellistor/F38_9-20-02.gif
image size: 23878
image not yet in cache: http://xxxxxx/gifs/intellistor/asset_allocation.gif
not yet in cache: http://xxxxxx/gifs/intellistor/asset_allocation.gif
image size: 583
image not yet in cache: http://xxxxxx/servlet/xxxxxxStatementPieChart?Title=May 30, 2003&points=2.5,CASH~1.6,MM FUND~71.7,FIXED~24.2,MUTUAL
not yet in cache: http://xxxxxx/servlet/xxxxxxStatementPieChart?Title=May 30, 2003&points=2.5,CASH~1.6,MM FUND~71.7,FIXED~24.2,MUTUAL
image size: 1895
image type of http://xxxxxx/servlet/xxxxxxStatementPieChart?Title=May 30, 2003&points=2.5,CASH~1.6,MM FUND~71.7,FIXED~24.2,MUTUAL is unknown.
can not load image: /servlet/xxxxxxStatementPieChart?Title=May 30, 2003&points=2.5,CASH~1.6,MM FUND~71.7,FIXED~24.2,MUTUAL
done in 4157ms.
done.Thanks for your help with this.
Best regards,
-Ade Olumide
July 22, 2009 at 16:42#27393But what type of image does piechart actualy return? PD4ML supports by default only Web- and Java-friendly image types: GIF, PNG and JPEG
Also “image size: 1895” log entry does not 100% mean it got an image. It still may be an error HTML message. The space characters in the image URL are possible reason of the error.
July 22, 2009 at 19:48#27394Your suggestions were extremely helpful.
As it turns out, the issue was a combination of bad path information and the white space between some of the servlet parameters. Once thoses issues were resolved, PD4ML was able to resolve the chart image (which was PNG). It complained about there being an excess number of colours and then reformatted the image, but it now shows up in the PDF. Here is the new debug info:
image not yet in cache: https://xxxxxxPieChartServlet?Title=May+30%2C+2003&points=2.5%2CCASH%7E1.6%2CMM+FUND%7E71.7%2CFIXED%7E24.2%2CMUTUAL
not yet in cache: https://xxxxxxPieChartServlet?Title=May+30%2C+2003&points=2.5%2CCASH%7E1.6%2CMM+FUND%7E71.7%2CFIXED%7E24.2%2CMUTUAL
image size: 5795
can not embed https://xxxxxxPieChartServlet?Title=May+30%2C+2003&points=2.5%2CCASH%7E1.6%2CMM+FUND%7E71.7%2CFIXED%7E24.2%2CMUTUAL. PNG should not have more than 256 colors. Reformatting image…done in 5592ms.
PDF creation done.Thanks a whole bunch for your help!!
Cheers,
-Ade O
July 22, 2009 at 20:06#27395The marked with red is a warning.
PDF allows to embed JPEGs and some species of PNG “as is”. Transparent, interlaced, “too-multicolor” PNGs need to be reformatted to the native for PDF not-lossy image format (more-less identical to GIF). As a result PDF size grows. However it is almost not noticeable for small images.
-
AuthorPosts
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.