xmlworker

Converting HTML to PDF using iText

橙三吉。 提交于 2020-06-09 05:37:38
问题 I am posting this question because many developers ask more or less the same question in different forms. I will answer this question myself (I am the Founder/CTO of iText Group), so that it can be a "Wiki-answer." If the Stack Overflow "documentation" feature still existed, this would have been a good candidate for a documentation topic. The source file: I am trying to convert the following HTML file to PDF: <html> <head> <title>Colossal (movie)</title> <style> .poster { width: 120px;float:

itext XMLWorkerFontProvider.DONTLOOKFORFONTS and generate multi language HTML page

亡梦爱人 提交于 2020-01-05 04:54:07
问题 Can someone help to explain what is XMLWorkerFontProvider.DONTLOOKFORFONTS for? Not much explainations in the apidoc. Also, I have seen some examples on XMLWorkerFontProvider.DONTLOOKFORFONTS, mostly used with XMLWorkerFontProvider.register("font file path") to generate multi language file for known text / fonts, in the case where the text is dynamic (i.e.: can be a mixture of any language ), how should this be handled? I tried to register all the google noto fonts that can support a lot of

How to avoid to tag the the empty <TR<TD> cells to PDF using Itext 5

依然范特西╮ 提交于 2020-01-05 03:56:04
问题 I an using i text 5 to generate the PDF from html as input . As part of PDF accessibility,adding pdfwriter.settagged(). But here all the empty and non-empty tags are tagging .can you please help how to avoid to tagging the non empty html tags 回答1: I suppose one way to go around it, would be to go through the StructTree on the output PDF document, and try to find the tag you are looking for, without any kids, and remove it from the parent. I do not use iText 5 anymore, as it has been

iTextPdf 5.5.1 - Converting large HTML to single Page PDF with Custom fonts

纵然是瞬间 提交于 2020-01-03 06:05:13
问题 I am having HTML document including CSS Styles. I want to create one pdf file with custom fonts and the height as per the document contents. I followed this implementations Adjust page size based on amount of HTML data But it wants separate HTML and CSS. I provide it whole document string as HTML and left the CSS String null. It gave me exception. Moreover if there is any examples to implement custom fonts in Java Please help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:/

How to generate a valid PDF/A file using iText and XMLWorker (HTML to PDF/A process)

感情迁移 提交于 2019-12-31 00:45:35
问题 I'm currently developing a method that will accept HTML input and convert it into a valid PDF/A file. I know how to programmatically construct a valid PDF/A file using iText (reference: http://itextsupport.com/download/pdfa3.html) but I'm unable to generate a valid PDF/A file using HTML as input and using XMLWorker to transform this input into a PDF file. The problem that I have right now is due to the embedded fonts requirement of the PDF/A format. I always get this exception: Exception in

How to create a PDF with iText+XMLWorker from servlet using custom font?

元气小坏坏 提交于 2019-12-30 07:31:33
问题 Playing with iText/XMLWorker samples (mostly this one), I could easily write simple applications able to create PDF files from HTML code using my own extra fonts, but as soon as tried to use my stuff in some web service code, I ended with exceptions like: Table 'name' does not exist in file:/C:/work/MyServer/target/classes/fonts/My%20Font.ttf ExceptionConverter: com.itextpdf.text.DocumentException: Table 'name' does not exist in file:/C:/work/MyServer/target/classes/fonts/My%20Font.ttf ..

How to create a PDF with iText+XMLWorker from servlet using custom font?

霸气de小男生 提交于 2019-12-30 07:31:32
问题 Playing with iText/XMLWorker samples (mostly this one), I could easily write simple applications able to create PDF files from HTML code using my own extra fonts, but as soon as tried to use my stuff in some web service code, I ended with exceptions like: Table 'name' does not exist in file:/C:/work/MyServer/target/classes/fonts/My%20Font.ttf ExceptionConverter: com.itextpdf.text.DocumentException: Table 'name' does not exist in file:/C:/work/MyServer/target/classes/fonts/My%20Font.ttf ..

How can I use iText to convert HTML with images and hyperlinks to PDF?

佐手、 提交于 2019-12-29 00:47:13
问题 I'm trying to convert HTML to PDF using iTextSharp in an ASP.NET web application that uses both MVC, and web forms. The <img> and <a> elements have absolute and relative URLs, and some of the <img> elements are base64. Typical answers here at SO and Google search results use generic HTML to PDF code with XMLWorkerHelper that looks something like this: using (var stringReader = new StringReader(xHtml)) { using (Document document = new Document()) { PdfWriter writer = PdfWriter.GetInstance

RTL not working in pdf generation with itext 5.5 for Arabic text

筅森魡賤 提交于 2019-12-28 04:32:26
问题 I have java code that writes arabic characters with the help of itext 5.5 and xmlworker jars, but its writing left to right even after writer.setRunDirection(PdfWriter.RUN_DIRECTION_RTL) is used. Code used is: public class CreateArabic extends DefaultHandler { /** Paths to and encodings of fonts we're going to use in this example */ public static String[][] FONTS = { {"C:/arialuni.ttf", BaseFont.IDENTITY_H}, {"C:/abserif4_5.ttf", BaseFont.IDENTITY_H}, {"C:/damase.ttf", BaseFont.IDENTITY_H}, {

iText -PDF reading issue on heading levels ( h1 - h6 )

被刻印的时光 ゝ 提交于 2019-12-25 07:41:18
问题 Generated PDF by iText-XMLWorker 5.5.4. Everything is reading perfectly except heading levels (h1-h6) in screen reader. Below code works fine on browsers but not in PDF. <section> <h1>heading 1</h1> <h2>heading 2 </h2> <h3>heading 3 </h3> <h4>heading 4 </h4> </section> 回答1: Please take a look at the ParseHeaders example. It takes the headers.html page with headers from <h1> to <h2> and converts it to headers.pdf: In your question, you claim that everything is working perfectly except heading