xhtmlrenderer

Render embedded image in PDF using Flying-Saucer from html

流过昼夜 提交于 2019-12-22 04:40:57
问题 I have an xhtml document that I'm turning into a PDF using flyingsaucer. The xhtml has several tags that have a base64 encoded images inline. The source of the xhtml is dynamic so the structure of where the image tags are can vary. This is a sample of what the tag looks like: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAagAAAEuCAYAAADbW4YFAAAgAElEQVR4Aex9CYBdRZ ... When I look at the html in a browser, the image appears correctly, however, the img element doesn't get rendered in

Bookmarks with xhtmlrenderer (iText)

心已入冬 提交于 2019-12-13 01:13:16
问题 I'm using xhtmlrenderer (Also known as Flying Saucer) with iText to convert HTML to PDF. How would I create bookmarks with this? Does someone with have a small example? Thanks in advance. 回答1: It seems bookmarks were added in R6, but the user guide only gives them a passing reference. with a TODO to the author to add an example later. Searching the forums, I found this example: <html> <head> <bookmarks> <bookmark name="A bookmark" href="#bm" /> <bookmark name="A bookmark 2" href="#bm2" />

How to convert url of html page to pdf in java using iText & flying saucer?

旧巷老猫 提交于 2019-12-12 11:12:57
问题 I've just downloaded xhtmlrenderer and iText jar files. I can make pdf files by using these jars. What I exactly want is: I need to create pdf if I give one valid URL (say " https://xhtmlrenderer.dev.java.net/news.html ") in the place of "inputFile". Is it possible with flying saucer and iText? If yes, please guide me to achieve this. Also, when I'm trying to run the below code, I'm getting error: stream closed import java.io.*; import com.lowagie.text.DocumentException; import org

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?

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

FlyingSaucer LTR/RTL/BiDi issue with arabic text

我的未来我决定 提交于 2019-12-09 11:24:19
问题 I'm using flying saucer xhtmlrenderer for building pdf documents. Everything worked fine until now - now we should generate arabic text inside pdf. Xhtmlrenderer is rendering Arabic text in reverse order. I've read somewhere on internet (maybe on their own site) that xhtmlrenderer does not support bidi/rtl. But IText itself contains examples to work with arabic and hebrew via ColumnText and PdfPTable (sources can be found here: http://sourceforge.net/projects/itextpdf/files/Examples/examples

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

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

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

爱⌒轻易说出口 提交于 2019-12-04 05:20:43
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 _sharedContext.getUac().getXMLResource(uri).getDocument(); } public void setDocument(String uri) { setDocument