We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Finding a string location in a PDF doc using Coldfusion with Java

Hi,
I am trying to get the location of a particular string “[CandidateSignature]” at all places of its existence in the Document. I am generating a position string in the format “PageNumber^X Coordinate,Y Coordinate” with each such location separated by semicolons. I am using Coldfusion with Aspose.PDF for Java. I get very different results when i am using 2 different files. I am attaching both the files here. In file “Dept-Head…”, the position string gets repeated for some reason (i get “2^98.324,264.538113005;2^98.324,264.538113005​”) and the second location of the string is not detected. In the other file, “CSTestDoc.pdf”, the 2 signature locations are detected but one is repeated for some reason. The position string that i get for this file is “1^72,549.166890986;1^72,549.166890986;2^72,526.726880486​”.

I am using the following code to get the locations of the string mentioned above:

<cfset docPDF.init(filepath)>

<cfset textFragmentAbsorber.init("[CandidateSignature]")>

<cfset docPDF.getPages().get_Item(eachPage).Accept(textFragmentAbsorber)>

 <cfset local.position = "">
 <cfloop from="1" to="#textFragmentCount#" index="local.eachItem">
         <cfset local.position = textFragmentAbsorber.getTextFragments().get_Item(local.eachItem).getPosition().getXIndent() & "," & textFragmentAbsorber.getTextFragments().get_Item(local.eachItem).getPosition().getYIndent()>
         <cfset pagenum = textFragmentAbsorber.getTextFragments().get_Item(local.eachItem).getPage().getNumber()>
         <cfset local.positionList = ListAppend(local.positionList,"#pagenum#^#local.position#",";")>

   </cfloop>

I am not sure what i am doing wrong. Can you kindly guide me as to how i can get the particular string locations at all places correctly without any repetition?

Regards,CSTestDoc.pdf (193.5 KB)
Dept Head Commission 5-2022.pdf (902.8 KB)

@Batrinux

Please spare us some time for the investigation of this issue. We will get back to you soon.

@Batrinux

We have tested the scenario using the latest version of Aspose.PDF for Java 22.4 and have not found the shared issue. So, please use Aspose.PDF for Java 22.4.