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







In the new version of eDocEngine, the PDF engine provides full support for Unicode. This means that eDocEngine can:
Classes.TBidiMode.In eDocEngine v2.x, the PDF engine class TgtPDFEngine had a boolean property Bidi. In Version 3, this property is replaced with another property BiDiMode. You can use a Classes.TBidiMode enum value to set the value of this property.
Following is some sample code that illustrates Unicode capabilities of the PDF engine. In this code snippet, text in several non-English languages are rendered on a page under different bidirectional text modes. The default page font is set to Arial. However, to render text whose glyphs are not present in Arial, the PDF engine automatically finds a more suitable font. All of these fonts are set to be subset embedded in the code. Arial has been excluded from getting embedded, simply to demonstrate that it is possible to exclude certain fonts in that way.
program Demo_eDocEngine_Unicode_Demo;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes, Graphics, TypInfo,
gtCstPDFEng, gtCstDocEng, gtPDFEng;
var
gtPDFEngine1: TgtPDFEngine;
ArabicStr, BrazilianPortugueseStr, ChineseStr, DeutschStr, EspañolStr,
FrenchStr, HebrewStr, JapaneseStr, MalayalamStr,
SanskritStr, RussianStr, TamilStr, ThaiStr: WideString;
y: Double;
BidiModeIterator: TBidiMode;
begin
ArabicStr :=
'من الحبة تنشأ الشجرة';
BrazilianPortugueseStr :=
'Toda regra tem uma exceção';
ChineseStr :=
'人要脸树要皮';
DeutschStr :=
'Das Eisen schmieden, solange es heiß ist';
EspañolStr :=
'Más vale maña que fuerza';
FrenchStr :=
'L''on est bien faible quand on est amoureux';
HebrewStr :=
'אל תסתכל בקנקן, אלא במה שבתוכו';
JapaneseStr :=
'たげいはむげい';
MalayalamStr :=
'പിത്തള മിനുക്കിയാല് പൊന്നാവില്';
RussianStr :=
'Два медве́дя в одно́й берло́ге не живу́т';
SanskritStr :=
'धर्मो रक्षति रक्षितः';
TamilStr :=
'அறம் செய விரும்பு';
ThaiStr :=
'แมลงเม่าบินเข้ากองไฟ';
gtPDFEngine1 := TgtPDFEngine.Create(nil);
try
with gtPDFEngine1 do begin
Font.Name := 'Arial';
Font.Size := 13;
Page.PaperSize := A3;
Preferences.ShowSetupDialog := False;
Preferences.OpenAfterCreate := True;
Preferences.EmbedTrueTypeFonts := etfSubset;
FontEmbedExcludeList.Add('Arial'); // Do not embed Arial
Filename := 'edocengine_v3_Unicode_Demo.pdf';
BeginDoc;
y := 0.2;
// Write text in multiple BiDi modes
for BidiModeIterator := Low(TBidiMode) to High(TBidiMode) do begin
BiDiMode := BidiModeIterator;
Textout(4, y, 'BiDimode is ' +
GetEnumName(TypeInfo(TBiDiMode), Ord(BidiModeIterator)));
// Render text in different languages
TextOut(4, y + 0.2, ArabicStr);
TextOut(4, y + 0.45, BrazilianPortugueseStr);
TextOut(4, y + 0.7, ChineseStr);
TextOut(4, y + 0.95, DeutschStr);
TextOut(4, y + 1.2, EspañolStr);
TextOut(4, y + 1.45, FrenchStr);
TextOut(4, y + 1.7, HebrewStr);
TextOut(4, y + 1.95, JapaneseStr);
TextOut(4, y + 2.2, MalayalamStr);
TextOut(4, y + 2.45, RussianStr);
TextOut(4, y + 2.7, SanskritStr);
TextOut(4, y + 2.95, TamilStr);
TextOut(4, y + 3.2, ThaiStr);
TextOut(4, y + 3.45, ArabicStr + // Mixed-language string
' From the seed, grows the tree ');
y := y + 3.45 + 0.6;
end;
EndDoc;
end;
except
on E: Exception do begin
Writeln('Sorry, an error occured in ' +
E.ClassName, ' with message ', E.Message);
end;
end;
Writeln('Press Enter to quit');
Readln;
end.
And, here is the output in screenshots.
bdRightToLeftNoAlign and bdRightToLeft Bidirectional Text Modes
bdRightToLeftNoAlign and bdRightToLeftReadingOnly Bidirectional Text ModesFinally, examine the fonts used in the document.
Thanks to the automatic and intelligent font mapping, you do not have to specify Arial Unicode MS or some other big polyglot Unicode font to support multiple languages. eDocEngine Version 3 does all that internally. You only need to have the appropriate fonts installed in Windows.
Please note that the above code snippet requires the PAS file to be Unicode-encoded. You will be able to use it in Delphi 2007, 2009 or 2010. If you are using an older version of Delphi, then you could read the Unicode strings from a stream and store them in a TWideStringList. Alternatively, you could load them off TNT Delphi Unicode Components.
The test phrases and the meanings are listed below.
---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).