itext

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 flatten pdf with Itext in c#?

浪子不回头ぞ 提交于 2020-01-03 05:57:29
问题 I need to remove all form fields of a pdf, so I am using iText and try to flatten the pdf. Because of legacy code I am restricted to iText version 4.1.6.1 My Code is: public static byte[] RemoveAcroFields(String filename) { if (filename != null && File.Exists(filename)) { byte[] pdfFile = File.ReadAllBytes(filename); PdfReader reader = new PdfReader(pdfFile); MemoryStream stream = new MemoryStream(pdfFile); PdfStamper stamper = new PdfStamper(reader, stream); stamper.FormFlattening = true;

Data not printing correctly on PDF using iText

╄→尐↘猪︶ㄣ 提交于 2020-01-03 05:10:12
问题 Here's my XHTML: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <META content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table cellspacing="0" cellpadding="0" align="Center" style="table-layout: fixed; word-wrap: break-word; width: 97%" bordercolor="4f81BD" border="1"> <tbody> <tr style="color: white;"> <td height

retrieve the pkcs7 file from pdf and co-sign

心已入冬 提交于 2020-01-03 04:52:09
问题 I have a PDF file signed and .p7s file. I need retrieve .p7s from PDF and co-sign the PDF (generating other .p7s). After I need put again the p7s into PDF file. I get this error when I try get p7s from PDF: ExceptionConverter: java.security.SignatureException: object not initialized for signing My code: BouncyCastleProvider provider = new BouncyCastleProvider(); Security.addProvider(provider); PdfReader pdfReader = new PdfReader(Files.readAllBytes(inputFile.toPath())); AcroFields acroFields =

Linking pdfs of Portable Collection using Itext

血红的双手。 提交于 2020-01-03 04:42:11
问题 I have portable collection in that total of two pdf document is there. My requirement is that if I open one pdf document and click the link or any text, it should redirect to another pdf of that portable Collection. For example: Consider there are two pdfs inside a portable collection namely Programming.pdf and Java.pdf. If I click any particular text or variable inside Programming.pdf, it should redirect to Java.pdf. Is it possible...?. 回答1: To navigate between documents in a portable

PDFStamper fails on several PDF files (itext 5.5.1)

放肆的年华 提交于 2020-01-03 04:34:06
问题 I'm trying to fill PDF forms with data and got PDFStamper (itext version 5.5.1) to work with several PDF files, but on some it always fails. Sample code: PdfReader reader = new PdfReader(new FileInputStream("C:/Temp/source.pdf")); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("C:/Temp/temp.pdf")); stamper.close(); Two different error messages until now, first one: Exception in thread "main" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature

how to change header for every pdf page in android

こ雲淡風輕ζ 提交于 2020-01-03 04:28:12
问题 I created pdf page using itext in android application,need to add header and footer for pdf page and need to change header in every page. i did like for adding header and footer public class HeaderAddFooter extends PdfPageEventHelper { private Phrase footer; private Phrase header; private String patientName; private String patientID; Font headerFont = new Font(FontFamily.TIMES_ROMAN, 12, Font.NORMAL); Font footerFont = new Font(FontFamily.TIMES_ROMAN, 12, Font.NORMAL); Font TitleFont = new

How to rotate watermark (text) in PDF using iText?

丶灬走出姿态 提交于 2020-01-02 13:33:13
问题 I'm using iText for stamping a watermark (text: "SuperEasy You Done") on PDF files as described in How to watermark PDFs using text or images? (TransparentWatermark2.java). See project source code on GitHub. Now an example of the PDF I'm getting is this one (the rest of the document is omitted): As you can see the watermark is centered and horizontal. I'd like to keep it centered in the middle of the page, but rotate it "45" degrees , so it rotates anticlockwise. Something like this: This is

Attach random file to a pdf using itText

亡梦爱人 提交于 2020-01-02 12:42:24
问题 I am trying to attach files to a pdf document using iText. Files can be images, xml, txt, pdf, etc. Is it possible to do this? 回答1: You can use this method with src the path to the original document, dest the path to the newly created PDF, and attachments is an array of paths to the files you want to attach: public void addAttachments( String src, String dest, String[] attachments) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new

Attach random file to a pdf using itText

这一生的挚爱 提交于 2020-01-02 12:41:02
问题 I am trying to attach files to a pdf document using iText. Files can be images, xml, txt, pdf, etc. Is it possible to do this? 回答1: You can use this method with src the path to the original document, dest the path to the newly created PDF, and attachments is an array of paths to the files you want to attach: public void addAttachments( String src, String dest, String[] attachments) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new