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

Free Support Forum - aspose.com

Document class does not display getPages as shown in examples

HI,


I was trying out the sample code in http://www.aspose.com/docs/display/pdfjava/Replace+Text+in+Pages+of+a+PDF+Document
but I get error.
The Document class does not have a getPages. I looked through the API and Document class link gives 404.

Can someone tell me how to get the following mentioned in the above line works?

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“source.pdf”);

// Create TextAbsorber object to find all instances of the input search phrase
com.aspose.pdf.TextFragmentAbsorber textFragmentAbsorber = new com.aspose.pdf.TextFragmentAbsorber(“sample”);

// Accept the absorber for first page of document
pdfDocument.getPages().accept(textFragmentAbsorber); // PROBLEM IS HERE.

//pdfDocument does not contain the method getPages(). I could get IntelliJ to auto fill the method

Hi Pritam,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 11.1.0 where I have used one of my sample PDF files and the code snippet given on above specified link and I am unable to notice any issue. The text is properly being replaced.

Can you please share the resource file causing this issue, so that we can test the scenario in our environment. We are sorry for your inconvenience.

Hi Team,

I trying to replace text in a PDF document and using the code refered in the support blog as below.
https://docs.aspose.com/display/pdfjava/Replace+Text+in+a+PDF+Document#ReplaceTextinaPDFDocument-ReplaceTextonAllPages

However, the pdfDocument.getPages().accept(textFragmentAbsorber); is not getting resolved,
Please let me know how to get pages from PDF document directly, with out going through any other DOM Object iteration.

I have added(aspose.pdf-19.1.jar) Aspose Jar into Library.
Regards,
Mamtha.A.C.D.

Hi Team,
I have Aspose License.

I trying to replace text in a PDF document and using the code referred in the support blog as below.
https://docs.aspose.com/display/pdfjava/Replace+Text+in+a+PDF+Document#ReplaceTextinaPDFDocument-ReplaceTextonAllPages

However, the pdfDocument.getPages().accept(textFragmentAbsorber); is not getting resolved,
Please let me know how to getpages() from PDF document directly, with out going through any other DOM Object iteration.

I have added(aspose.pdf-19.1.jar) Aspose Jar into Library.
Regards,
Mamtha.A.C.D.

@HAREEM_HCL_COM, @mamt.acd

Thanks for contacting support.

Would you kindly share what kind of issue you are facing. Also please make sure to include com.aspose.pdf.*; namespace in your program. In case the issue still persists, please provide a sample console application which is able to replicate the issue. We will test the scenario in our environment and address it accordingly.

You can simply use Document.getPages() method in order to get complete collection of Pages and in case you want to get single page, you can use Document.getPages().get_item() method by passing page number as an argument.