itext

IText: registering font: not found as file or resource

拥有回忆 提交于 2019-12-24 19:38:49
问题 I am developing on windows plattform. My maven project has the following structure for font resources: src/main/resources/package/name/fonts I try to register a font as following: FontFactory.register("package/name/fonts/fontname.otf"); But I get the error: package/name/fonts/fontname.otf not found as file or resource What is my failure? Thank you 回答1: First I get the correct path with getResource(): String pathtofont = "/package/name/fonts/fontname.otf"; String fontname = myworkingclass

IText7 html2pdf footer CSS does not work

♀尐吖头ヾ 提交于 2019-12-24 19:16:11
问题 I am not able to see footer in resultant PDF for below HTML and CSS. This code works fine with IText version 2 . Does the way to show header and footer is changed in IText version 7 ? or am I missing any configuration required for newer version? Thanks. Java code public void createPdf(String src, String dest, String resources) throws IOException { try { FileOutputStream outputStream = new FileOutputStream(dest); WriterProperties writerProperties = new WriterProperties(); //Add metadata

iText PdfTextExtractor getTextFromPage exception “Error reading string at file pointer”

China☆狼群 提交于 2019-12-24 19:15:26
问题 I am using iText PdfTextExtractor to extract text from the PdfReader, where the PdfReader is created from a byte array, byte[] pdfbytes = outputStream.toByteArray(); PdfReader reader = new PdfReader(pdfbytes); int pagenumber = reader.getNumberOfPages(); PdfTextExtractor extractor = new PdfTextExtractor(reader); for(int i = 1; i<= pagenumber; i++) { System.out.println("============PAGE NUMBER " + i + "=============" ); String line = extractor.getTextFromPage(i); System.out.println(line); } The

c# iTextsharp generated PDF with xmlworker is breaking Lists

人盡茶涼 提交于 2019-12-24 19:06:38
问题 I am using iTextsharp library with XmlWorker version 5.5.12.0, and facing problems with list is enclosed with DIV. <body> <span> <ul> <ul> <li>Project Management <ul> <li> <a class="jwiki-small" data-containerid="2544" data-containertype="14" data-objectid="14695" data-objecttype="102" href="https://SampleUrl.com/DOC-146">Sample Text</a> </li> </ul> </li> </ul> </ul> </span> </body> and the pdf looks correct like the image below. But Formatting problems start once List is enclosed in a Div at

Spring pdf generation

∥☆過路亽.° 提交于 2019-12-24 19:04:16
问题 I am using spring 3 AbstractPdfView in order to generate PDF files. I noticed Spring does not use the new version of iText (5.x.x) but uses an older version (2.1.7). Why does spring does not use the new package? Where can I find documentation for the old package? I don't seem to find it anywhere. 回答1: There is an other big problem with the newer versions of IText: they changed the licence. the old IText was LGPL or Mozilla Public License (till Java 2.1.7 and C# 4.1.6) the actual IText is: GNU

How to make PDF with turning page ability?

走远了吗. 提交于 2019-12-24 18:10:02
问题 In one of the weirdest client's requirement we need to devlop a functionality to generate a pdf document from java program(i did it with iText). But the view of pdf is problem. The client wants pdf generated in such a way that, it should have functionality of turning the page like we do in html using css. The book view of the pdf. I know this is weird and can't be done as we need to change the functionality of Adobe Reader itself. Kindly let me know it it is possible if yes then HOW 回答1: I'm

Read roman page number of page

ε祈祈猫儿з 提交于 2019-12-24 17:15:37
问题 in Adobe Reader the first pages of a ebook can have roman format page number as shown in attached image below Image : http://i.stack.imgur.com/GSm0Q.jpg I would like to read these page numbers out (not the indexed page number) with iText but I don't know which properties (labels or annotations..) I should use. I could already open file with PdfReader, loop through all pages but have no idea what I should access for these roman numbers using (Stream pdfStream = new FileStream(sourceFileName,

PDF-Checkbox - check one and uncheck another without JavaScript

混江龙づ霸主 提交于 2019-12-24 15:33:19
问题 in my project I need 3 checkboxes which should work like radiobuttons. But radiobuttons have some drawbacks with appearance in Adobe Reader. For this reason I have to use checkboxes. There is a very interesting answer, but I don't understand how this can be done with iText: Java iText and custom Radiobutton behaviour Can anybody -- especially Lonzak, the author of this posting -- help me in this case. Thanks and Kind regards, Dirk 回答1: I think the solution is to fix your current code. The

Setting BaseFont parameters back to default after bold

时间秒杀一切 提交于 2019-12-24 14:38:38
问题 I am using absolute positioning when writing text in a PDF document using iTextSharp. It can only deal with BaseFont and it is not possible to set a Bold decoration on a base font. I read in a post that this was the way to set the font to bold: pdfContentByte.SetCharacterSpacing(1); pdfContentByte.SetRGBColorFill(66, 00, 00); pdfContentByte.SetLineWidth((float)0.5); pdfContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE); That worked but created a another problem. I

How to add a PdfPTable to the HTML string in a document at (x,y) location using iText?

雨燕双飞 提交于 2019-12-24 14:20:01
问题 I am doing html to pdf conversion using iText . I am already using HTMLWorker class (deprecated) having the following content code: String htmlString = "<html><body> This is my Project <table width= '50%' border='0' align='left' cellpadding='0' cellspacing='0'><tr><td>{VERTICALTEXT}</td></tr></table></body></html>"; OutputStream file = new FileOutputStream(new File("C:\\Test.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); HTMLWorker