February 10, 201411 yr Newbies Hi All, Just wondering if anyone has created a ScriptMaster module using the iText library before? I'm needing to create a PDF Splitter and Merger in filemaker, so if you have any advice too, shoot!
February 11, 201411 yr Hi, here is a PDF Spliter // iText_SplitPDF ( pathToSrc ; pathToDest ) // 2012-07-05 by clem // // NOTE: To be properly numbered, the output file name must contain the format string %d // ex: pathToDest = C:/Path/To/mySplittedPortableDoc_page%d.pdf // result => C:/Path/To/mySplittedPortableDoc_page1.pdf etc… import com.itextpdf.text.Document import com.itextpdf.text.DocumentException import com.itextpdf.text.pdf.PdfCopy import com.itextpdf.text.pdf.PdfReader try{ def reader = new PdfReader(pathToSrc) def document def copy int n = reader.numberOfPages n.times{ document = new Document() copy = new PdfCopy(document, new FileOutputStream(String.format( pathToDest, it + 1))) document.open() copy.addPage copy.getImportedPage(reader, it + 1) document.close() } reader.close() return true } catch (IOException ioe){ return "ERROR: $ioe.message" } catch (DocumentException de){ return "ERROR: $de.message" } and you'll find a PDF Merger here : fmforums.com/forum/topic/73597-itext-scripts/
February 12, 201411 yr Clem you now need to explicitly close the reader so document.close() reader.close() also this uses the simpler but less useful class from their docs.>> PdfSmartCopy has the same functionality as PdfCopy, but when resources (such as fonts, images,...) are encountered, a reference to these resources is saved in a cache, so that they can be reused. This requires more memory, but reduces the file size of the resulting PDF document.
February 13, 201411 yr hi John, ... my bad ... I just forgot to copy the "finally" clause. also this uses the simpler but less useful class from their docs.>> PdfSmartCopy has the same functionality as PdfCopy, but when resources (such as fonts, images,...) are encountered, a reference to these resources is saved in a cache, so that they can be reused. This requires more memory, but reduces the file size of the resulting PDF document. ... Sir, yes Sir !! …I totally agree with you as long as we're dealing with concatenating PDFs, but in current case we're splitting them and all resources are needed.
Create an account or sign in to comment