itext7

In iText7, is there a way like iText5's calculateHeights method?

北城余情 提交于 2019-12-14 03:36:07
问题 In iText5, we can get the PdfPTable's height when we need "public float calculateHeights(boolean firsttime)". But in iText7, how can we get current table height value (especially before adding the table to its parent element)? I already tested "table.getHeight()" method, but it returns null. And I also found that in a table render object I can get this value, but the limitation is that the render need to be triggered when the table is adding into its parent element, so the time is not my need

IText 7 How To Add Div or Paragraph in Header Without Overlapping Page Content?

白昼怎懂夜的黑 提交于 2019-12-13 18:19:16
问题 I am facing the following problem for which i haven't found any solution yet. I am implementing a platform for a medical laboratory. They want for every incident to write the report to the system and then generate and print it from the system. I am using itext 7 to accomplish this. However i am facing the following problem. They have a very strange template. On the first page in the beginning they want to print a specific table, while in the beginning of every other page they want to print

What is the replacement for Chunk.NEWLINE in itext7

China☆狼群 提交于 2019-12-13 17:12:35
问题 Chunk.NEWLINE adds an new line in iText 5. But iText 7 do not support Chunk. How do I add a new line using iText 7? 回答1: Please refer to this answer about replacement of Chunk in iText7. Now to add a new line you should use new Text("\n") and put it to a paragraph. 来源: https://stackoverflow.com/questions/50818091/what-is-the-replacement-for-chunk-newline-in-itext7

itext7 exception License file was corrupted when trying to run free trial

谁说胖子不能爱 提交于 2019-12-13 16:05:39
问题 I am evaluating itext7 Html2pdf library. I registered for a free trial, downloaded the itextkey.xml license key and included it in my project. Here is the code I am using: public static readonly string destinationFile = @"C:\Test\Generated.pdf"; public static readonly string sourceHtml = @"C:\Test\djigit.html"; public static readonly string licenseKey = @"C:\Test\itextkey.xml"; static void Main(string[] args) { parsePdf(sourceHtml, destinationFile); } private static void parsePdf(string

iText 7 accessible PDFs from HTML: how do I avoid table tag when using display: table;

谁说胖子不能爱 提交于 2019-12-13 13:15:54
问题 I am working on an ASP.NET MVC project which converts a view to a PDF. Previously, Rotavia was used, but then a new client requirement is that the PDF be accessible/508-compliant. For layout purposes, the previous developer had a whole header section (logo, title, disclaimer, etc) as a table without th elements (just td). I needed to convert them to divs but keep the look the same. So, what I did was made them divs and then used the CSS properties, display: table, display: table-row-group,

Why don't the iText 7 form field values print?

我是研究僧i 提交于 2019-12-13 07:02:11
问题 I have a PDF with forms that was generated with iText 7. However, when I fill out the form and attempt to print, the form values do not show up; only the form outline shows. How do I generate form fields that will display the value when printed? A sample form generator: import java.io.FileNotFoundException; import java.io.IOException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.itextpdf.forms.PdfAcroForm; import com.itextpdf.forms.fields.PdfFormField; import com

Cannot copy indirect object from the document that is being written Java

无人久伴 提交于 2019-12-13 04:26:02
问题 I've created a method like this: public PdfDocument addBlankPage(final MediaModel pdfDocument) throws IOException { final InputStream inputStream = mediaService.getStreamFromMedia(pdfDocument); byte[] bytes = IOUtils.toByteArray(inputStream); final PdfReader reader = new PdfReader(new ByteArrayInputStream(bytes)); final PdfWriter writer = new PdfWriter(pdfDocument.getRealFileName()); final PdfDocument document = new PdfDocument(reader, writer); int index = document.getNumberOfPages(); final

iText - Read pdfs in a loop and merge one by one

旧时模样 提交于 2019-12-13 03:48:38
问题 I have a loop where I read a pdf file every time. And I want to add these pdf files into another final pdf. Basically merging all pdfs into one new pdf file. I tried following way : I tried to concatenate byteArrays inside the loop like ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); for (............){ outputStream.write(myInfo.getByteArray()); } pdfreader = new PdfReader(outputStream.toByteArray()); FileOutputStream fileout = new FileOutputStream(file); PdfStamper

Is the PdfWriter.getverticalposition() stopped in Itext 7?

£可爱£侵袭症+ 提交于 2019-12-13 03:29:39
问题 I am trying to add a IBlockElement at the end of the last page in the Itext 7 version my approach is After writing all the elements to the pdf document get the vertical position from the writer with writer.getVerticalPosition() Calculate the available space on the current page by using the bottomMargin as a reference. If space is less than the space required then add another blank page Create and insert a container of fixed height with text vertical alignment to bottom Add IBlockElement

Remove the first and last lines properties in the paper Itext7

♀尐吖头ヾ 提交于 2019-12-13 03:27:42
问题 I need to remove property in Text (setRise) , if t.setRise(+-) gets out of fields paper. PdfDocument pdfDoc = new PdfDocument(pdfWriter); Document doc = new Document(pdfDoc, PageSize.A5); doc.setMargins(0,0,0,36); for (int i = 0; i <50 ; i++) { Text t = new Text("hello " + i); if(i ==0){ t.setTextRise(7); } if(i==31){ t.setTextRise(-35); } Paragraph p = new Paragraph(t); p.setNextRenderer(new ParagraphRen(p,doc)); p.setFixedLeading(fixedLeading); doc.add(p); } doc.close(); } class