Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Oct 13, 2023 7:05 am

Hi, I am working for getting Paragraph details and their Positions from a PDF file in java. I perused the Spire PDF java and got some results with lines of Text and its Positions. But I need in the format of Paragraphs. Kindly help on it.
Code: Select all
public static void newTextPositions(PdfPageBase page) {
 PdfSection sec = page.getSection();
 PdfDocumentBase base = sec.getDocument();
 PdfTextFindCollection collection = page.findAllText();
 for (PdfTextFind find : collection.getFinds()) {
 // Get text position
 Point2D point = find.getPosition();
 find.applyHighLight(Color.BLUE);
 // Get text content
 String str = find.getMatchText();
 // Get text size
 Dimension2D size = find.getSize();
 System.out.println(str + "==" + point.toString() + size.toString());
 }

 }

moorthys
 
Posts: 3
Joined: Fri Oct 13, 2023 6:45 am

Fri Oct 13, 2023 7:38 am

Hi,

Thank you for your inquiry.
PDF documents do not contain the concept of paragraphs as you mentioned. PDF is a fixed-layout format, meaning the text is laid out on a page in a pre-defined manner.

Unlike in a word processing document like Word, where text can be formatted into paragraphs and other elements using specific styles and layout options, PDF documents are primarily designed for print output and are based on vector graphics.

In PDF, text is painted onto the page using specific font, size, color, and other attributes. The layout of the text is fixed, and cannot be easily modified or interactively edited like in a word processing document.

I hope this information helps. If you have any other questions or need further assistance, please let me know.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Fri Oct 13, 2023 9:01 am

Thanks for your response..any alternative solution to get paragraphs?

moorthys
 
Posts: 3
Joined: Fri Oct 13, 2023 6:45 am

Fri Oct 13, 2023 9:25 am

Hi,

Thanks for your feedback.
PDF documents do not contain the concept of paragraphs, so they cannot be obtained. If you have any other questions, just feel free to contact us. We are here to assist you.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF