Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4596 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a scanned PDF that has multiple areas of text handwritten text. I want to see if there's a way in itext to extrapolate coordinates on the page to be inserted into separate Container or viewers. Such as did this person sign the document? show the last 2 inches of the page starting 3 inches from the left.

Posted

Bear in mind that the iText co-ordinate system starts bottom left, like a graph and 72dpi

Two way to do it spring to mind

A: Copy the file and just make the crop box to the size of what you want left to display, leaves the whole file there just not visible

B: Render the file to an image and then use a java awt transformation to just get the part you want. (This could in part be done in FM12 with the Get (Thumbnail) function)

The first one is really easy


import com.itextpdf.text.pdf.PdfDictionary

import com.itextpdf.text.pdf.PdfName

import com.itextpdf.text.pdf.PdfReader

import com.itextpdf.text.pdf.PdfRectangle

import com.itextpdf.text.pdf.PdfStamper



reader = new PdfReader(src)



// make this 'lower left' 3in along, 0 up TO 'upper right' pageWidth along 2in up

PdfRectangle rect = new PdfRectangle(216, 0, reader.getPageSize(1).getWidth(), 144)



// for ALL pages use this

n = reader.getNumberOfPages()

for (i in 1..<n) {

pageDict = reader.getPageN(i)

pageDict.put(PdfName.CROPBOX, rect)

}

// or for just ONE known page

//pageDict = reader.getPageN(1)

//pageDict.put(PdfName.CROPBOX, rect



stamper = new PdfStamper(reader, new FileOutputStream(dest))

stamper.close()



This topic is 4596 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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