mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 06:09:22 +02:00
* Simple examples for reading
This commit is contained in:
parent
bd4b3af8b6
commit
ca97f25979
38
packages/fcl-pdf/examples/simpleread.pp
Normal file
38
packages/fcl-pdf/examples/simpleread.pp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
{$h+}
|
||||||
|
uses fppdfobjects, fppdfparser, sysutils, classes;
|
||||||
|
|
||||||
|
procedure ReadPDF(const aStream: TStream; aDoc: TPDFDocument);
|
||||||
|
|
||||||
|
var
|
||||||
|
aParser : TPDFParser;
|
||||||
|
|
||||||
|
begin
|
||||||
|
aParser:=TPDFParser.Create(aStream);
|
||||||
|
try
|
||||||
|
aParser.ResolveToUnicodeCMaps:=True;
|
||||||
|
aParser.ParseDocument(aDoc);
|
||||||
|
finally
|
||||||
|
aParser.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
F : TFileStream;
|
||||||
|
Doc : TPDFDocument;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if ParamCount<1 then
|
||||||
|
begin
|
||||||
|
Writeln('Usage : simpleread filename');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
F:=TFileStream.Create(paramstr(1),fmCreate or fmShareDenyNone);
|
||||||
|
try
|
||||||
|
Doc:=TPDFDocument.Create;
|
||||||
|
ReadPDF(F,Doc);
|
||||||
|
finally
|
||||||
|
doc.free;
|
||||||
|
f.free;
|
||||||
|
end;
|
||||||
|
end.
|
20
packages/fcl-pdf/examples/simpleread2.pp
Normal file
20
packages/fcl-pdf/examples/simpleread2.pp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
{$h+}
|
||||||
|
uses fppdfobjects, fppdfparser;
|
||||||
|
|
||||||
|
var
|
||||||
|
Doc : TPDFDocument;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if ParamCount<1 then
|
||||||
|
begin
|
||||||
|
Writeln('Usage : simpleread filename');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
Doc:=TPDFDocument.Create;
|
||||||
|
try
|
||||||
|
Doc.LoadFromFile(paramstr(1));
|
||||||
|
finally
|
||||||
|
doc.free;
|
||||||
|
end;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user