Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • 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!

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/

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.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.