  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Can not open the pdf created with PdfCopy | Can not open the pdf created with PdfCopy 2007-08-07 - By new2pdf
Back
Hi!
I use PdfCopy create a new pdf document by extracting few pages from another pdf document. But the newly created pdf has a larger file size than the original even though it has lesser number pages. Could any one help me understand why is it like this? This is the code that I am using to create the pdf.
public void extractPdfPages(String inFile, String outFile, int[] pagesToExclude) throws Exception { // create a reader for the input document PdfReader reader = new PdfReader(inFile); int pages = reader.getNumberOfPages(); // create a new document Document document = new Document(reader.getPageSizeWithRotation(1)); PdfCopy copy = new PdfCopy(document, new FileOutputStream(outFile)); document.open(); // copy selected pages PdfImportedPage page; boolean isIncludeThisPage; for (int i = 0; i < pages; ) { ++i; isIncludeThisPage = true;
if (pagesToExclude != null && pagesToExclude.length > 0) { for (int j = 0; j < pagesToExclude.length; j++) { if (i == pagesToExclude[j]) { isIncludeThisPage = false; break; } } }
if (isIncludeThisPage) { page = copy.getImportedPage(reader, i); copy.addPage(page); } } // close new document document.close(); } -- View this message in context: http://www.nabble.com/Can-not-open-the-pdf -created-with-PdfCopy-tf4230910.html#a12036735 Sent from the iText - General mailing list archive at Nabble.com.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |