Please take a look at the ParseHtml7 and ParseHtml8 examples. They take HTML input with Arabic characters and they create a PDF with the same Arabic text: Before we look at the code, allow me to explain that it's not a good idea to use non-ASCII characters in source code....
I think you should use textarea instead of textfield as you want multiple lines. And then you need to put textArea to ScrollPane to get scrollbar. JTextArea textArea = new JTextArea(10, 30); ScrollPane scrollPane = new JScrollPane(textArea); ...
Well, I finally solved it. Thanks to @BrunoLowagie and @Fahim Parkar. Will make a quick explanation of all my modifications according to all suggestions: First of all and according @Bruno comments, first I deleted unused method PdfPTable::setKeepTogether(boolean);. Second, and according to this question, posted by @Fahim (thanks!). We can force...
Please take a look at the NestedTables2 example. In this example, we tell iText that it's OK to split cells as soon as a row doesn't fit on a page: This is not the default: by default, iText will try to keep a row intact by forwarding it to the...
java,pdf,itext,digital-signature,invalidate
I made it happen' :) Here is the code used to add custom text to document using iText without invalidating digital signatures. //Read the source PDF PdfReader reader = new PdfReader(inputstream); //Create PdfStamp object stamp = new PdfStamper(reader, new FileOutputStream(file), '\0', true); //Create the proper annotation PdfAnnotation annot = PdfAnnotation.createFreeText(stamp.getWriter(),...
I have tried your example, and I have discovered that the behavior you experience is caused by a bug in Adobe Acrobat / Reader. The bug occurs when the borders of the widget annotations of different text fields overlap. Once I made sure that there was no overlap between the...
Please take a look at the CreateJapaneseButton example. It creates a PDF with a button that looks like this: Your code snippet is very short, but you probably have all the code you need, except the line that sets the font: public static final String JAPANESE = "\u3042\u304d\u3089"; public static...
Take a look at the answer to the following question: How to position a PDFGraphis2D object in iText? As you can see, it is common not to draw objects such as the chart or the table straight to the direct content. Instead, you should create a PdfTemplate to draw to....
You have detected a bug that was introduced in iText 5.5.6. This has already been fixed in our repository: Thank you for reporting this bug. You can find the fix on github: https://github.com/itext/itextpdf/commit/eac1a4318e6c31b054e0726ad44d0da5b8a720c2...
c#,itextsharp,itext,jpeg,clipping
iText copies the bytes of a JPG straight into the PDF. Not a single byte is changed. If you say that your JPGs have clipping paths (I've never heard of such a thing) and you don't see that feature in the PDF, you are being confronted with a limitation inherent...
Just in case someone has a similiar problem. I could solve it by changing the InputStream for the PdfStamper from MemoryStream to FileStream. With this change it worked for me. public static void RemoveAcroFields(String filename) { if (filename != null && File.Exists(filename)) { byte[] pdfFile = File.ReadAllBytes(filename); PdfReader reader =...
It is actually a Invalid PDF. When I open the PDF in text editor I noticed that header has CreatorDate with out close bracket. I just added the close bracket with valid date like this CreatorDate (05 November 2014 17:50:24) then It works. I asked client to correct on their...
java,pdf,pdf-generation,itext,itextpdf
If I understand your question correctly, you need to create something like this: In this screen shot, you see the first part of the first book of Caesar's Commentaries on the Gallic War. Gallia omnia est divisa in partes tres, and so is each page in this document: the upper...
try this, hope this will help you Drawable d = getResources().getDrawable(R.drawable.toplogos) BitmapDrawable bitDw = ((BitmapDrawable) d); Bitmap bmp = bitDw.getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); Image image = Image.getInstance(stream.toByteArray()); document.add(image); ...
If you want to add some extra space between two rows, why don't you add an extra (empty) row with a fixed height? I took your code snippet that adds two rows to a table, and I added an extra cell with colspan 3 between those two rows. I defined...
Please take a look at the BarcodePlacement example. In this example, we create three PDF417 barcodes: PdfContentByte cb = writer.getDirectContent(); Image img = createBarcode(cb, "This is a 2D barcode", 1, 1); document.add(new Paragraph( String.format("This barcode measures %s by %s user units", img.getScaledWidth(), img.getScaledHeight()))); document.add(img); img = createBarcode(cb, "This is NOT...
java,exception,servlets,itext,pdf-reader
Finally, the problem is solved, I just added this one line of code in the beginning, before specifying the path - <% String relativePath = getServletContext().getRealPath("/"); String Source = relativePath +"Resource/text.pdf"; ... ... %> ...
After many attempts, i confermed with no doubt that the "GlassPane" is not the right solution for my app or any app like this. because: it can't be above a specific area or a component. it's usable only with the root pane.. The best way to read a PDF file...
I see that you create your destination like this: new PdfDestination(PdfDestination.FIT,-1,-1,0) This is a strange way to create a destination so that the page is displayed to fit the viewer window. Please take a look at The ABC of PDF with iText. The book isn't finished yet, but it's free...
java,html,fonts,itext,xmlworker
I found at least one way to do it by getting the chunks out of each element and setting the font for that chunk. ie: Font f = new Font(); f.setSize(8); for (Element e : XMLWorkerHelper.parseToElementList(sisalto, null)) { for (Chunk c : e.getChunks()) { c.setFont(f); } cell.addElement(e); } table.addCell(cell); }...
You can take a look at the following Stack Overflow question and answers: Java PDF Viewer. You could give both ICEpdf and Pdf-renderer a try for viewing PDF files. Here you can find more PDF libraries that have other functionality that might be useful for your project: What is the...
Ok. So I am able to do this successfully using exactly your code but making these two changes. Put method="get" in the <form> tag in the jsp Change doPost to doGet in the servlet and it should work as it has worked for me too. Do tell me if it...
java,table,pdf-generation,itext
I found one not very good solution for this problem, I've added one column to the table, which width it too small and it isn't visible for users, in this column I've add table with two rows, for first row I set minimum height which I need, here the code...
Yes, you can create a Font from a byte[], but in that case, you can't use the FontFactory. Instead you need to create a BaseFont instance using the createFont method, see http://api.itextpdf.com/itext/com/itextpdf/text/pdf/BaseFont.html for the different options. Once you have a BaseFont instance, you can easily create a Font object: Suppose...
You are adding a List to a PdfPTable in text mode. That can never work. You should add the List in composite mode. The difference between text mode and composite mode is explained in the answer to the following questions: C# iTextSharp multi fonts in a single cell iText: maintain...
There is a process in iText known as 'flattening', which takes the form fields, and replaces them with the text that the fields contain. I haven't used iText in a few years (and not at all on Android), but if you search the manual or online examples for 'flattening', you...
The other answer to this question is almost correct, but not quite. You can use any OutputStream when you create a PdfWriter. If you want to create a file entirely in memory, you can use a ByteArrayOutputStream like this: ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document,...
The sample document actually contains one big image, a scanned page, and invisible text information on top of the scanned printed letters. Most likely this text information is the result of some OCR process. Unfortunately already this text information is missing the accents in question. E.g. the text for the...
itext,digital-signature,digest
After much debugging, we finally found the problem. For some mysterious reason, the method that generates the hash of the document, was executed twice, invalidating the first hash (which we use to send to the service). After a refactoring work of the code, the original code worked correctly. Very thanks...
Adding the cover page Usually using PdfCopy for merging PDFs is the right choice, it creates a new document from the copied pages copying as much of the page-level information as possible not preferring any single document. Your case is somewhat special, though: You have one document whose structure and...
Certifying the sample 2g.pdf using the OP's code and verifying the result with other tools than Adobe Reader one obtains the information that the certification signature is valid. Something like this (i.e. Adobe Reader complaining about a perfectly valid signature) usually happens with documents which cause Adobe Reader to manipulate...
You are using text mode (to be used when you only have text) in a situation where you should use composite mode (because you are adding a table to a cell). Please take a look at the NestedTableProblem example: // table 2 final PdfPTable table2 = new PdfPTable(1); table2.setHorizontalAlignment(Element.ALIGN_LEFT); table2.getDefaultCell().setBorderColor(BaseColor.RED);...
It sounds as if you are missing only a single piece of the puzzle to meet your requirement. That piece is called getYLine(). Please take a look at the DrawRectangleAroundText example. This example draws the same paragraph twice. The first time, it adds a rectangle that probably looks like the...
Please take a look at the BorderForParagraph example. It shows how to add a border for a paragraph like this: There is no method that allows you to create a border for a Paragraph, but you can create a PdfPageEvent implementation that allows you to draw a rectangle based on...
There are many different ways to achieve what you want: Take a look at the following screen shot: This PDF was created using the IndentationOptions example. In the first option, we use a List with the label ("A list of stuff: ") as the list symbol: List list = new...
This avoids splitting on "(999)" embedded in the text. It is based on the assumption that a line end precedes the parenthesized number that indicates the start of a paragraph. Also note that the sample text produces an empty "paragraph" from no text preceding the first parenthesized number - therefore...
java,pdf,pdf-generation,itext,bytearrayoutputstream
In a comment to your previous question How to convert a String object representing a PDF into a ByteArrayInputStream that will be used in iText?, you say I have to concatenate all the PDF to create a single PDF. This is crucial information that you are omitting in your new...
You create a PDF on your local disk and you set some headers that are sent to the browser. You do not send any bytes to the browser, hence you should not expect to see anything in your browser. This is consistent with the behavior you describe. In another answer,...
In PDF terminology, bookmarks are referred to as outlines. Please take a look at the CreateOutline example from my book to find out how to create an outline tree as shown in this PDF: outline_tree.pdf We start with the root of the tree: PdfOutline root = writer.getRootOutline(); Then we add...
I believe that you should mark the HTML as safe to display. This has been answered in another question http://stackoverflow.com/a/7442668/1806855
I have written a brute force method to extract all streams in a PDF and store them as a file without an extension: public static final String SRC = "resources/pdfs/image.pdf"; public static final String DEST = "results/parse/stream%s"; public static void main(String[] args) throws IOException { File file = new File(DEST);...
Depending on what you want exactly, different scenarios are possible, but in any case: you are doing it wrong. You should use either PdfCopy or PdfSmartCopy to merge documents. The different scenarios are explained in the following video tutorial. You can find most of the examples in the iText sandbox....
Here is the answer: http://weblog.west-wind.com/posts/2012/May/30/Rendering-ASPNET-MVC-Views-to-String. I replace ControllerExtensions with this source. And it works. If someone can tell me, why the ViewBag via the ControllerExtensions class disappeared. Nice to hear.
import com.lowagie.text.*; import com.lowagie.text.pdf.PdfWriter import javax.swing.text.Document public static void main(String[] args){ String[] ITEMS = ["Insurance system", "Agent", "Agency", "Agent Enrollment", "Agent Settings", "Appointment", "Continuing Education", "Hierarchy", "Recruiting", "Contract", "Message", "Correspondence", "Licensing", "Party"]; com.lowagie.text.Document document = new com.lowagie.text.Document(); PdfWriter.getInstance(document,new FileOutputStream("List1.pdf")); Font zapfdingbats = new Font(); Font font = new...
The σ-symbol doesn't exist in Helvetica, so you need to use the Symbol font. This is demonstrated in the StandardDeviation. See standard_deviation.pdf: This is how it's done: public void createPdf(String dest) throws IOException, DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); document.add(new Paragraph("The standard deviation symbol doesn't...
Leigh's comment about using ByteArrayOutputStream was the correct answer. Here is the updated code that works placing the generated PDF into a ColdFusion variable: <cfset var document=createObject("java", "com.lowagie.text.Document") /> <cfset var PageSize=createObject("java","com.lowagie.text.Rectangle") /> <cfset var fileIO=createObject("java","java.io.ByteArrayOutputStream") /> <cfset var writer=createObject("java","com.lowagie.text.pdf.PdfWriter") /> <cfset var paragraph=createObject("java",...
There are lots of alternatives for your request: 1.) Do you know that fields offer autosizing of fonts? If you set the fontsize to 0 the font will be automatically sized to fit a field. 2.) Do you know that text form fields can contain multiple lines? (multiline textfield Ff...
I have first scaled the image and then created document with scaled PageSize. This fixed the issue com.itextpdf.text.Image image =com.itextpdf.text.Image.getInstance("../temp.jpg"); image.scalePercent(1); Document doc = new Document(new com.itextpdf.text.Rectangle(image.getScaledWidth(), image.getScaledHeight())); doc.open(); doc.add(image); ...
There are some open source and some paid options. itext imho would bring out the best result if you can use a product under AGPL license. If you are looking for open source / free Yet another Html to Pdf converter ==> http://www.allcolor.org/YaHPConverter/ wkhtmltopdf ==> http://wkhtmltopdf.org/ PDF Box ==> http://pdfbox.apache.org/...
you have copy/pasted an example from my book, but it seems that you have not read the book, nor have you really tried the example. You say "I don't want to reduce the dimension, but change DPI." Well... that's exactly what the example in my book is doing! In the...
java,itext,autofill,form-fields,formfield
Fact 1: The PdfFormField class extends the PdfAnnotation class, because most of the times, it is possible to merge a field dictionary with an annotation dictionary. In your case, you have a PdfFormField that is used as a hierarchical element and although that element is also an instance of PdfAnnotation,...
c#,gridview,itext,export-to-pdf,spgridview
Finally I got my solution. I am using a different approach alltogether. protected void btnExport_Click(object sender, EventArgs e) { dtUIExport = GetData(); //Creating iTextSharp Table from the DataTable data PdfPTable pdfTable = new PdfPTable(dtUIExport.Columns.Count - 1); pdfTable.DefaultCell.BorderWidth = 2; int[] widths = new int[dtUIExport.Columns.Count - 1]; //setting font BaseFont bf...
html,pdf,itext,screen-readers,xmlworker
Please take a look at the ParseHeaders example. It takes the headers.html page with headers from <h1> to <h2> and converts it to headers.pdf: In your question, you claim that everything is working perfectly except heading levels (h1-h6), but you don't explain what isn't working. Please elaborate. As shown in...
java,itext,heap-memory,ioexception
i am wring answer to my own question so it can be helpful to other. i have solved problem Using below code (using Document.plainRandomAccess=true;): PdfReader pdfReader = null; try{ Document.plainRandomAccess=true; pdfReader = new PdfReader(new RandomAccessFileOrArray("D://bigfile.pdf"),null); }catch(Exception e){ System.out.println("Error"); e.printStackTrace(); } ...
The cause In comments it turned out that the OP creates his web application in maven, that the template.pdf file is supplied as a maven resource, and that filtering (i.e. text variable replacements) of the resources is activated. Unfortunately, though, filtering resources implies that the resource files are treated as...
Please be aware that signatures done well (using a certificate from a CA that is member of CDS or AATL) can be verified so that you can test for (1) "integrity", (2) "authentication", and (3) "non-repudiation". By throwing away the signature fields, you lose all that information and nobody will...
in your first snippet, you hardcode the page number: stamper.GetUnderContent(1); In your second snippet, you loop over the pages: for (var i = 1; i <= reader.NumberOfPages; i++) { } Now combine these two snippets: for (var i = 1; i <= reader.NumberOfPages; i++) { PdfContentByte pbunder = stamper.GetUnderContent(i); //...
the second signature invalidates the first one even though the signing is done in append mode, and only the last signature has the PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED certification level. As already conjectured in an initial comment, this actually turned out to be the problem: Only the first signature of a document may...
android,pdf,android-studio,itext
I faced a similar problem yesterday. Just add this to your build.gradle file and clean/invalidate your project =) android { .... dexOptions { jumboMode = true } } ...
Try moving the instantiation and closing of the PrintWriter outside of the main for loop: try { PdfReader reader = new PdfReader("D:\\hl_sv\\L09MF.pdf"); int pagenumber = reader.getNumberOfPages(); PrintWriter out = new PrintWriter("D:\\hl_sv\\L09MF.txt"); for (int i = 1; i <= pagenumber; i++) { System.out.println("==================PAGE NUMBER " + i + "==================="); String line...
Please take a look at the MultiLineField that was written to test your allegation. In this example, we create a form with the simplest possible multi-line text field: Rectangle rect = new Rectangle(36, 720, 144, 806); TextField tf = new TextField(writer, rect, "text"); tf.setOptions(TextField.MULTILINE); writer.addAnnotation(tf.getTextField()); Then we fill and flatten...
As explained in the comment section, this isn't supported yet in XML Worker. We'll add it to the next release. If you can't wait until the next release, please apply this patch: diff --git a/src/main/java/com/itextpdf/tool/xml/html/table/Table.java b/src/main/java/com/itextpdf/tool/xml/html/table/Table.java index 541818bfc9..e262b4a406 100644 --- a/src/main/java/com/itextpdf/tool/xml/html/table/Table.java +++ b/src/main/java/com/itextpdf/tool/xml/html/table/Table.java @@ -165,6 +165,19 @@ public class Table...
As far as I remember, internal anchors are created like this: <a href="#myanchor">Click here to go to my anchor</a> ... <a name="myanchor">This is the destination of a link</a> That's supported in XML Worker. Adding an id attribute to a <p> tag is not supported....
You are closing the PdfReader instances too early. You can only trigger: reader.Close(); after you close the PdfSmartCopy instance, hence you have to rethink where you create the different PdfReader objects (not inside the loop). The reason why the different PdfReader instances have to remain open is purely technical: merging...
In the SD Card of real Device. If by "the SD Card", you mean what the Android SDK refers to as external storage, you have a number of options for getting a path to a spot to write your file. Off the cuff, I would recommend getExternalStoragePublicDirectory() on the...
This issue was resolved by changing the initial call by using the following code: imgStream = grailsAttributes.getApplicationContext().getResource("Logo.jpg").getInputStream() Instead of the initial way imgStream = servletContext.classLoader.getResourceAsStream("/assets/Logo.jpg") Thanks, Tom...
Just use: //import java.awt.Color; fields.setFieldProperty("text_2", "bordercolor", Color.BLUE, null); fields.setFieldProperty("text_2", "bordercolor", Color.RED, null); fields.setFieldProperty("text_2", "bordercolor", Color.GREEN, null); If you need a custom color, define it like this: Color custom = new Color(228,102,0); fields.setFieldProperty("text_2", "bordercolor", custom, null); ...
First let me assure you that changing the rotation in the page dictionary is the correct procedure to achieve what you want. As far as I can see your code, there's nothing wrong with it. You are doing the right thing. Unfortunately, you are faced with a third party product...
Sure, just save it to a MemoryStream instead: using (MemoryStream ms = new MemoryStream()) { // Odd to have a constructor but not use the newly-created object. // Smacks of the constructor doing too much. var ignored = new PdfStamper(reader, ms); return ms.ToArray(); } ...
@BrunoLowagie Thanks for your response. Actually, I managed to get iText to concatenate PDF interactive forms to create a custom PDF packet. Let me explain how I did this. From using Adobe Acrobat XI Pro, I learned that when the XFA PDF is loaded, I cannot edit the form if...
You need to upgrade your iText-2.1.7.jar file to latest version as earlier the package that was used by jar is com.lowagie... See the change list here which says it has changed the package name....
You use PdfStamper for that. The code goes like this: PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfContentByte canvas = stamper.getOverContent(1); PdfPTable table = ...; //add data to table table.writeSelectedRows(... , canvas); stamper.close(); reader.close(); ...
Many things are wrong with your code. For instance: you say that the watermark doesn't appear in your final PDF, but if you looked closer, you'd see that a watermark is indeed added, but it is covered by an opaque image (the TIFF you added in a previous go). Look...
java,itext,right-to-left,hebrew,xmlworker
Please take a look at the ParseHtml10 example. In this example, we have take the file hebrew.html: <html> <head> <title>Hebrew text</title> </head> <body style="font-size:12.0pt; font-family:Arial"> <div dir="rtl" style="font-family: Noto Sans Hebrew">שלום עולם</div> </body> </html> And we convert it to PDF using this code: public void createPdf(String file) throws IOException, DocumentException...
Please take a look at the ComboBoxItems example: This is the cell event implementation: class SelectCellEvent implements PdfPCellEvent { protected PdfFormField selectGroup; protected String name; protected String[] exports; protected String[] options; protected BaseFont font; public SelectCellEvent(PdfFormField selectGroup, String name, String[] exports, String[] options) throws DocumentException, IOException { this.selectGroup = selectGroup;...
Problem solved- I was not able to update the jar because of dependencies of existing architecture. But the real problem was with rowspan. The rowspan was different for active/inactive parts. After changing that logic the problem was solved....
I just ran your SSCCE (Short, Self Contained, Correct (Compilable), Example), and printed the resulting PDF from Adobe Reader. I measured the red rectangle both on-screen using the Adobe Reader measuring tool and on-paper. The result on screen: matches your parameters createRectangle(writer, 30.75f, 11, 148.5f, 210, Color.RED); ------------------------------------^^^^^^--^^^ exactly, and...
Which example are you using? If it is the the one from page 575 you will read the following: "What you have here is a poor man’s text extractor. It works well for this example, but it won’t work with most PDF files that can be found in the wild....
We had a similar question in our closed issue tracker. In that ticket, it appeared that the Document needed to be opened right after the PdfCopy instance is created. In your case, we see a similar problem: you use a Document object to create a PDF from scratch, and you...
You are using ColumnText.showAligned() which is sufficient to add a line of text without any special features, but if you want the anchor to work, you need to use ColumnText differently. This is shown in the AddLinkAnnotation2 example: public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader...
Check this example for displaying checkboxes or radiobuttons without specifying positions. You need to use PdfPTable. http://itextpdf.com/sandbox/acroforms/CreateRadioInTable . There is one issue for displaying radiobuttons on multiple pages which I have posted here Issue with iText RadioCheckField when displayed on multiple pages and still waiting for answers
The label of a field in PDF is not contained in some dedicated label object, it is mere page content. Thus, it has to be added as regular content. I merely have Java development tools at my hand right now, so the following sample is in Java for iText. (Usually...
Please take a look at the SpaceCharRatioExample to find out how to create a PDF that looks like space_char_ratio.pdf: When you justify a paragraph, iText will add extra space between the words and between the characters. By default, iText will add 2.5 times more space between words than between characters....
android,database,sqlite,pdf,itext
There are two problems in your code: You open the document before attaching a PdfWriter to it. Thus, the PdfWriter is not informed about the document being opened. You don't close the document in the end. Thus, the PDF output remains unfinished. The iText in Action example HelloWorld shows the...
The jar you are trying to run is not an executable jar. iText is a library that be used in a Java application by adding itextpdf-5.5.6.jar to the CLASSPATH. If you don't write any Java code, then the jar won't do a thing, hence your Shell() and your RunProgram() methods...
You are using the wrong iText version, hence you are creating signatures that are not future proof (please read this book to find out what's wrong with your code). You are depending on the fact that the operating system is Windows. Is your server also a Windows server? Your...
Your initial question didn't get an answer because it is rather misleading. You claim link coming twice, but that's not true. From the point of view, the link is shown as HTML syntax: <a href="http"//stackoverflow.com">http://stackoverflow.com</a> This is the HTML definition of a single link that is stored in the cellText...
First of all, there is not necessarily the hash/digest message from the signature, in case of PKCS#7 / CMS signatures usually multiple hashes are involved, cf. this answer to Message digest of pdf in digital signature. Considering that you need the digest to fulfill some legal restrictions, though, I assume...
You aren't adding the text correctly. The PDF you are creating contains a serious syntax error. Some PDF viewers will ignore this syntax error and show the text anyway (which may be why you can print the PDF from a browser); others will not show anything because you are showing...
css,itextsharp,itext,xmlworker
You forgot to define the vertical alignment of the right cell. I have adapted your HTML (table4_css.html): <table> <tr> <td> <table border="1"> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> </table> </td> <td valign="top"> <table border="1"> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> </table> </td> </tr> </table> You...
java,html,parsing,itext,xmlworker
Problem solved. It was caused by my itextpdf and xmlworker being slightly different versions. This and MANY other problems were solved by getting the exact same versions (5.5.5 in my case) of both dependencies. After 2 days of banging my head to the wall rigorously I cannot stress this enough:...
When you have finished creating a PDF, you can create a PdfReader instance and ask that reader object for the total number of pages. That is true. However: it seems that you are not creating a PDF from scratch. Instead you are using PdfCopy to concatenate many different documents. Allow...