I’m new to the PDF API and Aspose.Pdf in particular, so I don’t know how to get to certain parts of a document, or if it is even available or possible.
Hello Tim,
Thanks for your interest in our products.
I am pleased to share that you can add text paragraphs inside PDF document and assign a particular ID to it but I am afraid it does not support the feature to to extract text paragraph based on particular ID or name associated with it. Please note that in order to add text paragraph along with its ID, you need to make use of Aspose.Pdf.Generator namespace. The Text object is a paragraph level element and you can assign particular ID to it. For more information, please visit [Assign ID to Paragraph ](http://docs.aspose.com/display/pdfnet/Assign+ID+to+Paragraph)
You can use some Regular expression to extract text from PDF document. For this purpose, you need to try using Aspose.Pdf namespace. For more information, please visit Search and Get Text From All Pages Using Regular Expression
PS, please note that I have logged the requirement of extracting text based on particular ID as PDFNEWNET-33444 in our issue tracking system. We will further look into the details of this requirement and see how we can implement this feature. Please be patient and spare us little time. We apologize for your inconvenience.
You say that I cannot get a paragraph by its ID. That’s fine, but can I iterate over all the paragraphs in a document, and will each paragraph object then contain the ID? That’s really all I need.
Hello Tim,
Pdf pdf = new Pdf();
// create section inside PDF
Aspose.Pdf.Generator.Section sec = pdf.Sections.Add();
// create a sample text paragraph
Text para1 = new Aspose.Pdf.Generator.Text(“Text Paragraphs with ID Text1”);
// assign ID to text paragraph
para1.ID = “Text1”;
// add paragraph to paragraphs collection of section object
sec.Paragraphs.Add(para1);
// create a sample text paragraph
Text para2 = new Aspose.Pdf.Generator.Text(“Text Paragraphs with ID Text2”);
// assign ID to text paragraph
para2.ID = “Text2”;
// add paragraph to paragraphs collection of section object
sec.Paragraphs.Add(para2);
// save the resultnat PDF file
pdf.Save(“D:/pdftest/Pdf_2_Paragraphs.pdf”);