We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Loop through all pdf elements

Thread ID:

Created:

Updated:

Platform:

Replies:

143888 Apr 9,2019 06:16 AM UTC Apr 10,2019 08:58 AM UTC WPF 4
loading
Tags: PDF
John
Asked On April 9, 2019 10:49 AM UTC

Loop through all pdf elements.

How to do that ?


Meikanda Nayanar [Syncfusion]
Replied On April 9, 2019 12:57 PM UTC

Hi John, 
 
According to the structure of the PDF documents, we cannot loop through the PDF elements inside a PDF page. The Syncfusion PDF library allows you to loop through the Annotations and images in a PDF page. Please find the code snippet for the same as below 
 
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Sample.pdf"); 
 
//Gets the collection of annotations in the PDF page 
foreach (var item in loadedDocument.Pages[0].Annotations) 
{ 
 
} 
 
//Gets the information about the extracted images from PDF page 
foreach (var item in loadedDocument.Pages[0].ImagesInfo) 
{ 
 
} 
 
Please let us know if you need any further assistance in this. 
 
Thanks  Meikandan           

John
Replied On April 9, 2019 01:44 PM UTC


Loop through all pdf elements.

How to do that ?

I need to replace certain text like all "abc" to "ghj" in pdf document and fill certain rectangles with other contents.


John
Replied On April 9, 2019 01:45 PM UTC

Hi John, 
 
According to the structure of the PDF documents, we cannot loop through the PDF elements inside a PDF page. The Syncfusion PDF library allows you to loop through the Annotations and images in a PDF page. Please find the code snippet for the same as below 
 
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Sample.pdf"); 
 
//Gets the collection of annotations in the PDF page 
foreach (var item in loadedDocument.Pages[0].Annotations) 
{ 
 
} 
 
//Gets the information about the extracted images from PDF page 
foreach (var item in loadedDocument.Pages[0].ImagesInfo) 
{ 
 
} 
  Please let us know if you need any further assistance in this.    Thanks  Meikandan           

I need to replace certain texts. Like all "abc" to "ghj" in pdf document and fill certain rectangles with other contents.
Meikanda Nayanar [Syncfusion]
Replied On April 10, 2019 08:58 AM UTC

Hi John, 
We cannot retrieve the bounds of a shape within a PDF document.  
Functionality 
Possibilities 
Replace text 
Possible with a workaround (Please find the details below) 
Replace the content in rectangles  
Not possible 

We can retrieve the position of a text in a PDF document. Please find the below article for replacing a text in a PDF document with Syncfusion PDF library, 
But, still it is workaround and this workaround has its limitations.  
1.       Background color of the replaced text may be different in some cases.  
2.       Font, style and size of the newly added text will not be same as the other text in the paragraph.  
3.       The replaced text should occupy the same space occupied by the older text, if it occupies more space it might lead to text overlap. 
Please let us know if you need any further assistance in this. 
Thanks 
Meikandan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon