I am a bit confused as to how to add text to a PDF document via your API. Here's my situation: I'm dealing with PDF files that are essentially images of paper documents that have been scanned in. I first extract a TIFF image of each page of the PDF and send it to my OCR engine. The OCR engine give be back an array of words with positioning coordinates of each word. I then need to place each word in a text object on the pdf page so it lines up behind the part of the image where the word is located. The text also need to be invisible.
I'm making the switch from the Amyuni PDF product. In that product, they talk in terms of Objects. In this case, I created a "Text Object", filled out its attributes, and placed in on the page. Below is a quick example of some Delphi code used with Amyui to place some text on a page:
FPDF.CreateObject(acObjectTypeText, AName);
with FPDF.GetObjectByName(AName) do
begin
Attribute['TextFont'] := Format('%s, %d, %s, %s, 0', [_OCRFont, AFontSize, ABoldText, AItalicText]);
Attribute['Text'] := AWord.Text;
Attribute['Left'] := AWord.Left;
Attribute['Right'] := AWord.Left + AWord.Width;
Attribute['Top'] := AWord.Top;
Attribute['Bottom'] := AWord.Top + AWord.Height;
Attribute['TextColor'] := AWord.Color;
Attribute['TextRenderingMode'] := _TextRenderMode;
end;
I'm trying to find the equivalent of this in your PDF Tools SDK. I see talk of Annotations, but it says that is like the skicky notes which I don't think will work here.
I'm also looking for a way to pull out the names of all form fields on a page as well as to set their values via code.
I'm new to PDF Tools SDK so I may be missing something, but I have read most of the documentation.
Adding Text to a PDF Document
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Adding Text to a PDF Document
Hello,
Maybe this small Delphi 7 sample can help you.
HTH.
Maybe this small Delphi 7 sample can help you.
HTH.
- Attachments
-
- AddTextToPDF.zip
- (214.09 KiB) Downloaded 159 times
Re: Adding Text to a PDF Document
Ok. I see that to add text I need to use the PXC Library and not the XCPRO Library. However, this brings up a big issue for me. The PXC Library and the demo you sent can add text to a "new" PDF page. I need to add this text to an "existing" PDF page. When I OCR my existing PDF document, I have to place the OCR text back in that same document.
Is there any way to add text to and EXISTING PDF document?
Is there any way to add text to and EXISTING PDF document?
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Adding Text to a PDF Document
You will need to create new PDF with all required text and then just merge it with existed PDF using PXCp_PlaceContents function.
HTH
HTH
Re: Adding Text to a PDF Document
Perfect. Would you happen to have a Delphi Example for this?
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Adding Text to a PDF Document
Here is base sample:
- Attachments
-
- AddTextToPDF2.zip
- (299.93 KiB) Downloaded 168 times