flying-saucer

Generation of PDF from HTML with non-Latin characters using ITextRenderer does not work

牧云@^-^@ 提交于 2019-12-12 07:48:47
问题 This is the 2nd day I spend investigating with no results. At least now, I am able to ask something very specific. I am trying to write a valid HTML code that contains some non-Latin characters in a PDF file using iText and more specifically using ITextRenderer from Flying Saucer. My short example/code starts by initializing a string variable doc with this value: String doc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">" + "<body>Some

Grails Render PDF Plugin returns NullPointerException

我怕爱的太早我们不能终老 提交于 2019-12-12 03:22:59
问题 I'm trying to render a pdf file with render plugin. My controller code is: def toPDF(){ DomainClass domainClass = DomainClass.get(params.id) try{ renderPdf(template: "/domainClass/pdf", model: [domain: domainClass], filename: System.currentTimeMillis().toString() + "_" + domainClass.id.toString() + ".pdf") }catch(e){ redirect action: "error" } } In development mode, it works properly. But in production, this action throws NullPointerException 2015-01-30 11:51:40,393 [http-apr-8080-exec-48]

IText 2 + Flying Saucer: how to avoid that the images appears broken between two pdf's pages?

痴心易碎 提交于 2019-12-11 08:47:20
问题 i have an html file and i'm using Itext 2 with flying Saucer to convert it to a pdf file. The problem is that if an image starts near the page end, flying saucer render a portion of it it the end of the current page and the rest in the beginning of the next page. How to say that i want the entire image on one page only? 回答1: You can add this to your print css: img { page-break-inside: avoid; } The user guide (PDF) mentions it. 回答2: There appears to be a bug in FlyingSaucer that is causing

xhtmlrenderer creating PDFs of length 0

橙三吉。 提交于 2019-12-11 05:42:38
问题 I am new to org.xhtmlrenderer.pdf.ITextRenderer and have this problem: The PDFs that my test servlet streams to my Downloads folder are in fact empty files. The relevant method, streamAndDeleteTheClob , is shown below. The first try block is definitely not a problem. The server spends a lot of time in the second try block. No exception thrown. Can anyone suggest a solution to this problem or a good approach to to debugging it? Can anyone point me to essentially similar code that really works?

Huge white space after header in PDF using Flying Saucer

ε祈祈猫儿з 提交于 2019-12-10 20:46:30
问题 I am trying to export an HTML page into a PDF using Flying Saucer. For some reason, the pages have a large white space after the header (id = "divTemplateHeaderPage1") divisions. The jsFiddle link to my HTML code that is being used by PDF renderer: https://jsfiddle.net/Sparks245/uhxqdta6/. Below is the Java code used for rendering the PDF (Test.html is the same HTML code in the fiddle) and rendering only one page. import java.io.IOException; import javax.servlet.ServletException; import javax

How can i make my html page to be fit in the pdf using Flying Saucer

ε祈祈猫儿з 提交于 2019-12-10 18:03:00
问题 I am using Flying Saucer to convert XHTML page to PDF. My XHTML page width is little longer. When I create the PDF, 10% right portion of the XHTML file is missing in PDF. How can i make my XHTML page to be fit in the PDF? 回答1: You can use the @page rule. please take a look at following FS documentation: How do you control page size? How do you control page size on PDF output? How do you control page margins on PDF output? 来源: https://stackoverflow.com/questions/14066964/how-can-i-make-my-html

Flying Saucer iTextPDF Chinese Fonts

ぃ、小莉子 提交于 2019-12-10 17:23:37
问题 I'm using FlyingSaucer (R8pre2 version) to convert an XHTML into PDF. The HTML has Chinese characters and are using MS Mincho fonts. The document was converted, but all the Chinese characters are missing on the converted PDF. Any idea how to resolve this problem? Code: OutputStream os = new FileOutputStream("output.pdf"); String inputFile = "input.html"; String url = new File(inputFile).toURI().toURL().toString(); ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(url);

Is it possible to resolve css as a classpath resource using Flying Saucer (XHTML-Renderer)?

末鹿安然 提交于 2019-12-10 17:01:58
问题 I'm trying to package up resources into a jar, but I'm having trouble getting Flying Saucer to find the css on the classpath - I can't construct a URL easily to be able to resolve this seamlessly. Does Flying saucer have a way of specifying resource packages on the classpath to resolve items and images? Note: I'm running this in a webstart application that does not have file system writing permissions, so jar expansion is not really an option. 回答1: You should implement a UserAgentCallback

Arabic problems with converting html to PDF using ITextRenderer

谁说胖子不能爱 提交于 2019-12-10 12:14:36
问题 When I use ITextRenderer converting html to PDF.this is my code ByteArrayOutputStream out = new ByteArrayOutputStream(); ITextRenderer renderer = new ITextRenderer(); String inputFile = "C://Users//Administrator//Desktop//aaa2.html"; String url = new File(inputFile).toURI().toURL().toString(); renderer.setDocument(url); renderer.getSharedContext().setReplacedElementFactory( new B64ImgReplacedElementFactory()); // 解决阿拉伯语问题 ITextFontResolver fontResolver = renderer.getFontResolver(); try {

Edit HTML Document with Java

泄露秘密 提交于 2019-12-10 11:25:10
问题 I have an HTML document stored in memory (set on a Flying Saucer XHTMLPanel) in my java application. xhtmlPanel.setDocument(Main.class.getResource("/mailtemplate/DefaultMail.html").toString()); html file below; <html> <head> </head> <body> <p id="first"></p> <p id="second"></p> </body> </html> I want to set the contents of the p elements. I don't want to set a schema for it to use getDocumentById(), so what alternatives do I have? 回答1: XHTML is XML, so any XML parser would be my