itext

External Font is not getting applied to SVG content inside HTML after it gets generated to PDF using IText 7

北城余情 提交于 2020-01-06 06:42:19
问题 I am using IText 7.1.6 version to generate a PDF Report from the HTML source. I am able to generate the PDF report successfully. I have a small issue with external font-family like TREBUC.TTF not getting applied to one of the reports which contain SVG element in HTML source. Fonts are getting applied to all other elements like header, footer and other texts in the HTML source. I tried to add the custom TagWorkerFactory and CSS applier factory for the SVG but there is no luck. Can anyone

PdfContentStreamEditor rotating image on PDF file

余生颓废 提交于 2020-01-06 06:35:20
问题 I have what I hope is an easy question. I'm trying to use iTextSharp to modify some PDF files, however it seems that the XMP metadata that iTextSharp puts at the end of the files is ruining the layout of the PDF files (and I'm not very conversant in the PDF format to understand at all why). You can see from the two images above that the document appears to have been rotated. From looking at the PDF files as binary differences however, the only thing different appears to be some XMP metadata

itext 7 html to pdf with page size detection

十年热恋 提交于 2020-01-06 06:10:52
问题 I am using itext 7 to render HTML templates (Velocity) to PDF, then to PNG (Apache PdfBox), for thermal printer printing. My template is rendered as : <html> <head> <style>...</style> </head> <body> <div id="container">...</div> </body> </html> My container has a fixed width to 512px. I would like to measure the rendered height of the html, and then render it as a single page PDF with page height = measured height. But the rendered size is not the expected size. I expect to have a rendered

itext 7 html to pdf with page size detection

倖福魔咒の 提交于 2020-01-06 06:10:15
问题 I am using itext 7 to render HTML templates (Velocity) to PDF, then to PNG (Apache PdfBox), for thermal printer printing. My template is rendered as : <html> <head> <style>...</style> </head> <body> <div id="container">...</div> </body> </html> My container has a fixed width to 512px. I would like to measure the rendered height of the html, and then render it as a single page PDF with page height = measured height. But the rendered size is not the expected size. I expect to have a rendered

itext7 end_page events are called when document is closed

旧城冷巷雨未停 提交于 2020-01-06 06:01:43
问题 I am trying to follow the example given in https://developers.itextpdf.com/examples/page-events/clone-page-events-headers-and-footers#2656-variableheader.java to create a PDF document with variable header. But the events are not fired correctly. Here is the code I have tested with - class Program { public static String DEST = "test.pdf"; static void Main(string[] args) { Console.WriteLine("Hello World!"); manipulatePdf(DEST); } public static List<int> getFactors(int n) { List<int> factors =

I don't understand why PdfReader.ComputeUserPassword() is returning null

流过昼夜 提交于 2020-01-06 05:56:12
问题 I am trying to receive the user's password from a PDF file. For testing purposes I'm given both, the master's and user's password. Right now I am passing the master's password in a parameter and use it to create a new instance of iTextSharp.text.pdf.PdfReader which works fine. Then I'm entering an if-clause which should return whether the PDF is being opened with full permissions or not. Inside this if-clause I request the user's password by calling iTextSharp.text.pdf.PdfReader

Concatenate tagged PDF files using the older version iText 4.2.0

我的未来我决定 提交于 2020-01-06 05:30:11
问题 I am maintaining the code which is using older version iText 4.2. Now, I am trying to merging multiple tagged PDF files into one using following codes: Document document = new Document(); PdfCopy copy = new PdfCopy(document, new FileOutputStream(RESULT)); document.open(); PdfReader reader; int n; for (int i = 0; i < files.length; i++) { reader = new PdfReader(files[i]); n = reader.getNumberOfPages(); for (int page = 0; page < n; ) { copy.addPage(copy.getImportedPage(reader, ++page)); } copy

How can i convert HTML with SVG content to PDF using IText PDF Api?

我的梦境 提交于 2020-01-06 04:46:06
问题 I have a requirement to convert HTML with SVG Content to PDF using Itext. I am using latest Itext version along with Html2Pdf jar. I tried to implement but the generated PDF does not render the SVG content properly. The SVG content is messed up. I do not have any control on SVG content generation in PDF. I have pasted the implementation code and sample HTML below . Can anyone please let me know how can I achieve it ? Here is the test code import java.io.ByteArrayOutputStream; import java.io

java.lang.ClassNotFoundException: org.bouncycastle.asn1.ASN1Encodable

爷,独闯天下 提交于 2020-01-06 04:19:12
问题 I am using IText 4.2.0 and bcprov-jdk15-1.43.jar and bctsp-jdk15-1.43.jar for signing pdf. I added these jars by add external jars button in Eclipse. When I execute it gives me following error. ExceptionConverter: java.lang.Exception: Failed to get TSA response from tsaURL at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:185) at com.lowagie.text.pdf.TSAClientBouncyCastle.getTimeStampToken(TSAClientBouncyCastle.java:136) at com.lowagie.text.pdf

Prevent copying pdf contents generated using iText

好久不见. 提交于 2020-01-06 04:06:07
问题 We have a web application which generates a report and saves it in pdf using iText. We want to prevent user from copying the contents from this file. I thought this can be achieved by converting pdf contents to image and then add that image to pdf but it seems iText cannot convert pdf to an image. Is there a way I can do this using iText? 回答1: As @YuriyGalanter indicated, restrictive permissions in PDFs are primarily defined in the context of encryption in PDFs, cf. section 7.6.3.1 of the PDF