logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
felipe@thera.com.br  
#1 Posted : Monday, May 21, 2018 9:09:14 AM(UTC)
felipe@thera.com.br

Rank: Newbie

Groups: Registered
Joined: 5/21/2018(UTC)
Posts: 3
Brazil

Dear friends,

When I extract the text from the pdf file, there are some characters that are placed in the wrong postion.

Per example, in the pdf the text is "INALGEX®, 50 mg/g | 100 m g/g, Gel" and the extracted text is "INALGEX , 50 mg/g | 100 m g/g, Gel ®". The ® moved to the end of the line when the text was extracted. I'm attaching an image showing my problem.

My goal is to extract the full text from the pdf file. I'm using the following function:

public static string ExtractFullText(ppsPdfViewer viewerObj)
{
string fullText = string.Empty;
var doc = viewerObj.Document;
foreach (var page in doc.Pages)
{
//Gets number of characters in a page or -1 for error.
//Generated characters, like additional space characters, new line characters, are also counted.
int totalCharCount = page.Text.CountChars;
//Extract text from page to the string
string pageText = page.Text.GetText(0, totalCharCount);
fullText += pageText;
page.Dispose();
}
return fullText;
}

Any ideas how could I fix these?

Thanks in advance,

Felipe

textExtraction.png (85kb) downloaded 18 time(s).
felipe@thera.com.br  
#2 Posted : Friday, July 13, 2018 7:28:56 AM(UTC)
felipe@thera.com.br

Rank: Newbie

Groups: Registered
Joined: 5/21/2018(UTC)
Posts: 3
Brazil

Any help? Please
Paul Rayman  
#3 Posted : Friday, July 13, 2018 7:43:43 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Could you please provide PDF document
felipe@thera.com.br  
#4 Posted : Friday, July 13, 2018 7:57:46 AM(UTC)
felipe@thera.com.br

Rank: Newbie

Groups: Registered
Joined: 5/21/2018(UTC)
Posts: 3
Brazil

Hi Paul,

This is the file that I used in my tests.

2_Leaflet_Master.pdf (1,416kb) downloaded 5 time(s).

Thanks a lot!

Felipe
Paul Rayman  
#5 Posted : Monday, July 16, 2018 9:56:17 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
A PDF document is not a Flow Document.
PDF contains text objects that have a number of properties, including the coordinates on the page.
In this case, there are four text objects which represent the text in the first line.
In order to convert these text objects to the flowing text, a algoriths is used that take into account the ordinal number of the text objects.
The fact that the text from this line is extracted in same manner in both Pdfium and in such programs as Adobe Reader and Foxit Phatom Reader indicates that the algorithm probably does not have an error. Looks like the problem with the the document. Maybe you need to change the order of text objects.
Please see the video below. I hope that the situation immediately becomes clear.

Edited by user Monday, July 16, 2018 9:57:27 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.