How to generate pdf in java using itext

I would NOT like to save the pdf to the local storage of the android device, instead I would like to save it to a variable, like File file; or something similar, or directly convert it to a string and then save that value to a database. The current version of iText is iText 7. Apache PDFBox and iText are among the popular ones. You are creating your PDF in memory. convertToPdf(. PdfAWriter writer = PdfAWriter. getValoreString("PDFmulti", "PDF"). I downloaded the iTextpdf-5. Our PDF toolkit offers you one of the best-documented and most versatile PDF engines in the world (written in Java and . FileInputStream fs=new FileInputStream(src); //create document object to wrap the file inputstream object. For PDF generation, we will use the popular, open source PDF library called iText. If you are distributing a closed source / proprietary product (e. Oct 17, 2008 · Firstly, you can create a normal PDF which when read back will not give you the hierarchy of the original XML file. “When using iText PDF in a closed source environment, you will need to purchase an iText PDF commercial license. </b>", // html to be converted. xml file like this. For this we will use iText library and pass it the graphs generated by jFreeChart library. g. When I create the third page I set this code for the second time but Discover iText PDF. iText for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Working iText examples programs with output and source code. May 21, 2024 · In Java, multiple libraries exist that provide out-of-the-box features to handle PDFs and merge them into a single PDF. The new page will only actually get created when you place the next object. Second page (LANDSCAPE) with portrait text. Import the necessary iText classes: Oct 19, 2017 · This is the first time i'm using the library iText 7. getInstance(document, new FileOutputStream(dest), PdfAConformanceLevel. Read in a template pdf. I am not sure how to fix it, I'm thinking that maybe the solution is to calculate the space that the footer will need, then set the specific page size to fit with that blank space for the footer. Unlike using Java code, this method is clean to implement. Below code is creates second column of the table editable,however I want to have values of myVO. . It is a fork of iText version 4, more specifically iText svn tag 4. We’ll call this class PdfUtils. int i = 0, len = s. i am using itext 2. Create a new Java project. Many printers (or at least their drivers) will take PDF directly these days, so at that point one could argue that you're done. rotate()); and It seems to be working. Mar 20, 2019 · For example I need to generate 3 pages: First page (PORTRAIT) with portrait text. The output pdf file is dumped with a lot of things which are non-readable. DocumentException; import 1. iText 7 is released using the AGPL, just like iText 5 and XML Worker. The PDF is stored in the buffer object. open(); Jan 8, 2024 · OpenPDF is a free Java library for creating and editing PDF files under the LGPL and MPL licenses. jar. new PdfDocument(new PdfReader(src), new PdfWriter(dest)); PdfAcroForm form = PdfAcroForm. Step 3: Generate PDF with Charts/Graphs in Java using iText Now its time to generate the actual PDF files. pdf"); Aug 2, 2019 · dear srinivasan the code you added will print only one row with 7 columns and first column will have rowspan2. Using iText, we can create PDF files, dynamically. jar in your class path and paste following code in GeneratePDF. EMBEDDED), 8); I need to create a PDF A-2 file May 17, 2016 · We have customers who use iText to do this, but their code is much more elaborate than yours. iText has an add-on that enables converting HTML to PDF document. Steps to generate a pdf: Step 1: Create a Project in eclipse. x) This tutorial is going to show you how to leverage Spring MVC’s view technology to build a sample application that generates a PDF document dynamically in order to be downloaded/opened by the user. Add the itext jar files in class path. ” This video shows a simple example of how to generate a PDF document (using itextpdf library) in Java. Document document = new Document(PageSize. iText ( https://itextpdf. May 7, 2016 · In this case, we use a font that knows how to draw the ☉ character, as can be checked when you open sun_character. xml. answered Feb 8, 2012 at 13:45. java class and compile and execute it. I prefer Flying Saucer because it can convert almost all css styles from html to pdf whereas iTextPdf is very limited in css compliant. getValoreString ("PDFmulti", "PDF"). Oct 27, 2017 · I had to do the same thing and this is how I did it. getAcroForm(pdf, true); Map<String, PdfFormField> fields = form. We haven’t added yet the code to generate actual PDF file using iText API. Jul 3, 2023 · Adding metadata/Setting attributes of PDF using free Java-PDF library While you generate a PDF, you may want to set its different attribute like: author name, title, file description etc. Finish the project creation wizard. length(); Oct 28, 2010 · I have to create report using itext but the language should be hindi or marathi. It internally uses iText. The book (iText in Action) by Bruno Lowagie (original founder of iText) also goes in great detail. Feb 15, 2010 · Also note that the main method is still empty. Java itext tutorial examples. now I'm working with my project in Java Application with Netbeans 7. Click on Convert to Maven Project. This post shows how to use iText to convert HTML to PDF. although it has certain Restrictions like all tags should be closed like doing this <input/> wont work . Aug 5, 2013 · However, as the file you want to link to is also a PDF file, you probably don't want to use the setAnchor() method. setExternalDigest(Base64. A4. // read in template pdf. I am using the following code it is not working. When using iText5, I created a instance of PdfGraphics2D via createGraphicsShapes() and then drawn the objects using the APIs of Graphics2D. getOverContent(1); over. FileOutputStream; import com. Below is the snippet to do it : Lets assume the html data is available as Input Stream (If its a String then we can convert it to InputStream using Apache Commons - IOUtils) InputStream htmlData; // Html Data that needs to converted to Pdf. Mar 29, 2015 · I create a Document instance using the size of the first image. However, I am still struggling including the images. I'm just going to copy-paste the relevant section here. NET. getResourceAsStream(labelsTemplate); PdfReader reader = new PdfReader(templateStream); // create a table in a See full list on baeldung. There are literally endless use-cases. Oct 13, 2012 · How to create pdf in java using iText,iText image insertion in pdf, inserting table in itext pdf file, inserting list in itext pdf, new line in itext pdf chunk property Please consider disabling your ad blocker for Java4s. . Create input stream to convert html and write it to pdf and instantiate with new ByteArrayInputStream (stringBuilderHtml. itextpdf. Navigate to Configure. iText library helps in dynamically generating the . Build html using StringBuilder to be converted to pdf. It even shows how to program a calculator in a PDF document, page 232. If you use iText directly then it would be a tedious process. super. We're using iText to read an input PDF, then add messaging and saving the output. if I add something simple with document. commons libraries to encode and to read file contents into a byte array. page = copy. I would like to send the pdf generated through my @Get http response without storing the file on my server. - itext/itext-java import java. <dependency> <groupId> com. Mar 11, 2019 · String hashSignat = hashPdf; This is our code, first, we get the signature appearance, and calculate the hash. This’ll be the first out of a series of tutorials regarding iText PDF document generation. May 29, 2020 · I am using PdfAWriter to create a PDF A-2 document as below. pdf: The fact that this character doesn't appear when you replace Cardo-Regular. com Oct 1, 2022 · In this iText tutorial, we are writing various code examples to read a PDF file and write a PDF file. @Override. showTextAligned(align, text, x, y, angle); Oct 21, 2014 · It converts HTML to PDF directly. After you have the PDF bytes, its a normal "how do you print in Java" question. We’ll see various examples of PDF creation using iText showing the use of classes in iText like PdfDocument, Document, PdfWriter, Paragraph, Table, PdfFont, PDFReader. hey, I'm new here. Step 1: Create a New Java Class. The html2pdf gives utility methods that help us to convert HTML files or content into PDF. Aug 20, 2019 · The pdf is great, except the footer, that is overlapping the rest of the content. javac create_PDF. File; import java. So far, it's looking like this. Document doc = new com. Then we send the hash to the webservice, and we get the signed hash code. Create a new Java class in your project, name it SimplePdfGeneration or something similar. Please take a look at the TickboxCharacter example in the official documentation. public HeaderAndFooter(String name) {. Setup. Jan 10, 2015 · Jan 9, 2015 at 8:44. LETTER, 0. Oct 28, 2017 · How to create rectangle vertically and add text to it in PDF using itext 2. It's an iText7 add-on that converts HTML5 (+CSS3) into pdf syntax. then having java to get the phrases from xml file and convert it into Unicode using this method: public String convertToUnicode(String s) {. getBytes ()); XMLWorkerHelper. I then loop over an array of images, setting the page size of the next page to the size of each image before I trigger a newPage() [*] . 75F); Oct 20, 2014 · I need to create a PDF Document using Java's iText libraries. Apr 1, 2009 · Generate simple PDF in Java using free Java-PDF library It is very easy to generate a simple PDF file in Java using iText . (Obviously the layouter could have done a better job by making the date column broader, but that is about it Aug 5, 2016 · In iText 5, you have to set all the borders of all the cell to NO_BORDER, and you have to draw the border of a table by using a table event. Jul 15, 2023 · Java Development Kit (JDK) installed on your machine; An Integrated Development Environment (IDE) such as Eclipse or IntelliJ; The iText library added to your project; Creating a PDF File. pdf files from Java applications. Open source. If you also need Section titles, use the onSection() method to keep track of the sections too. 1- Download iText JAR. However, iText 5 is no longer supported. Hope this helps. I am using iText 5 and have been able to include the styling into the generated PDF. A4, MARGIN, MARGIN, MARGIN, MARGIN); HeaderFooter footer = new HeaderFooter(new Phrase("- "), new Phrase(" -")); When you create PDFX1. iText PdfWriter example to write content to a PDF file. Apr 3, 2023 · Next, we need to create a utility class that will generate the PDF file. In this tutorial, we’ll implement the PDF merge functionality using Apache PDFBox and iText. PdfReader reader = new PdfReader(SOME_SOURCE); PdfStamper stamper = new PdfStamper(reader, SOME_TARGET_STREAM); Oct 2, 2018 · I am using ITextPDF to create a PDF. What I need to do is convert HTML files that contain images and CSS styling to PDF. createFont(FONT, BaseFont. Apr 28, 2014 · 1. You should use the setRemoteGoto() method instead. getInstance(). iText provides the capability to convert HTML Data to Pdf. Feb 26, 2015 · 1. Here's an example implementation: public static ByteArrayOutputStream generatePdfStream Sep 1, 2016 · 1) First I tried following. The PDF is created in android. This is explained very elaborately in 'Section 9. HTML file to PDF. 3. Create a folder and copy the contents of zip folder. And I am able to write it to pdf file using the following code: OutputStream ostream = new FileOutputStream("c:\\test\\newfile1. Document Apr 1, 2020 · Need to make it one, remembering that this is dynamic, it may be much longer. I have the following situation, into a method I have: ByteArrayInputStream fis = new ByteArrayInputStream(Bean. onEndPage(writer, document); //code. InputStream templateStream = getServletContext(). What I exactly want is: I need to create pdf if I give one valid URL (say "https://xhtmlrenderer. Apr 21, 2024 · In this post we’ll see how to create PDF in Java using iText library. In fact, before version 5, the code for generating PDF using OpenPDF was nearly identical to the iText API. open (), otherwise first page will not display it. getFormFields(); Dec 28, 2016 · 1. Dec 12, 2020 · Overview. Step 4: Add the below methods to your class. Dec 5, 2019 · Creating a PDF file from HTML can be done using iText Java library. iText is an open source and widely used for creating the PDF document in Java application/program. I used apache. I need to include as well some checkboxes, which are on/off depending on the value of some class variables. put("Kids", kids); If you want an entry without a link, remove the lines that put an Action and a Page. new PdfWriter(. Oct 6, 2017 · Hi~ I'm trying to migrate the source code using iText 5 to iText 7, but I have a problem. You can use JasperReports library and the iReport visual designer. now I want to create a report with iTextPDF from my data in database. You can always use a ByteArrayOutputStream instead of a FileOutputStream. We start with the root of the tree: PdfOutline root = writer. FileOutputStream; import java. pdf"); byte[] data = new byte[4096]; int r = 0; Mar 29, 2022 · This iText tutorial shows how to generate PDF in Java using iText. After that continue from step 5. I suggest you try. 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. In this point, we have the hash code of the document. import com. How to save pdf with java itext. 7 Hot Network Questions Did Tolkien give his son explicit permission to publish all that unfinished material? Oct 21, 2013 · You can use iTextPdf library or flying saucer (which in turns makes use of iText library). The AGPL allows free use in the sense of free of charge in the context of open source projects. All products. Creating a valid pdf requires valid header and content bytes in a particular format. This should be an example that works with a PdfReader / PdfStamper pair, e. PdfReader reader = new PdfReader(inputFilepath); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputFilename, true)); PdfContentByte over = stamper. We add a paragraph into the Document instance using the Paragraph object. setPageSize(PageSize. Open your IDE and create a new Java class. May 2, 2014 · 6. answered May 16, 2014 at 14:25. Version of iText used here is the latest 8. Secondly, you can create a tagged PDF which contains both the hierarchy of the XML as well as the data. Aug 20, 2018 · Here the output file contains so many unwanted characters, some XML tags etc. Of course, I found that I could drawn the May 16, 2014 · helloworld. getBytes () returns a byte [] So now I need to put the content of the fis object into Oct 17, 2017 · I have searched the questions and have not been able to find a solution to my specific problem. Oct 29, 2013 · For this I have created one servlet and I also created one class HeaderandFooter that extends PdfPageEventHelper. I can make pdf files by using these jars. super(); @Override. getClientAuthorized() and myVO. In this article, I will introduce the latest version of the iText 7 library. In PDF terminology, bookmarks are referred to as outlines. To convert HTML files to PDF, you need to use the following java method. Aug 8, 2018 · The code in your question is code that uses iText 5. beginText(); over. Step 2: Import Required Packages. OutputStream; import com. x version. PdfWriter. 0, which was hosted publicly on sourceforge with LGPL and MPL license headers in the source code, and LGPL and MPL license documents in the svn repository. iText. "<b>This text should be written in bold. getBytes()); As you can see fis varialbe is a ByteArrayInputStream and Bean. "temp. 2 Parsing XML' of the 'iText in Action : Edition 2'. 75F, 0. ttf is proof that FreeSans. Document pdfdoc=new Document(PageSize. 2. UPDATE: I don't know if the helps but Sep 10, 2019 · Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Code sample of how I create it: Document document = new Document(); PdfWriter writer = PdfWriter. 1. iText Library. I have included my code below. Make a copy in memory of the template. I need to use the free iText, and iText 7 isn't free / the pdfHTML add-on is closed source. Font font8 = new Font(BaseFont. getOutputStream()) Jul 16, 2018 · In this tutorial, we will discuss how to create a table in the PDF document using iText API. Converting Using Flying Saucer Creating a simple PDF document involves several steps, starting from setting up a new Java class to writing code that initializes the iText library components. These documents vary from invoices, ebooks or vouchers etc. Follow these steps to Convert Html To Pdf in java using iText library >. getInstance(document, response. if it doesn;t take more than a second or so to generate), then you could create a servlet and write to HttpServletResponse. A4,72,72,72,72); //create a pdf writer object to write text to mypdf. e. Is it possible to make pdf file which contains marathi font like mangal,shruti,shree-devetc if yes plz reply me Thank you! May 27, 2019 · To add headers and footers to a PDF you generate using iText 7. 2: If you are working on a new project, you should abandon iText 5 and upgrade to iText 7 because all new development will be done on iText 7, not on iText 5. The given code examples are categorized into multiple sections based on the functionality they achieve. Feb 28, 2014 · I'm facing a problem when trying to export a Vietnamese document as PDF using iText. Also, newPage() only creates a new page if the current page is not blank; otherwise, it's ignored; you can use setPageBlank(false) to May 14, 2015 · 4. It is written in Java and . Once you have this list, create the TOC at the end of the document. iText is the most popular PDF API used by the Java developers for generating the PDF report. Once you're finished, add the outlines to the copy object: copy. getInstance(document, new FileOutputStream(pdfDirectoryPath +. That’s it. setStrictImageSequence(true); document. Once you have created the Eclipse Java project and added itext jar files. getRootOutline(); Then we add a branch: Nov 9, 2016 · Looking though the itextsharp code its possible that it doesn't always work well with multiple readers on the same content. add () after opening it works fine, I just never see the graphics. Right-click on the project, a drop-down menu appears. so to get 8 rows try folowwing for loop in code: Oct 27, 2013 · Generating PDF report is the very general requirement in most of the Java projects. Explore Teams Create a free Team. You would have to do <input></input>. ttf with FreeSans. Write the copy pdf to an outputstream. I would also use page event, but I would use the onChapter() method to create a list of chapter titles and page numbers. " You are adding content three times, and reading your code, this gives an incorrect result in the first attempt, a correct result in the second attempt, and you don't tell us whether the third attempt is correct or incorrect. Paragraph; May 23, 2023 · The basic steps to produce a PDF documents are: Create a Document object that represents a PDF document. Third page (PORTRAIT) with portrait text. itextpdf </groupId> <artifactId> html2pdf </artifactId> <version> 3. All you have to do is to put itext. public void onEndPage(PdfWriter writer, Document document) {. Feb 19, 2021 · The kernel dependency provides the core module for PDF support. Jun 19, 2013 · Below answer is applicable for versions prior to 7. //create file inputstream object to read data from file. NET), which allows you to not only integrate PDF functionalities into your workflow, but also in your applications, processes or products. To print 8 rows ,you took table of 8 columns and in for loop for every increment of variable 'aw' one cell will be added to the table and for every multiple of 8 of 'aw' new row will be created. xml appears in your project folder. If you want to add a link to an existing document, this is how to do it: PdfReader reader = new PdfReader("hello. Before going to examples of PDF creation in Java using iText there are few points about iText library. See the MovieLinks2 example. Nov 7, 2020 · Adding metadata/Setting attributes of PDF using free Java-PDF library. Using html2pdf. setOutlines(outlines); Look at the resulting PDF and you'll see the outlines in the bookmarks panel. But the output is amazing and fast and since it HTML you can change it easily. Open Eclipse IDE. Hide child comments as well Apr 21, 2015 · I am using iText to generate a pdf and write it to the file system as the following: private void createPDF() throws Exception{ com. It’s a fork of the iText program. XWPFDocument doc=new XWPFDocument(fs); //72 units=1 inch. Finally, we put the signed hash to the PDF: sgn. x, you will generally create event listeners for page starts and/or page ends and add the header and footer contents there-in. The reason why iText doesn't convert ordinary PDF documents to PDF/A should be evident: an ordinary PDF might not have all the necessary features that are needed in a PDF/A. pdf")); writer. IDENTITY_H, BaseFont. PDF_A_2A); For adding text I am using TTF fonts like this. I don't think you can create a pdf by simply creating a file with . com, we won't encourage audio ads, popups or any other annoyances at any point, hope you support us :-) Thank you. If you want to see a pure PDF version of your sample document, click the "Printable version" link in the upper right corner of the dynamic version. Here is my code: Document document = new Document(); PdfWriter writer = new PdfWriter(); Oct 25, 2010 · I've just downloaded xhtmlrenderer and iText jar files. 7. So let us add that dependency as well to our java project. Let's start by creating a simple PDF file using iText. But iText 7 does not provide createGraphicsShapes(), so I need help. The document you are presented then, is how dynamic you are in PDF. Draw a table on the copy. To convert HTML to PDF, the iText java library provides plenty of utility methods. It is very simple and easy to get started writing simple PDF files. Extract the content of zip file. com) comes with dual licenses commercial as well as open source (AGPL). Document; import com. 0 and I added it into the library of my project. GetImportedPage(reader, i); rather than create a new reader for each page you're trying to read. This is explained in chapter 5 of the book "iText in Action - Second Edition", more specifically in the PressPreviews example. io. JasperReports use iText to produce PDFs from "jasper" templates, that are XML files (following the jrxml DTD) compiled in java classes, but allows you to use the template for generating MS Office files (with POI), html, etc. iText jar can help you to set different attributes of a PDF file. Closed source. parseXHtml (pdfWriter, document, is); Mar 1, 2014 · The answer by Christian Schneider seems somewhat complex. I set after creating the first page: document. I tried this : @GET @Path("/gener Jan 6, 2011 · 1. Feb 6, 2020 · I'm using iText to generate . import java. pdf files and then save them to a specific location. I put Vietnamese words in . PDF created If you verify the specified path, you can find the created PDF document as shown below. If you are Maven user, you can directly add the dependency in your pom. Here is the static method I used Flying saucer to convert HTML to PDF: Oct 3, 2018 · try{. getClientSize() also in second column in Oct 4, 2015 · Excuse me. newPage() tells iText to place subsequent objects on a new page. pdf extension. Document object provide different methods to add various attributes to a PDF file. Dec 10, 2017 · Although PdfPageEventHelper can solve it, HeaderFooter seems more easier. I will provide an example of how to generate a PDF using the library and some methods for testing PDF content. You will observe that a new file named pom. getInstance(document, baos1); When concatenating the PDF documents, use a PdfReader with a ByteArrayInputStream: PdfReader reader = new PdfReader(new Sep 4, 2020 · Spring Web MVC with PDF View Example (using iText 5. Step 3: Add iText jar file which you have downloaded. iText – Write PDF. Apr 2, 2013 · If you want to be able to generate and download the PDF file dynamically (i. And we start by showing how to create pdf documents using iText. I've found some examples about interactive forms but I don't need this level of complexity: just some checkboxes which are added to a basic document like this: Apr 1, 2019 · This is a page from their website entitled 'Making a PDF interactive' which focusses on adding form elements. If you are using AGPL license (which is free) you need to share your entire Aug 10, 2012 · Create a variable to hold the bytes: private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Have the PdfWriter output the data to the byte [] as it creates the document: Document document = new Document(PageSize. It is a well-maintained solution for producing PDFs in Java. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText can be a boon to nearly every workflow. You now want to know how to add a check box character to a PDF (not an interactive form). The code is pretty straightforward: HtmlConverter. Make sure add HeaderFooter before document. 2. I am trying to complete an example that draws graphics and writes them to PDF, but I keep getting errors that the PDF has no pages. iText tutorial in java for beginners and professionals with examples in eclipse on Basics, create pdf, read pdf, edit pdf, split pdf, merge pdf, add password protection to PDF and more. getOutputStream(). The PdfWrite object that need the Document and an OutputStream object write the content of the PDF we added to the Document into a PDF file. I use IntelliJ IDEA CE 2019. x. Here two event listeners are defined: String header; public Header(String header) {. text. toByteArray()); Then you reuse this content like this: Go to iText PDF library files. you use iText in a Jul 14, 2016 · Many applications need to generate dynamic PDF documents. While you generate a PDF, you may want to set its different attribute like: author name, title, file description etc. 4. pdf. iText is also an open-source Java library that deals with PDFs. ttf doesn't contain the ☉ character. Feb 26, 2016 · Approach 3: create a PDF document with a single page; concatenate the file many times. Sep 27, 2020 · The Itext library comes with a supporting library called html2pdf that can convert Html and CSS to visually pleasing PDF documents. toString (). decode(hashSignat), null, "RSA"); Mar 29, 2024 · OpenPDF is open source software with a LGPL and MPL license. java java create_PDF Upon execution, the above program creates a PDF document, displaying the following message. ByteArrayOutputStream outputStream = new Feb 5, 2015 · 1. You might have a PDF of which the fonts aren't embedded. Rather than re-inventing the whee, you can use a framework such as Apache PdfBox, ItextPdf etc. Oct 19, 2017 · As you already have a PDF, you should use code from an example that adds watermarks to existing PDFs. For example you can do it like in this sample on the iText site. Paragraph; import com Jun 3, 2022 · The easiest way of doing this is using pdfHTML. Feb 16, 2024 · Create a project in Eclipse ( File -> New -> Java Project ). May 5, 2010 · Please explain what you mean when you write "It doesn't work. so here is my sample d Nov 8, 2017 · That's explained in the iText 7 Jump-start tutorial, more specifically in chapter 4: This form: Can be filled out like this: PdfDocument pdf =. 0 Compile and execute the saved Java file from the Command prompt using the following commands −. Step 2: Create a class called as "iTextPDFTutorial". those here, which all have the structure. The problem is when running the service and I hit the service with a request, it saves the first file correctly but when I'm trying to generate another one, it generates a file with the data of the first one plus it appends the previous data with the new data. pdf, use a PdfWriter with a ByteArrayOutputStream instead of a FileOutputStream: ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter. Calling document. 2 version for the coding in May 23, 2017 · You already know how to check a check box field in an interactive PDF. You could read this PDF using PdfReader like this: PdfReader reader = new PdfReader(buffer. pdf file. uv ab ml gh uv xo gm zc zg fx