Re: PDF as data entry for web
- From: "Eddie Shipman" <mr_delphi_developer at yahoo dot com>
- Date: 29 Jun 2006 10:24:57 -0700
Billy wrote:
Is there a component that will let me display a PDF document with
dataentry fields inside a web page and then let me extract those
fields when the page submitted?
Thanks
You can use an FDF file to accomplish that.
See this Delphi conversion of the articles here:
http://www.15seconds.com/issue/010822.htm
http://www.15seconds.com/issue/010823.htm
{Download the files from the article to get FormTest.PDF}
procedure TForm1.Button1Click(Sender: TObject);
function GetFieldName(AString: String):String;
begin
Result := '';
Result := StringReplace(AString, '/T', '', [rfReplaceALL]);
Result := StringReplace(Result, '(', '', [rfReplaceALL]);
Result := StringReplace(Result, ')', '', [rfReplaceALL]);
Result := Trim(Result);
end;
var
slForm: TStringList;
slData: TStringList;
sFormName, sFieldName: String;
i, x: Integer;
begin
sFormName := 'c:\FormTest.fdf';
slData := TStringList.Create;
slData.Add('txtFirstName=MrBaseball34');
slData.Add('txtExperience=11 yrs Delphi;');
slData.Add('chkVBS=No');
slData.Add('radGender=Male');
slData.Add('selSite=microsoft.com');
slData.Add('selColor=#990033');
slForm := TStringList.Create;
try
slForm.LoadFromFile(sFormName);
for i := 0 to slForm.Count-1 do
begin
if Copy(slForm[i], 1, 2) = '/T' then
begin
sFieldName := GetFieldName(slForm[i]);
for x := 0 to slData.count-1 do
if slData.IndexOfName(sFieldName) > -1 then
if sFieldName = 'selColor' then
begin
slForm[i+2] := '/V (' + slData.Values[sFieldName] + ')';
break;
end
else
begin
slForm[i+1] := '/V (' + slData.Values[sFieldName] + ')';
break;
end;
end;
end;
slForm.SaveToFile(sFormName);
ShellExecute(0, 'open', PChar(sFormName), 'c:\FormTest.pdf', 'c:\',
sw_show);
finally
slForm.Free;
slData.Free;
end;
end;
Resulting FDF file text:
Note that this line: /F (c:\FormTest.pdf)
determines the PDF File to be filled in.
%FDF-1.2
1 0 obj
<<
/FDF
<<
/Fields
[
<<
/T (txtFirstName)
/V (MrBaseball34)
<<
/T (txtExperience)
/V (6year Delphi;9 months in HTML, 6 months in ASP & VBScript, 1 month
in JavaScript, CSS2 & DOM)
<<
/T (chkVBS)
/V (No)
<<
/T (radGender)
/V (Male)
<<
/T (selSite)
/V (microsoft.com)
<<
/T (selColor)
/Opt [(#6699FF) (#0000CC) (#990033) (#000080) (#FFCC00)]
/V (#990033)
]
/F (c:\FormTest.pdf)
endobj
trailer
<<
/Root 1 0 R
%%EOF
--
.
- Follow-Ups:
- Re: PDF as data entry for web
- From: Billy
- Re: PDF as data entry for web
- References:
- PDF as data entry for web
- From: Billy
- PDF as data entry for web
- Prev by Date: PDF as data entry for web
- Next by Date: Re: Thread day for Scott Martin
- Previous by thread: PDF as data entry for web
- Next by thread: Re: PDF as data entry for web
- Index(es):