flying-saucer

Convert HTML page containing Arabic characters to PDF using FlyingSaucer

空扰寡人 提交于 2019-12-07 01:15:31
问题 I want to convert an HTML page that contains Arabic characters to a PDF file using FlyingSaucer, but the generated PDF does not contain combined characters and prints the output backwards. HTML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body style="font-size

Edit HTML Document with Java

北城余情 提交于 2019-12-06 12:44:31
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? rolfl XHTML is XML, so any XML parser would be my recommendataion. I maintain the JDOM library , so would naturally recommend using that, but other libraries,

iText Flying Saucer pdf headers and ignoring html

僤鯓⒐⒋嵵緔 提交于 2019-12-06 09:39:01
We use xhtml to pdf with good success, but a new requirement came up to have headers and page count on every page. We are using newset release of Flying Saucer. I followed example here: http://today.java.net/pub/a/today/2007/06/26/generating-pdfs-with-flying-saucer-and-itext.html#page-specific-features ...but this would not work. The header would be top left on first page. If I use the r7 version, headers and page numbering works perfectly, but none of the passed in html is rendered, whilst in r8 the headers\ page numbers are ignored, but the html is rendered perfectly. xHTML used for tests is

flying-saucer/iText PDF in servlet not finding css file

送分小仙女□ 提交于 2019-12-06 07:52:51
问题 A code snippet is at the bottom of the question I am successfully able to render a PDF in the client's browser using a servlet and flying-saucer/iText. However, I can't figure out how to get the style sheet included in the PDF rendering. I've tried the following and none have worked thus far: getServletContext().getRealPath("/PDFservlet.css") and putting "PDFservlet.css" at the web root directory buf.append("<head><link rel='stylesheet' type='text/css' href='PDFservlet.css' /></head>") and

PDF created on HTTP request won't open in Internet Explorer

本小妞迷上赌 提交于 2019-12-06 05:35:19
问题 I've got servlet that makes a PDF on the fly to the response, based on some parameters on the request. When I try to open/download this file in IE I get the following message: "Unable to download [filename] from [site]. Unable to open this Internet site. The requested site is either unavaliable or cannot be found. Please try again later." This is what i set to the response: response.setHeader("Content-Disposition", "attachment;filename=" + title + ".pdf"); response.setContentType("application

image not displaying in PDF template using Spring Boot, flying saucer and Thymeleaf

房东的猫 提交于 2019-12-06 04:05:30
I create a file pdf from html template using Spring Boot, flying saucer, thymeleaf. But image is not displaying in my file. Project structure: code html: <div class="col-xs-6 invoice-col-2"> <img src="../static/images/mastercard.png" alt="mastercard"></img> </div> When I change img tag to: <img src="../static/images/mastercard.png" alt="mastercard" th:src="@{static/images/mastercard.png}"></img> When I create PDF file, I get an error: org.thymeleaf.exceptions.TemplateProcessingException: Link base "static/images/mastercard.png" cannot be context relative (/) or page relative unless you

What's the easiest way of converting an xhtml string to PDF using Flying Saucer?

梦想的初衷 提交于 2019-12-06 01:04:19
问题 I've been using Flying Saucer for a while now with awesome results. I can set a document via uri like so ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(xhtmlUri); Which is nice, as it will resolve all relative css resources etc relative to the given URI. However, I'm now generating the xhtml, and want to render it directly to a PDF (without saving a file). The appropriate methods in ITextRenderer seem to be: private Document loadDocument(final String uri) { return

embaded images are breaked between pdf pages in flaying-saucer

被刻印的时光 ゝ 提交于 2019-12-05 20:01:57
I have some problem with images (all images are embedded in html as base64 strings). I use css img {page-break-inside: avoid;} and it helps but not always. In some cases the same image can be processed correctly where in other situation is divided between pages. It depends form many factors, examples: image is assigned as block element previous images are or are not block elements there is some big image before divided one I also noticed that if the problem occurred at least once than all images to the end of document can be broken when they don't fit on the page. I'm using this approach with

Turning on Flying Saucer java.util.logging Output

让人想犯罪 __ 提交于 2019-12-05 11:11:06
I'm compiling a PDF using iText and Flying Saucer, and unfortunately, I can't seem to get any output from Flying Saucer when compiling. I'd really like to be able to see what's going on internally so as to be able to debug the current problem I'm facing. How can I turn on java.util.logging for Flying Saucer? I'm currently using SLF4J/Logback. Found it: System.getProperties().setProperty("xr.util-logging.loggingEnabled", "true"); XRLog.setLoggingEnabled(true); 来源: https://stackoverflow.com/questions/9729147/turning-on-flying-saucer-java-util-logging-output

Reference is not allowed in prolog

允我心安 提交于 2019-12-05 10:55:27
Please help me to find the reason for this exception ,am using following jars, core-renderer.jar itext-paulo-155.jar firstdoc.xhtml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My First Document</title> <style type="text/css"> b { color: green; } </style> </head> <body> <p> <b>Greetings Earthlings!</b> We've come for your Java. </p> </body> </html> JAVA : import java.io.File; import java.io.FileOutputStream; import java.io.IOException