I have used GetPageText() function which successfully extracts the text but the format is not retained. I mean all white spaces have been removed between words and paragraphs.
I have also tried to use GetPageTextWithCoords() function, which returns the text with coordinates. This can be useful but is their easier way to transform this to text only?
I know it is hard with different font and text sizes. But is there a inbuilt function which can extract text to a nearest position in terms of white spaces, new lines and paragraphs? In other words I want the page text from to retain text position and coordinates in the text file as well as closely resemble as possible from PDF.
The main "issue" here comes from the definition of the PDF format.
The text how you can see it on the page in your PDF document is written in a totally different way behind the scene. So even if you see some text drawn in the same line on the page, it may not be the real line in the document content.
The GetPageText() method extracts text with all spaces if those are there, it means if the text is really separated with space characters. But if the text is aligned in the same line, it can be in reality two separate texts with no real spaces. So the text is extracted without "formatting".
And if we take into consideration also font and font size, it is almost impossible to implement such a feature without some heuristics behind.
Using both methods GetPageTextWithCoords() and GetPageTextWithCoordsEx() you can implement your own parser to be able to obtain the page formatting you want:
http://guides.gdpicture.com/content/web ... oords.html
http://guides.gdpicture.com/content/web ... rdsEx.html
Who is online
Users browsing this forum: No registered users and 0 guests