flying-saucer

ITextRenderer: Adjust page height to content

寵の児 提交于 2019-12-09 16:21:54
问题 I'm using ITextRenderer to generate a PDF from HTML and what I need to do is a cash register receipt. This receipt has dynamic width and, of course, dynamic content. This said, the height of content will always be different and right now I'm struggling to find a way of adjusting the height of the PDF page to the content. If it's too big the receipt has a long white section in the end and if it's to short the PDF get's paginated and I need it to be in one page only. I'm using @page {size: Wpx

Render image from servlet in flyingsaucer generated pdf

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 23:49:41
问题 I'm using flyingsaucer to render an xhtml document to pdf through a servlet which returns the generated pdf document. The xhtml document features an image which is requested from another servlet. The image servlet checks who is logged in before returning the appropriate image. The code below shows how the image is requested: <img height="140" width="140" src="http://localhost:8080/myapp/servlet/DisplayPic" /> My problem is that the http request for the image is from the pdf renderer and not

Resolving protected resources with Flying Saucer (ITextRenderer)

会有一股神秘感。 提交于 2019-12-08 21:36:33
问题 I'm using Flying Saucer to create a pdf from xhtml, hosted on a tomcat server. Most of the images included in the pdf are publicly available (logos and so on), but some of them are protected behind a login (that is, they are streamed through a servlet if the user is logged in). When I paste the url in the browser, the image is of course displayed fine, because the browser sends the session with the request. But when Flying Saucer renders the pdf, it doesn't include the protected image because

How to protect pdf report with password using thymeleaf as template engine and flying-saucer as rendrer

大憨熊 提交于 2019-12-08 20:31:53
问题 PDF is generating successfully but I want to protect it with a password. flying-saucer-pdf doc does not help me. I am using this example Using thymeleaf+flying-saucer-pdf+Spring Boot 回答1: To set password in PDF with Flying Saucer PDF Creator use PDFEncryption class. To set password to your PDF, First create an instance of PDFEncryption and then use its method setUserPassword() like this: final File outputFile = File.createTempFile(fileName, ".pdf"); FileOutputStream os = new FileOutputStream

FlyingSaucer renderer.setDocument throws “Stream closed” exception

孤人 提交于 2019-12-08 19:16:45
问题 I am having problems with creating a PDF using the simple example found here. It is my first time trying to use it and I have tried a few things and lots of searching but haven't found a reason why the error is generating. The error originates on the renderer.setDocument(url); line. If anyone has any ideas, suggestions or alternatives it would be greatly appreciated. package flyingsaucerpdf; import java.io.*; import com.lowagie.text.DocumentException; import org.xhtmlrenderer.pdf

iText Flying Saucer pdf headers and ignoring html

戏子无情 提交于 2019-12-07 22:01:34
问题 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

embaded images are breaked between pdf pages in flaying-saucer

别来无恙 提交于 2019-12-07 13:30:37
问题 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

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

耗尽温柔 提交于 2019-12-07 13:02:37
问题 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

Turning on Flying Saucer java.util.logging Output

大憨熊 提交于 2019-12-07 05:44:01
问题 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. 回答1: Found it: System.getProperties().setProperty("xr.util-logging.loggingEnabled", "true"); XRLog.setLoggingEnabled(true); 来源: https://stackoverflow

Reference is not allowed in prolog

早过忘川 提交于 2019-12-07 05:15:10
问题 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>