itextpdf

Itextpdf stop transform pdf correctly

微笑、不失礼 提交于 2019-12-23 02:13:12
问题 I have a next issue with itextpdf. private void generatePdf() throws Exception { FileOutputStream fos = null; try { PdfReader reader = new PdfReader("template.pdf"); fos = new FileOutputStream("test.pdf"); PdfStamper stamper = new PdfStamper(reader, fos); stamper.close(); } catch (Exception e) { throw e; } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { throw new Exception(e); } } } } This method have to read a template and save that to a new pdf. But if I looked

PDF Page re-ordering using itext

时光怂恿深爱的人放手 提交于 2019-12-17 10:05:50
问题 i am using itext pdf library. can any one know how can i move pages in existing pdf? Actually i want to move few last pages at beginning of file. It is something like below but i don't understand how it work. reader = new PdfReader(baos.toByteArray()); n = reader.getNumberOfPages(); reader.selectPages(String.format("%d, 1-%d", n, n-1)); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(filename)); stamper.close(); Can any one explain in detail? 回答1: The selectPages() method is

Using iTextPDF to trim a page's whitespace

帅比萌擦擦* 提交于 2019-12-17 02:26:00
问题 I have a pdf which comprises of some data, followed by some whitespace. I don't know how large the data is, but I'd like to trim off the whitespace following the data PdfReader reader = new PdfReader(PDFLOCATION); Rectangle rect = new Rectangle(700, 2000); Document document = new Document(rect); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(SAVELCATION)); document.open(); int n = reader.getNumberOfPages(); PdfImportedPage page; for (int i = 1; i <= n; i++) { document

Divide page in 2 parts so we can fill each with different source

喜你入骨 提交于 2019-12-14 02:24:48
问题 I need to create an User guide, where I've to put the content in 2 different language but on the same page. so the first half of the page would be in English while the second part would be in French. (In future they might ask for 3rd language also, but maximum 3). So each page would have 2 blocks. How can I achieve this using iTextPDF in java ? UPDATE Following is the structure for more insight of the question. 回答1: If I understand your question correctly, you need to create something like

Fill the dynamic data with each row columns by column Using iText in Java

此生再无相见时 提交于 2019-12-13 10:08:50
问题 Hi Every One I've a pdf report generated with iText containing a PdfPTable added to MultiColumnText, sometimes becomes so large that it will be split on more than one page, Here am added sample Code, Its working as Page -1 --------------------------------------------------------------------------------------------------------------------------------------------------+ | 1st - Emp1-NO | 2nd - Emp1-Name| 3rd - Emp1-Desig | | 4th - Emp2-NO | 5th - Emp2-Name| 6th - Emp2-Desig | | 7th - Emp3-NO |

After generating pdf file how to save dynamic name for this pdf? [closed]

早过忘川 提交于 2019-12-13 08:16:18
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I generate a PDF document using a file path to create a PDF file with name test.PDF . However, I want to chance this so that the user can choose a name and that this name is used at the time of PDF generation. I am using iText to creating a PDF file like this. private String FILE = "e://test.PDF";

iText - avoid last row not to cut tables on page split to next page

牧云@^-^@ 提交于 2019-12-13 06:27:39
问题 I am working on itext 5 using java. I have pages with mutiple tables with dynamic rows. In some instances, the table last row is splitted into next page with the folowing header. I am using setHeaderRows() and setSkipFirstHeader() to manage continuation of next page. The last row has enough space to fit on earlier page. I would like to fit that last row in same page instead of next page. For example, on page 1, the last row is splitted into first row of next page. Instead I would like to fit

iText - how to find last row is split into next page

有些话、适合烂在心里 提交于 2019-12-13 06:22:24
问题 I have group of tables with dynamic rows. There are some scenarios where a table is splitted between pages. In some scenarios, only the last row is split into next page. Suppose if a table has 10 rows, the rows 1 thru 9 are displayed in page 1 and row 10 is displayed in page 2. I am looking for a solution to have a page break (document.newpage()) to happen to move the entire table to next page in this scenario. I tried below code and it was working for some scenarios but not for all. I would

Table on same line

末鹿安然 提交于 2019-12-13 05:53:22
问题 I use itextpdf-5.5.6 in my publisher project. I want to set a table on same line that a paragraph or phrase or text ? Something like that : In My Para |MY TAB OF ONE COLUMN| is present on a same line. is it possible ? 回答1: You don't need a table. What you need, is a generic tag event. Take a look at the answer by Chris Haas to this question: How do you underline text with dashedline in ITEXT PDF In this answer, he describes how to use a page event often referred to as the generic tag

Sign concatenated PDF in append mode with CERTIFIED_NO_CHANGES_ALLOWED

寵の児 提交于 2019-12-12 06:13:40
问题 I tried to sign PDF with append mode and certification level CERTIFIED_NO_CHANGES_ALLOWED but certain PDF files shown as modified and therefore invalid in Acrobat. itext 5.5.6, code: PdfStamper stp = PdfStamper.createSignature(reader, os,'\0',null,true); PdfSignatureAppearance app = stp.getSignatureAppearance(); app.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED); PDf file is created with wkhtmltopdf and concatenated with itself with pdfunite (CentOS 7) Here is zip