| |
TRolePDF is a FREE VCL component for Borland Delphi and C++Builder. It includes a
TCanvas for creating Adobe .pdf files. It
uses our PDF.DLL to create the .pdf files. We use it in
our Rolehelp and PDF Creator to create the
.pdf documents. Note: The PDF.DLL is
designed to support .rtf and .html files drawing methods
(using Rich Editors like TRichView), so NOT all
TCanvas properties and methods are supported (like Arc,
Poly…) because it is not required to draw .rtf and
.html files.
Users of
TRichView may download the
freeware VCL TRichViewPDF on the Components page to create
.pdf documents automatically from TRichView.
Why
a DLL not a VCL:
Because DLL is supported by all versions
of Delphi and C++Builder.
License:
-
The PDF.DLL is Royalty Free.
- The PDF.DLL can be used or deployed only with the End
User (consumer) Products such as Applications, etc...
- The PDF.DLL can NOT be used in
developing other components or deployed with others
developers products such as VCL, ActiveX, COM, etc…
Delphi
Example:
with
TRolePDF.Create(nil) do
try
FileName := ‘myfile.pdf’;
PageSize := psA4;
BeginDoc;
Canvas… // use TCanvas properties and
methods
NewPage;
Canvas…
EndDoc;
Parent := AddOutline(‘Header’, -1, 1, 0);
AddOutline(‘Page 1’, Parent, 1, 0);
finally
Free;
end;
C++Builder
Example:
TRolePDF
*pdf = new TRolePDF(this);
pdf->FileName = "myfile.pdf";
pdf->BeginDoc();
pdf->Canvas->Font->Name = "Verdana";
pdf->Canvas->Font->Size = 10;
pdf->Canvas->Font->Charset = ANSI_CHARSET;
pdf->Canvas->TextOut(50, 50, "Sample Text");
pdf->EndDoc();
delete pdf;
 |
Uses
True Type Fonts as WinAnsiEncoding and Costum
Encoding. |
 |
PDF
version will be set to PDF-1.2 (adobe 3.0-6.0),
but if unicode characters were used the PDF
version will be set to PDF-1.5 (adobe 6 and up
only). |
 |
Page
stream, and XObjects will be compressed
automatically. |
 |
Resolution
is set to Screen Pixels Per Inch automatically. |
 |
Support
of nested outlines (Table of Contents) |
 |
AcroForm
is not implemented (not required to draw .rtf or
.html files). |
 |
Java
is not implemented (not required to draw .rtf or
.html files). |
 |
Trial
version is limited to create 10 pages per .pdf
file without watermark, stamp or any other
special remarks to the author. It is useful to
create documents like data sheets, features
matrix, what's new, quick start guide, etc... |
 |
Security
not implemented yet (owner password, User
password, can print, edit...). |
 |
Url
links not implemented yet. |
 |
TRolePDF.Canvas
is a TMetaFileCanvas. |
 |
When
playing the MetaFile all images will be read as a
TBitmap. |
 |
Images
PixelFormat will be set to pf24bit and will be
compressed using Delphi zlib (included with
Delphi Pro). |
 |
Outlines
is a TList converted to Adobe .pdf commands
according to Adobe PDFReference.pdf using the
/FitH operator on EndDoc method.
TOutline = class(TObject)
private
// user vars
Title: string;
Parent: integer;
PageNo: integer;
Top: integer;
Level: integer;
// internal vars
Obj: integer;
ParentObj: integer;
First: integer;
Next: integer;
Count: integer;
end;function
TRolePDF.AddOutline(Title: string; ParentObj,
PageNo, TopPos: integer): integer;
var
Parent: integer;
Outline: TOutline;
begin
Outline := TOutline.Create;
if ParentObj in [0..FOutlines.Count - 1] then
begin
Parent := ParentObj;
Inc(TOutline(FOutlines[Parent]).Count);
Outline.Level :=
TOutline(FOutlines[Parent]).Level + 1;
end
else
Parent := -1;
Outline.Title := Title;
Outline.Parent := Parent;
Outline.PageNo := PageNo;
Outline.Top := TopPos;
FOutlines.Add(Pointer(Outline));
result := FOutlines.Count - 1;
end;
|
 |
Playing
the MetaFile loop:
while PEMR(Ptr).iType <>
EMR_EOF do begin
case PEMR(Ptr).iType of
EMR_SETVIEWPORTORGEX:
emrSetViewPortOrgEx(Ptr);
EMR_SETTEXTCOLOR: emrSetTextColor(Ptr);
EMR_SETBKCOLOR: emrSetBKColor(Ptr);
EMR_EXTTEXTOUTA, EMR_EXTTEXTOUTW:
emrExtTextOut(Ptr);
EMR_EXTCREATEFONTINDIRECTW:
emrCreateFontInDirectW(Ptr);
EMR_CREATEPEN: emrCreatePen(Ptr);
EMR_CREATEBRUSHINDIRECT:
emrCreateBrushInDirect(Ptr);
EMR_MOVETOEX: emrMoveToEx(Ptr);
EMR_LINETO: emrLineTo(Ptr);
EMR_RECTANGLE: emrRectangle(Ptr);
EMR_BITBLT: emrBitBLT(Ptr);
EMR_STRETCHBLT, EMR_STRETCHDIBITS,
EMR_SETDIBITSTODEVICE: emrStretchDiBits(Ptr);
end;
Ptr := Pointer(Cardinal(Ptr) + PEMR(Ptr).nSize);
end; |
 |
if
Outlines.Count > 0 then PageMode will be set
to '/UseOutlines' automatically else PageMode
will be set to '/UseNone'. |
 |
PageLayout
will be set to '/OneColumn'. Adobe Acrobat users
can use the arrow keys or the mouse to scroll the
document pages. |
 |
Viewer
Preferences not supported. The Adobe Acrobat will
use its default viewer preferences. |
 |
Multi-Pagesize
not supported (i.e. Page1 size = psA4, Page2 size
= psLetter) because the TRolePDF design is
intended to support only drawing .rtf and .html
files (but can be added if requested). |
 |
If
Canvas.Font.Charset = DEFAULT_CHARSET then it
will be changed to ANSI_CHARSET as the .pdf
Default Charset, so avoid using DEFAULT_CHARSET. |
 |
PDF
Document saving sequence:
1. info
2. page stream
3. fonts
4. images
5. page kids
6. resources (xobject, font)
7. page obj
8. outlines
9. catalog
10. trailer
11. xref |
 |
Each
Text will be saved as one line on the page
stream:
BT 60.75 766.472 Td /TT1 12 Tf 0 0
0 RG 0 0 0 rg -0.035 Tc (Sample Text) Tj ET
Each Image will be saved as one line on the page
stream:
q 18.75 0 0 18.75 61.5 635 cm /x1
Do Q |
 |
Because
the design is intended to support drawing .rtf
and .html files only 3 paper sizes is implemented
as psA4, psLetter, and psLegal otherwise use the
psCustom and set the PageWidth, PageHeight
manually. |
| |
|
|
|
 |
|