Re: any HTML to PDF example within apache FOP?
Admittedly I am not familiar with HTML to PDF (and fairly new to FOP) but just wondering if the java heap size is a factor at all with the memory issues? Can you please give more detail about your setup? What environment? Do you have a -Xmxsize option anywhere? If so then is it possible to increase the heap size (unless I am on the wrong track of course). Thanks. -Mike On 21/05/11 21:51, Kapil garg wrote: ok I was able to find the jar 0.204 and run it successfully however it runs out of memory .., anyone be kind enough to share a working example within apache fop 1.0.0 to convert html to PDF? Am I missing something here? Kapil Garg From: gargka...@hotmail.commailto:gargka...@hotmail.com To: fop-...@xml.apache.orgmailto:fop-...@xml.apache.org Subject: HTML to PDF :NoSuchMEthod Erros on callingorg.apache.fop.fo.FOTreeBuilder in Driver class Date: Sun, 22 May 2011 05:05:31 +1000 Hello Guys Bit new on Apache FOP. I am trying to run a demo code to convert HTML into PDF. I am getting following exception on using fop 0.20.5 version I could not find the driver class in fop 1.0.0 version. IS there a sample code that converts html into pdf in FOP 1.0.0 version. I need urgently some sort of HTML to PDF conversion library. Am I missing here? Would FOP work for HTML to PDF conversion? Any help would be appreciated. Exception in thread main java.lang.NoSuchMethodError: org.apache.fop.fo.FOTreeBuilder: method init()V not found at org.apache.fop.apps.Driver.init(Driver.java:221) at org.apache.fop.apps.Driver.init(Driver.java:226) at com.smartbin.smartbinpdf.Html2Pdf.fo2PDF(Html2Pdf.java:135) at com.smartbin.smartbinpdf.Html2Pdf.main(Html2Pdf.java:61) This is my code package com.smartbin.smartbinpdf; import java.io.FileInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.ByteArrayOutputStream; import java.util.logging.Level; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import org.w3c.tidy.Tidy; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.apache.fop.apps.Driver; import org.apache.fop.messaging.MessageHandler; import org.apache.fop.tools.DocumentInputSource; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.Logger; /* * Class that converts HTML to PDF using * the DOM interfaces of JTidy, Xalan, and FOP. * * @author Kapil Garg * */ public class Html2Pdf { public static void main(String[] args) { FileInputStream input = null; try { // open file //if (args.length != 2) { // System.out.println(Usage: Html2Pdf htmlFile styleSheet); // System.exit(1); //} //String htmlFileName = args[0]; String htmlFileName = C:/fop-1.0/examples/html2pdf/hello.html; //try { input = new FileInputStream(htmlFileName); Tidy tidy = new Tidy(); //Document xmlDoc = tidy.parseDOM(input, null); Document xmlDoc = tidy.parseDOM(input, null) ; String stylesheet =C:/fop-1.0/examples/html2pdf/xhtml2fo.xsl; Document foDoc = xml2FO(xmlDoc, stylesheet); String pdfFileName = htmlFileName.substring(0, htmlFileName.indexOf(.)) + .pdf; try { OutputStream pdf = new FileOutputStream(new File(pdfFileName)); pdf.write(fo2PDF(foDoc)); } catch (java.io.FileNotFoundException e) { System.out.println(Error creating PDF: + pdfFileName); } catch (java.io.IOException e) { System.out.println(Error writing PDF: + pdfFileName); } } catch (FileNotFoundException ex) { java.util.logging.Logger.getLogger(Html2Pdf.class.getName()).log(Level.SEVERE, null, ex); } finally { try { input.close(); } catch (IOException ex) { java.util.logging.Logger.getLogger(Html2Pdf.class.getName()).log(Level.SEVERE, null, ex); } } } /* * Applies stylesheet to input. * * @param xml The xml input Document * * @param stylesheet Name of the stylesheet * * @return Document Result of the transform */ private static Document xml2FO(Document xml, String styleSheet) { DOMSource xmlDomSource = new DOMSource(xml); DOMResult domResult = new DOMResult(); Transformer transformer = getTransformer(styleSheet); if (transformer == null) { System.out.println(Error creating transformer for + styleSheet); System.exit(1); } try { transformer.transform(xmlDomSource, domResult); } catch
DO NOT REPLY [Bug 51245] New: Text is strongly clipped by block-container border when display-align is after.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51245 Bug #: 51245 Summary: Text is strongly clipped by block-container border when display-align is after. Product: Fop Version: all Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P2 Component: general AssignedTo: fop-dev@xmlgraphics.apache.org ReportedBy: alexander.chinga...@duallab.com Classification: Unclassified See attachment: zip includes source fo file and dstination pdf. If display-align is after and actual text height is a bit bigger than block-container height then text is shifted down and clipped by the block-container border. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are the assignee for the bug.
DO NOT REPLY [Bug 51245] Text is strongly clipped by block-container border when display-align is after.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51245 --- Comment #1 from Alexander Chingarev alexander.chinga...@duallab.com 2011-05-23 13:46:44 UTC --- Created attachment 27046 -- https://issues.apache.org/bugzilla/attachment.cgi?id=27046 source fo and destination pdf -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are the assignee for the bug.
JPEG2000 - RE: Fop Memory Use
While somewhat unrelated, I figure this is the best thread in which to note that there is a known memory leak within JAI when writing handling JPEG2000 images that a third party has fixed in March and documented it here: http://www.jpedal.org/PDFblog/2011/03/java-jai-image-io-jpeg2000-memory- leak-fix/ http://www.jpedal.org/PDFblog/2011/04/jai-memory-leak-source-changes/ They have been unable to commit their change to java-net since the move to Oracle. -Josh From: Eric Douglas [mailto:edoug...@blockhouse.com] Sent: Wednesday, May 18, 2011 1:43 PM To: fop-dev@xmlgraphics.apache.org Subject: RE: Fop Memory Use This test run isn't using SVG at all. The PDFRenderer is working, the PNGRenderer runs out of memory, so it is using images but as output. I already broke up the input to multiple FOs with multiple calls to the transform to generate a large document by combining small documents using the initial-page-number. As the program runs it just keeps increasing memory use. I tried running a profile with Java's VisualVM though I'm not sure what exactly I'm looking at or what to do with it. The number one item showing memory hog in the profiler, as of my last snapshot was: class int[], live bytes 23,273,952 B, live objects 382, generations 10 After the program crashed with the profiler running I had an additional file opened, Java2DRenderer.class, so I'm assuming it's doing something that breaks PNGRenderer. My class doesn't have any int[] references. After that first reference the sizes drop off sharply in the profiler. The next class reference is char[], then org.apache.fop.area.inline.SpaceArea. From: Peter Hancock [mailto:peter.hanc...@gmail.com] Sent: Wednesday, May 18, 2011 12:05 PM To: fop-dev@xmlgraphics.apache.org Subject: Re: Fop Memory Use Hi Eric, Does your document contain many large SVG's? If so take a look at Bugzilla #46360. This issue was resolved in rev 997602 of FOP trunk. Pete On Wed, May 18, 2011 at 5:10 PM, Adrian Cumiskey adrian.cumis...@gmail.com wrote: Hi Eric, Fop calculates layout in page sequence chunks, so try breaking up your pages into chunks of page sequences. Pages should be available for garbage collection once the page sequence has been rendered. Cheers, Adrian. On May 18, 2011, at 7:24 AM, Michael Rubin mru...@thunderhead.com wrote: Just a wild thought. But is there a way you could possibly get the JVM to garbage collect between each run? Maybe that might free the memory up? Thanks. -Mike On 18/05/11 13:20, Eric Douglas wrote: I am using Fop 1.0. I tried using Fop to transform a single document. When I got a little over 100 pages my FO file was over 5 MB. The transform crashed with a Java heap out of memory error. I managed to break the input down, as I'm using embedded code generating the input programmatically, and the PDF output is a lot smaller. So I'm currently transforming 10 pages at a time, setting the initial-page-number to the next sequence (1, 11, 21, etc). Then I save all the generated PDFs in memory and merge them using pdfbox. So far this is working great. I tried to do the same thing with the PNGRenderer, just calling a method to transform 10 pages at a time and save the output images in an array. The PNGRenderer is created locally in the method. It should be getting released when the method ends but the java process never releases any memory. I tested a 90 page report and the memory use was over 1 GB. I tested on another machine where the memory limit is apparently lower and it crashed on page 24. Everything about the method to render to PNG is the same as the method to render to PDF aside from the Renderer. Is there a problem with this renderer or something I could need to do different? Michael Rubin Developer Thunderhead Logo Error! Filename not specified. Error! Filename not specified. T F M E W +44 20 8238 7400 +44 20 8238 7401 mru...@thunderhead.com www.thunderhead.com http://www.thunderhead.com Thunderhead featured in The Sunday Times Profit Track 100 league table of companies with fastest-growing profits. Click here http://www.fasttrack.co.uk/fasttrack/press/pt11-lon.pdf to read more. Error! Filename not specified. http://www.linkedin.com/companies/25033/Thunderhead Error! Filename not specified. http://twitter.com/Thunderheadon Error! Filename not specified. http://www.thunderhead.com/rss/rss.php Error! Filename not specified. http://www.youtube.com/user/ThunderheadOn Error! Filename not specified. http://thunderheadinnovate.wordpress.com/ Error! Filename not specified. http://thunderhead.com/about/careers.php The contents of this e-mail