Developer Tools
|
Office Productivity Applications
|
Enterprise Solutions
|
|||||||||||||||||||||||







Important
With the release of Version 4 of PDFtoolkit, form field processing has got simpler. PDF-to-image conversion is much more simpler. A special article titled "Form Fields Creation and Processing Using PDFtoolkit v4" has been written for users of Version 4. This article has been left here for users of older versions of PDFtoolkit.
Last month in our series, we saw how to perform some basic tasks in meeting everyday PDF-related needs.
This month, we will see how to:
function ExtractText(
APageNo: Integer): TStringList;
function ExtractTextFormatted(
APageNo: Integer): TStringList;
This method extracts text from a specified page and returns the text in a TStringList.
PDFDoc: TgtPDFDocument;
LStrList: TStringList;
edExtPageno: TEdit;
edExtTxtFileName: TEdit;
edExtPageno: TEdit;
rbExtTxt: TRadioButton;
...
PDFDoc.LoadFromFile('input_file.pdf')
...
if PDFDoc.IsLoaded then
begin
try
LStrList := TStringList.Create;
if rbExtTxt.Checked then
// Extracts text without worrying about formatting
LStrList :=
PDFDoc.ExtractText((edExtPageno.Text))
else
// Extracts text with whatever formatting is possible
LStrList :=
PDFDoc.ExtractTextFormatted(
StrToInt(edExtPageno.Text));
LStrList.SaveToFile(edExtTxtFileName.Text);
finally
LStrList.Free;
end;
end;
procedure SetFormFieldValue(FieldName: string;
Value: string);
Specify the field name and the new value, and its done.
edEditFormFieldName: TEdit; edNewValue: TEdit; ... if PDFDoc.IsLoaded then begin PDFDoc.SetFormFieldValue( edEditFormFieldName.Text, edNewValue.Text); end; SaveDocument;
TgtPDFFileAttachment, specify the file that needs to be attached, specify the file name for the attachment in the PDF, location where the attachment icon will be, type of the icon used for the attachment, and call the method:
procedure InsertFileAttachment( AFile: TgtPDFFileAttachment; PageNumber: Integer); property FileAttachmentIcon: TgtFileAttachmentIcon read FFileAttachmentIcon write FFileAttachmentIcon; TgtFileAttachmentIcon = (faGraph, faPaperclip, faPushPin, faTag);Here is the code:
LFileAttach: TgtPDFFileAttachment; edAttachment: TEdit; edAttachmentName: TEdit; edAttachPageno: TEdit; ... try LFileAttach := TgtPDFFileAttachment.Create; // pathname of the attachment in the file system LFileAttach.FileName := edAttachment.Text; // name of the attachment in the document LFileAttach.AttachmentName := edAttachmentName.Text; // location of the attachment icon LFileAttach.SetBounds(50,50,300,300); // type of the attachment icon LFileAttach.FileAttachmentIcon := faGraph; // Insert the attachment PDFDoc.InsertFileAttachment( LFileAttach, StrToInt(edAttachPageno.Text)); SaveDocument; finally LFileAttach.Free; end;
Downloads:
---o0O0o---
| Our Developer Tools | |
|---|---|
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
XtremePDFConverter VCLA Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents. |
|
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
XtremeDocumentStudio .NETMulti-format document-processing component suite for .NET developers |
PDFOne (for Java™)A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications. |
XtremeFontEngine (for Java)Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts |
| Our Office Productivity Applications |
|---|
Free PDF ReaderA free, fast, and portable application for viewing, printing and converting PDF documents. |
| Privacy | Legal | Feedback | Newsletter | Resellers | © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved. |
This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).