itext7

itext 7.1 how to check if image is rotated

倖福魔咒の 提交于 2020-01-14 05:50:09
问题 in itext 7.1, I am adding an image to a pdf document with following code : Document document = new Document(writerPdf); //make a new document object ImageData imgData = ImageDataFactory.create(imageBytes); Image image = new Image(imgData); document.add(image); This works fine for most images but I have come across an image that seems normal on desktop but when adding to pdf it is rotated by -90 . imgData.getRotation() gives 0 as output My question is : how to check if image has any rotation

Append mode requires a document without errors, even if recovery is possible

只谈情不闲聊 提交于 2020-01-13 07:07:35
问题 The PDF which I signed with append mode is exported from Office Word 2016. Here is my file : word.pdf And I got this error message: com.itextpdf.kernel.PdfException: Append mode requires a document without errors, even if recovery is possible. I am using iText7 7.0.4 . 回答1: The document you are trying to change in append mode is broken. Most likely, the byte offsets as defined in the cross-reference table don't correspond with the actual byte positions of the PDF objects. In your case, I see

iText 7 PDF accessibility: “Table header cell has no associated subcells”

僤鯓⒐⒋嵵緔 提交于 2020-01-11 04:10:14
问题 I am converting HTML to a PDF using iText 7. I need the PDF to be accessible (508 compliant with appropriate tags, etc), but, no matter what markup I put on a table, accessibility checkers give the same error: "Table header cell has no associated subcells". I've tried setting scope, headers, etc... nothing seems to work. Here is an example of one of the tables but all of them have the same issue: <table class="problems" summary="Patient's diagnosed problems and associated ICD codes."> <thead>

Need iText7 HTML to PDF Encryption Code in C#

强颜欢笑 提交于 2020-01-07 03:48:58
问题 I Have Installed iText7 trail Version Packages to convert html file into pdf. I have succefully converted html to pdf using proper code like they(iText Software) mentioned.But still i am not clear to set the Password for created pdf. After converting html file to pdf,the pdf file should be protected with password.so please anyone help me what is the code in c# to encrypt the pdf file while converting from html. 回答1: You didn't share any code (which is actually a requirement when you post a

iText “Coordinate outside allowed range” exception using LocationTextLocationStrategy

风格不统一 提交于 2020-01-06 08:45:06
问题 An exception "Coordinate outside allowed range" is thrown when I try to use LocationTextExtractionStrategy . for (int pageNum = 1; pageNum <= document.getNumberOfPages(); pageNum++) { PdfPage page = document.getPage(pageNum); sb.append(PdfTextExtractor.getTextFromPage(page, new LocationTextExtractionStrategy())); } More information about the exception: java.lang.IllegalStateException: Coordinate outside allowed range at com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperBase.rangeTest

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

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 =

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