Get pagenumber and position of text

With Aspose.Pdf or Aspose.Pdf.Kit, how can I find the pagenumber and the (X,Y) coordinates of a text in a PDF document? Do you have an example? I'm trying to put a Signature in a Pdf document and need to be able to position it on the right spot. This spot is marked by a certain text, like [X____SIGNATURE HERE___]

My code:

Signature sgn = new Signature();

if (!location.isEmpty()) sgn.setLocation(location);
if (!name.isEmpty()) sgn.setName(name);
if (!reason.isEmpty()) sgn.setReason(reason);

sgn.setRect(new java.awt.Rectangle(x, y, width, height)); // <-- need X and Y here!

//sign PDF file
PdfFileSignature filesignature = new PdfFileSignature();
RandomAccessFileInputStream stream3 = new RandomAccessFileInputStream( certInfo.getStream() );
filesignature.setCertificate( stream3 );
filesignature.bindPdf( stream1 );
filesignature.setMultiSignature( false );
filesignature.setSignModel( PdfFileSignature.SELF );
filesignature.setPageNumber( pageno ); // <-- need pagenumber here!
filesignature.setPassword( password );
filesignature.setSignature( sgn );
filesignature.setKeyStoreType( "pkcs12" );
filesignature.setSignatureAppearance( bitmapInfo.getSecureFileName() );

filesignature.setCertificationLevel( PdfFileSignature.CERTIFIED_NO_CHANGES_ALLOWED );
filesignature.save( output.getOutputStream() );

Hello Wim,


Thanks for using our products.

I am afraid currently Aspose.Pdf.Kit for Java does not support the feature to get the page number information of a particular text string. For the sake of implementation, this feature is already logged in our issue tracking system as PDFKITJAVA-26171. Our development team is working hard to implement this feature and as soon as we have made significant progress regarding its implementation, we would be more than happy to update you with the status of correction. We apologize for your inconvenience.

Now concerning to your other requirement on getting XY coordinates of text string, please check out the following article for related details. Extract Text Formatting Information

Hi,


Thanks for contacting support.

I am afraid the requirement to get text position in existing PDf file using Aspose.Pdf.Kit for Java (logged earlier as PDFKITJAVA-26171) is not yet resolved. The development team has been busy resolving other priority issues and as soon as we have made some definite progress in terms of its resolution, we would be more than happy to update you with the status of correction. Please be patient and spare us little time.

Furthermore, Aspose.Pdf for .NET supports the feature to search and get position of text inside PDF document and recently we have ported Aspose.Pdf for .NET to Java platform and currently we are busy testing the new release version. So once this new auto-ported version becomes available, you will be able to parse an existing PDF file and get the location for particular string. Please be patient and spare us little time.

We are sorry for your inconvenience.

Hi,


Thanks for your patience.

I am pleased to share that an autoported MergedAPI release version of Aspose.Pdf for Java 4.0.0 has been released. Please try using the latest release version and in case you encounter any issue or you have any related query, please feel free to contact.