RxFPC: replace LazFreeType to fpTTF in TRxDBGridExportPDF. Now TRxDBGridExportPDF work with ODF fonts. Fix errors.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5094 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-08-19 13:31:56 +00:00
parent 9dc6e186e3
commit 9be6f7eac5
5 changed files with 666 additions and 484 deletions

View File

@ -68,7 +68,7 @@
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Exceptions Count="4">
<Item1>
<Name Value="EAbort"/>
</Item1>
@ -78,6 +78,9 @@
<Item3>
<Name Value="EFOpenError"/>
</Item3>
<Item4>
<Name Value="ETTF"/>
</Item4>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -3,13 +3,13 @@
<ProjectSession>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="67">
<Units Count="80">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="81" Y="12"/>
<UsageCount Value="80"/>
<UsageCount Value="107"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@ -18,9 +18,9 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<TopLine Value="179"/>
<CursorPos X="8" Y="176"/>
<UsageCount Value="80"/>
<TopLine Value="127"/>
<CursorPos Y="141"/>
<UsageCount Value="107"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -30,15 +30,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="143"/>
<CursorPos X="31" Y="32"/>
<UsageCount Value="15"/>
<UsageCount Value="12"/>
</Unit2>
<Unit3>
<Filename Value="../../rxdbgrid.pas"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="482"/>
<CursorPos X="41" Y="496"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
<UsageCount Value="28"/>
</Unit3>
<Unit4>
<Filename Value="rxdbgridexportpdf.pas"/>
@ -46,28 +45,28 @@
<EditorIndex Value="-1"/>
<TopLine Value="51"/>
<CursorPos X="69" Y="76"/>
<UsageCount Value="16"/>
<UsageCount Value="13"/>
</Unit4>
<Unit5>
<Filename Value="../../rxdconst.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="161"/>
<CursorPos X="18" Y="177"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit5>
<Unit6>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/classes/reader.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="964"/>
<CursorPos Y="986"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit6>
<Unit7>
<Filename Value="../../../OPTORG/alexs/3/examples/testfppdf.lpr"/>
<EditorIndex Value="-1"/>
<TopLine Value="107"/>
<CursorPos Y="133"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit7>
<Unit8>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
@ -75,25 +74,29 @@
<EditorIndex Value="-1"/>
<TopLine Value="530"/>
<CursorPos X="15" Y="544"/>
<UsageCount Value="24"/>
<UsageCount Value="21"/>
</Unit8>
<Unit9>
<Filename Value="../../registerrxdb.pas"/>
<UnitName Value="RegisterRxDB"/>
<EditorIndex Value="-1"/>
<CursorPos X="23" Y="10"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit9>
<Unit10>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<UnitName Value="RxDBGridExportPdf"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="656"/>
<CursorPos Y="680"/>
<UsageCount Value="38"/>
<Bookmarks Count="1">
<Item0 Y="696" ID="1"/>
<TopLine Value="381"/>
<CursorPos X="54" Y="381"/>
<UsageCount Value="51"/>
<Bookmarks Count="5">
<Item0 X="3" Y="856" ID="1"/>
<Item1 X="3" Y="457" ID="2"/>
<Item2 Y="418" ID="3"/>
<Item3 X="18" Y="519" ID="4"/>
<Item4 X="15" Y="329" ID="5"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit10>
@ -103,53 +106,51 @@
<EditorIndex Value="-1"/>
<TopLine Value="140"/>
<CursorPos X="3" Y="145"/>
<UsageCount Value="16"/>
<UsageCount Value="13"/>
</Unit11>
<Unit12>
<Filename Value="../../../OPTORG/alexs/1/1/testfppdf.lpr"/>
<EditorIndex Value="-1"/>
<TopLine Value="145"/>
<CursorPos X="13" Y="166"/>
<UsageCount Value="20"/>
<UsageCount Value="17"/>
</Unit12>
<Unit13>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-pdf/src/fpparsettf.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="344"/>
<CursorPos Y="365"/>
<UsageCount Value="12"/>
<UsageCount Value="9"/>
</Unit13>
<Unit14>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/sysutils/sysutilh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="97"/>
<CursorPos X="19" Y="112"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit14>
<Unit15>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-pdf/src/fpttfencodings.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="2025"/>
<CursorPos X="3" Y="2100"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit15>
<Unit16>
<Filename Value="../../../lazutils/lazfreetypefontcollection.pas"/>
<UnitName Value="LazFreeTypeFontCollection"/>
<EditorIndex Value="6"/>
<EditorIndex Value="-1"/>
<TopLine Value="331"/>
<CursorPos Y="352"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
<UsageCount Value="34"/>
</Unit16>
<Unit17>
<Filename Value="../../../lazutils/easylazfreetype.pas"/>
<UnitName Value="EasyLazFreeType"/>
<EditorIndex Value="3"/>
<TopLine Value="36"/>
<CursorPos X="3" Y="50"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="1214"/>
<CursorPos X="13" Y="1224"/>
<UsageCount Value="36"/>
</Unit17>
<Unit18>
<Filename Value="../../../../examples/lazfreetype/mainform.pas"/>
@ -159,7 +160,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="51"/>
<CursorPos X="78" Y="61"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit18>
<Unit19>
<Filename Value="../../../lazutils/ttfile.pas"/>
@ -167,28 +168,28 @@
<EditorIndex Value="-1"/>
<TopLine Value="234"/>
<CursorPos X="4" Y="242"/>
<UsageCount Value="13"/>
<UsageCount Value="10"/>
</Unit19>
<Unit20>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/sysutils/finah.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="10"/>
<CursorPos X="10" Y="25"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit20>
<Unit21>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/sysutils/fina.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="100"/>
<CursorPos X="3" Y="105"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit21>
<Unit22>
<Filename Value="../../../install/source/fpcsrc/rtl/inc/fexpand.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="226"/>
<CursorPos X="10" Y="106"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit22>
<Unit23>
<Filename Value="../../../tachart/tadraweropengl.pas"/>
@ -196,7 +197,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="218"/>
<CursorPos Y="220"/>
<UsageCount Value="12"/>
<UsageCount Value="9"/>
</Unit23>
<Unit24>
<Filename Value="../../../lazutils/fileutil.pas"/>
@ -204,14 +205,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="220"/>
<CursorPos X="17" Y="235"/>
<UsageCount Value="13"/>
<UsageCount Value="10"/>
</Unit24>
<Unit25>
<Filename Value="../../../lazutils/fileutil.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1019"/>
<CursorPos X="3" Y="1024"/>
<UsageCount Value="13"/>
<UsageCount Value="10"/>
</Unit25>
<Unit26>
<Filename Value="../../../lazutils/lazfileutils.pas"/>
@ -219,7 +220,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="719"/>
<CursorPos Y="736"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit26>
<Unit27>
<Filename Value="../../../tachart/backup/tadraweropengl.pas"/>
@ -227,13 +228,13 @@
<EditorIndex Value="-1"/>
<TopLine Value="208"/>
<CursorPos X="20" Y="224"/>
<UsageCount Value="6"/>
<UsageCount Value="3"/>
</Unit27>
<Unit28>
<Filename Value="unit1.lfm"/>
<EditorIndex Value="-1"/>
<TopLine Value="231"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
<DefaultSyntaxHighlighter Value="LFM"/>
</Unit28>
<Unit29>
@ -242,14 +243,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="3503"/>
<CursorPos X="3" Y="3506"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit29>
<Unit30>
<Filename Value="C:/lazarus/components/lazutils/easylazfreetype.pas"/>
<UnitName Value="EasyLazFreeType"/>
<EditorIndex Value="-1"/>
<CursorPos X="14" Y="160"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit30>
<Unit31>
<Filename Value="C:/lazarus/components/lazutils/lazfreetypefontcollection.pas"/>
@ -257,28 +258,28 @@
<EditorIndex Value="-1"/>
<TopLine Value="127"/>
<CursorPos X="50" Y="141"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit31>
<Unit32>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="76"/>
<CursorPos X="56" Y="91"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit32>
<Unit33>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/sysutils/sysinth.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="122"/>
<CursorPos X="58" Y="137"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit33>
<Unit34>
<Filename Value="../../vclutils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="125"/>
<CursorPos Y="155"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit34>
<Unit35>
<Filename Value="../../rxshortcutunit.pas"/>
@ -288,41 +289,41 @@
<UnitName Value="rxShortCutUnit"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit35>
<Unit36>
<Filename Value="../../rxctrls.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="40"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit36>
<Unit37>
<Filename Value="../../rxapputils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="28"/>
<CursorPos X="83" Y="64"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit37>
<Unit38>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/sqldb/sqldb.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="439"/>
<CursorPos X="3" Y="454"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit38>
<Unit39>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/db.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1339"/>
<CursorPos X="3" Y="1354"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit39>
<Unit40>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/dataset.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="473"/>
<CursorPos X="3" Y="476"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit40>
<Unit41>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/bufdataset.pas"/>
@ -330,7 +331,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="458"/>
<CursorPos X="3" Y="446"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
<Bookmarks Count="1">
<Item0 X="3" Y="3449" ID="1"/>
</Bookmarks>
@ -339,21 +340,21 @@
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/bufdataset_parser.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="20" Y="18"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit42>
<Unit43>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/dbase/dbf_prscore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="34"/>
<CursorPos X="3" Y="43"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit43>
<Unit44>
<Filename Value="../../rxmemds.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="25"/>
<CursorPos X="47" Y="40"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
<Bookmarks Count="1">
<Item0 X="33" Y="131" ID="2"/>
</Bookmarks>
@ -363,64 +364,64 @@
<EditorIndex Value="-1"/>
<TopLine Value="136"/>
<CursorPos X="14" Y="155"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit45>
<Unit46>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/dbase/dbf.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="2336"/>
<CursorPos X="3" Y="2338"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit46>
<Unit47>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/dbase/dbf_parser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="162"/>
<CursorPos X="5" Y="87"/>
<UsageCount Value="7"/>
<UsageCount Value="4"/>
</Unit47>
<Unit48>
<Filename Value="../../rxdb/rxmemds_parser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="186"/>
<CursorPos X="3" Y="189"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit48>
<Unit49>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/dbase/dbf_common.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="95"/>
<CursorPos X="10" Y="110"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit49>
<Unit50>
<Filename Value="../../../../lcl/grids.pas"/>
<UnitName Value="Grids"/>
<EditorIndex Value="5"/>
<EditorIndex Value="-1"/>
<TopLine Value="11194"/>
<CursorPos Y="11210"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
<UsageCount Value="14"/>
</Unit50>
<Unit51>
<Filename Value="../../../lazutils/lazfreetype.pas"/>
<UnitName Value="LazFreeType"/>
<EditorIndex Value="-1"/>
<TopLine Value="512"/>
<CursorPos X="5" Y="520"/>
<UsageCount Value="13"/>
<TopLine Value="814"/>
<UsageCount Value="10"/>
</Unit51>
<Unit52>
<Filename Value="../../../lazutils/ttobjs.pas"/>
<UnitName Value="TTObjs"/>
<EditorIndex Value="-1"/>
<UsageCount Value="8"/>
<TopLine Value="364"/>
<CursorPos X="3" Y="382"/>
<UsageCount Value="13"/>
</Unit52>
<Unit53>
<Filename Value="../../../lazutils/tttables.pas"/>
<UnitName Value="TTTables"/>
<EditorIndex Value="-1"/>
<UsageCount Value="8"/>
<UsageCount Value="5"/>
</Unit53>
<Unit54>
<Filename Value="../../../../lcl/dbgrids.pas"/>
@ -428,15 +429,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="4071"/>
<CursorPos Y="4090"/>
<UsageCount Value="10"/>
<UsageCount Value="7"/>
</Unit54>
<Unit55>
<Filename Value="../../../../lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="48"/>
<CursorPos X="59" Y="63"/>
<UsageCount Value="14"/>
<CursorPos X="14" Y="17"/>
<UsageCount Value="13"/>
</Unit55>
<Unit56>
<Filename Value="../../../../lcl/lcltype.pp"/>
@ -444,7 +444,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="1629"/>
<CursorPos X="3" Y="1644"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit56>
<Unit57>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-image/src/fpimage.pp"/>
@ -452,7 +452,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="37"/>
<CursorPos X="4" Y="45"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit57>
<Unit58>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
@ -463,7 +463,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="57"/>
<CursorPos X="23" Y="81"/>
<UsageCount Value="22"/>
<UsageCount Value="19"/>
</Unit58>
<Unit59>
<Filename Value="../../rxdbgridexportspreadsheet_paramsunit.pas"/>
@ -474,7 +474,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="3" Y="46"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit59>
<Unit60>
<Filename Value="../../../../lcl/controls.pp"/>
@ -482,23 +482,21 @@
<EditorIndex Value="-1"/>
<TopLine Value="5"/>
<CursorPos X="14" Y="19"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit60>
<Unit61>
<Filename Value="/home/OPTORG/alexs/1/1/testfppdf.lpr"/>
<EditorIndex Value="7"/>
<TopLine Value="518"/>
<CursorPos X="23" Y="542"/>
<UsageCount Value="20"/>
<EditorIndex Value="3"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit61>
<Unit62>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
<UnitName Value="fpPDF"/>
<EditorIndex Value="4"/>
<TopLine Value="4191"/>
<CursorPos X="3" Y="4196"/>
<UsageCount Value="20"/>
<TopLine Value="43"/>
<CursorPos X="12" Y="58"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit62>
<Unit63>
@ -506,14 +504,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="236"/>
<CursorPos X="3" Y="215"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit63>
<Unit64>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-base/src/contnrs.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="16"/>
<CursorPos X="3" Y="31"/>
<UsageCount Value="10"/>
<UsageCount Value="8"/>
</Unit64>
<Unit65>
<Filename Value="../../../../lcl/stdctrls.pp"/>
@ -521,7 +519,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="951"/>
<CursorPos X="14" Y="964"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit65>
<Unit66>
<Filename Value="../../../lazutils/tterror.pas"/>
@ -529,134 +527,219 @@
<EditorIndex Value="-1"/>
<TopLine Value="34"/>
<CursorPos X="3" Y="49"/>
<UsageCount Value="13"/>
<UsageCount Value="10"/>
</Unit66>
<Unit67>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fpparsettf.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="893"/>
<CursorPos X="3" Y="896"/>
<UsageCount Value="20"/>
</Unit67>
<Unit68>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fpttfencodings.pp"/>
<EditorIndex Value="-1"/>
<UsageCount Value="20"/>
</Unit68>
<Unit69>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fpttf.pp"/>
<UnitName Value="fpTTF"/>
<EditorIndex Value="2"/>
<TopLine Value="17"/>
<CursorPos X="29" Y="21"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit69>
<Unit70>
<Filename Value="../../../../lcl/include/canvas.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1756"/>
<CursorPos X="3" Y="1765"/>
<UsageCount Value="10"/>
</Unit70>
<Unit71>
<Filename Value="../../../../lcl/include/winapih.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="136"/>
<CursorPos X="10" Y="151"/>
<UsageCount Value="9"/>
</Unit71>
<Unit72>
<Filename Value="../../../../lcl/include/intfbasewinapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1161"/>
<CursorPos X="3" Y="1165"/>
<UsageCount Value="9"/>
</Unit72>
<Unit73>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/tests/fpttf_test.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="143"/>
<CursorPos X="13" Y="151"/>
<UsageCount Value="15"/>
</Unit73>
<Unit74>
<Filename Value="/home/install/source/fpcsrc/rtl/unix/sysunixh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="14"/>
<CursorPos X="2" Y="29"/>
<UsageCount Value="9"/>
</Unit74>
<Unit75>
<Filename Value="../../../lazutils/tttypes.pas"/>
<UnitName Value="TTTypes"/>
<EditorIndex Value="-1"/>
<TopLine Value="357"/>
<CursorPos X="12" Y="372"/>
<UsageCount Value="13"/>
</Unit75>
<Unit76>
<Filename Value="../../../lazutils/lazutf8.pas"/>
<UnitName Value="LazUTF8"/>
<EditorIndex Value="-1"/>
<TopLine Value="483"/>
<CursorPos X="3" Y="430"/>
<UsageCount Value="9"/>
</Unit76>
<Unit77>
<Filename Value="/home/install/source/fpcsrc/rtl/inc/ustringh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="125"/>
<CursorPos X="10" Y="140"/>
<UsageCount Value="9"/>
</Unit77>
<Unit78>
<Filename Value="/home/install/source/fpcsrc/rtl/inc/ustrings.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1781"/>
<CursorPos X="10" Y="1796"/>
<UsageCount Value="9"/>
</Unit78>
<Unit79>
<Filename Value="/home/install/source/fpcsrc/rtl/inc/systemh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="550"/>
<CursorPos X="3" Y="565"/>
<UsageCount Value="9"/>
</Unit79>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<JumpHistory Count="29" HistoryIndex="28">
<Position1>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="650" TopLine="632"/>
<Caret Line="428" Column="41" TopLine="413"/>
</Position1>
<Position2>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="652" TopLine="632"/>
<Caret Line="426" TopLine="413"/>
</Position2>
<Position3>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="654" TopLine="632"/>
<Caret Line="177" Column="7" TopLine="153"/>
</Position3>
<Position4>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="655" TopLine="632"/>
<Caret Line="784" Column="7" TopLine="770"/>
</Position4>
<Position5>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="656" TopLine="632"/>
<Caret Line="923" Column="39" TopLine="894"/>
</Position5>
<Position6>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="659" TopLine="634"/>
<Caret Line="425" Column="28" TopLine="418"/>
</Position6>
<Position7>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="660" TopLine="635"/>
</Position7>
<Position8>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="661" TopLine="637"/>
<Caret Line="420" Column="59" TopLine="391"/>
</Position8>
<Position9>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="663" TopLine="640"/>
<Caret Line="427" Column="44" TopLine="400"/>
</Position9>
<Position10>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="667" TopLine="643"/>
<Caret Line="443" Column="98" TopLine="418"/>
</Position10>
<Position11>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="670" TopLine="649"/>
<Filename Value="/home/OPTORG/alexs/1/1/testfppdf.lpr"/>
<Caret Line="133" Column="49" TopLine="108"/>
</Position11>
<Position12>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="673" TopLine="649"/>
<Filename Value="/home/OPTORG/alexs/1/1/testfppdf.lpr"/>
</Position12>
<Position13>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="676" TopLine="652"/>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
</Position13>
<Position14>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="690" TopLine="669"/>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
<Caret Line="1015" Column="12" TopLine="1005"/>
</Position14>
<Position15>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="668" TopLine="654"/>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
<Caret Line="1137" Column="3" TopLine="1130"/>
</Position15>
<Position16>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="690" TopLine="675"/>
<Caret Line="202" Column="22" TopLine="191"/>
</Position16>
<Position17>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="692" TopLine="675"/>
<Caret Line="203" Column="48" TopLine="191"/>
</Position17>
<Position18>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="679" TopLine="674"/>
<Caret Line="327" Column="29" TopLine="302"/>
</Position18>
<Position19>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="642" TopLine="640"/>
</Position19>
<Position20>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="643" TopLine="637"/>
<Caret Line="203" Column="36" TopLine="178"/>
</Position20>
<Position21>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="644" TopLine="637"/>
<Caret Line="202" Column="52" TopLine="178"/>
</Position21>
<Position22>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="645" TopLine="637"/>
<Caret Line="204" Column="52" TopLine="178"/>
</Position22>
<Position23>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="647" TopLine="637"/>
<Caret Line="426" Column="44" TopLine="398"/>
</Position23>
<Position24>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="649" TopLine="637"/>
<Caret Line="428" Column="96" TopLine="401"/>
</Position24>
<Position25>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="650" TopLine="651"/>
<Caret Line="427" Column="9" TopLine="414"/>
</Position25>
<Position26>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="652" TopLine="648"/>
<Caret Line="452" Column="6" TopLine="423"/>
</Position26>
<Position27>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="654" TopLine="648"/>
<Caret Line="149" TopLine="136"/>
</Position27>
<Position28>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="655" TopLine="648"/>
<Caret Line="381" Column="75" TopLine="371"/>
</Position28>
<Position29>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="656" TopLine="648"/>
<Caret Line="149" Column="38" TopLine="149"/>
</Position29>
<Position30>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="659" TopLine="648"/>
</Position30>
</JumpHistory>
</ProjectSession>
<Debugging>
<BreakPoints Count="4">
<BreakPoints Count="2">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
@ -668,23 +751,9 @@
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="685"/>
<Source Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fpttf.pp"/>
<Line Value="320"/>
</Item2>
<Item3>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="668"/>
</Item3>
<Item4>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="691"/>
</Item4>
</BreakPoints>
<Watches Count="1">
<Item1>

View File

@ -80,9 +80,9 @@ object Form1: TForm1
Height = 346
Top = 0
Width = 1043
ActivePage = TabSheet1
ActivePage = TabSheet2
Align = alClient
TabIndex = 0
TabIndex = 1
TabOrder = 1
object TabSheet1: TTabSheet
Caption = 'Test data'
@ -115,7 +115,7 @@ object Form1: TForm1
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Title.Caption = 'Дата поставки'
Width = 90
Width = 120
FieldName = 'PDATE'
EditButtons = <>
Filter.DropDownRows = 0
@ -193,6 +193,27 @@ object Form1: TForm1
end>
end
item
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Title.Caption = 'Статус'
Width = 60
FieldName = 'FLAG'
EditButtons = <>
Filter.DropDownRows = 0
Filter.EmptyValue = '(Нет)'
Filter.EmptyFont.Style = [fsItalic]
Filter.ItemIndex = -1
Footers = <>
ImageList = ImageList1
KeyList.Strings = (
'0=0'
'1=1'
'2=2'
'3=3'
)
end
item
Alignment = taCenter
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Title.Caption = 'Страна'
@ -299,7 +320,7 @@ object Form1: TForm1
ClientWidth = 1033
object Memo1: TMemo
Left = 0
Height = 313
Height = 312
Top = 0
Width = 1033
Align = alClient
@ -311,7 +332,6 @@ object Form1: TForm1
end
end
object RxMemoryData1: TRxMemoryData
Active = True
FieldDefs = <
item
Name = 'ID'
@ -345,6 +365,10 @@ object Form1: TForm1
DataType = ftString
Precision = -1
Size = 100
end
item
Name = 'FLAG'
DataType = ftInteger
end>
PacketRecords = 0
left = 136
@ -376,6 +400,7 @@ object Form1: TForm1
ProviderFlags = [pfInUpdate, pfInWhere]
ReadOnly = False
Required = False
DisplayFormat = 'dd.mm.yyyy'
end
object RxMemoryData1SUM: TCurrencyField
FieldKind = fkData
@ -409,6 +434,15 @@ object Form1: TForm1
Required = False
Size = 100
end
object RxMemoryData1FLAG: TLongintField
FieldKind = fkData
FieldName = 'FLAG'
Index = 6
LookupCache = False
ProviderFlags = [pfInUpdate, pfInWhere]
ReadOnly = False
Required = False
end
end
object DataSource1: TDataSource
DataSet = RxMemoryData1
@ -419,12 +453,120 @@ object Form1: TForm1
RxDBGrid = RxDBGrid1
Caption = 'Export to PDF file'
FileName = 'test111.pdf'
Options = [repExportTitle, repExportColors, repExportFooter]
Options = [repExportTitle, repExportColors, repExportFooter, repOverwriteExisting]
PdfOptions.PaperOrientation = ppoLandscape
PdfOptions.Options = []
OpenAfterExport = True
AuthorPdf = 'Лагунов А.А.'
ProducerPdf = 'alexs'
PageMargin.Left = 40
PageMargin.Top = 40
PageMargin.Right = 40
PageMargin.Bottom = 40
left = 112
top = 160
end
object ImageList1: TImageList
left = 112
top = 224
Bitmap = {
4C6903000000100000001000000000000000000000FF000000FF000000000000
0000000000FF000000FF0000000000000000000000FF000000FF000000000000
000000000000000000000000000000000000000000FFFF0000FF000000FF0000
00FF800000FFFF0000FF000000FF000000FF800000FFFF0000FF000000FF0000
00FF000000FF000000FF000000000000000000000000000000FFFF0000FF8000
00FF800000FFFF0000FFFF0000FF800000FF800000FFFF0000FFFF0000FF8000
00FF000000FF00000000000000000000000000000000000000FFFF0000FF8000
00FF800000FFFF0000FFFF0000FF800000FF800000FFFF0000FFFF0000FF0000
00FF000000000000000000000000000000000000000000000000000000FFFF00
00FF800000FF800000FFFF0000FFFF0000FF800000FF800000FF000000FF0000
0000000000000000000000000000000000000000000000000000000000FFFF00
00FF800000FF800000FFFF0000FFFF0000FF000000FF000000FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FFFF0000FF800000FF000000FF000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FFFF0000FF000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
000000000000000000000000000000000000000000FF000000FF000000000000
0000000000FF000000FF0000000000000000000000FF000000FF000000000000
000000000000000000000000000000000000000000FF0000FFFF000000FF0000
00FF000080FF0000FFFF000000FF000000FF000080FF0000FFFF000000FF0000
00FF000000FF000000FF000000000000000000000000000000FF0000FFFF0000
80FF000080FF0000FFFF0000FFFF000080FF000080FF0000FFFF0000FFFF0000
80FF000000FF00000000000000000000000000000000000000FF0000FFFF0000
80FF000080FF0000FFFF0000FFFF000080FF000080FF0000FFFF0000FFFF0000
00FF000000000000000000000000000000000000000000000000000000FF0000
FFFF000080FF000080FF0000FFFF0000FFFF000080FF000080FF000000FF0000
0000000000000000000000000000000000000000000000000000000000FF0000
FFFF000080FF000080FF0000FFFF0000FFFF000000FF000000FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FF0000FFFF000080FF000000FF000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FF0000FFFF000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
000000000000000000000000000000000000000000FF000000FF000000000000
0000000000FF000000FF0000000000000000000000FF000000FF000000000000
000000000000000000000000000000000000000000FF00FFFFFF000000FF0000
00FF008080FF00FFFFFF000000FF000000FF008080FF00FFFFFF000000FF0000
00FF000000FF000000FF000000000000000000000000000000FF00FFFFFF0080
80FF008080FF00FFFFFF00FFFFFF008080FF008080FF00FFFFFF00FFFFFF0080
80FF000000FF00000000000000000000000000000000000000FF00FFFFFF0080
80FF008080FF00FFFFFF00FFFFFF008080FF008080FF00FFFFFF00FFFFFF0000
00FF000000000000000000000000000000000000000000000000000000FF00FF
FFFF008080FF008080FF00FFFFFF00FFFFFF008080FF008080FF000000FF0000
0000000000000000000000000000000000000000000000000000000000FF00FF
FFFF008080FF008080FF00FFFFFF00FFFFFF000000FF000000FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FF00FFFFFF008080FF000000FF000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00FF00FFFFFF000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000FF0000000000000000000000000000
0000000000000000000000000000
}
end
end

View File

@ -7,7 +7,7 @@ interface
uses
Classes, SysUtils, FileUtil, rxmemds, rxdbgrid,
RxDBGridExportPdf, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, db;
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Spin, db;
type
@ -18,6 +18,7 @@ type
CheckBox1: TCheckBox;
DataSource1: TDataSource;
Edit1: TEdit;
ImageList1: TImageList;
Label1: TLabel;
Memo1: TMemo;
PageControl1: TPageControl;
@ -26,6 +27,7 @@ type
RxDBGridExportPDF1: TRxDBGridExportPDF;
RxMemoryData1: TRxMemoryData;
RxMemoryData1Country: TStringField;
RxMemoryData1FLAG: TLongintField;
RxMemoryData1ID: TAutoIncField;
RxMemoryData1NAME: TStringField;
RxMemoryData1PDATE: TDateField;
@ -42,6 +44,7 @@ type
procedure InitFonts;
procedure ShowInfo(AText:string; AParams : array of const);
procedure DebugFonts;
procedure CreateFontDirList;
public
{ public declarations }
end;
@ -50,10 +53,11 @@ var
Form1: TForm1;
implementation
uses EasyLazFreeType, LazFreeTypeFontCollection,
LazFileUtils;
uses fpTTF, LazFileUtils;
{$R *.lfm}
const
TestText = 'Образец текста';
{ TForm1 }
@ -62,32 +66,33 @@ begin
RxDBGridExportPDF1.ShowSetupForm:=true;
PageControl1.ActivePageIndex:=0;
RxMemoryData1.Open;
RxMemoryData1.AppendRecord([1, 'Строка с длинным текстом 1', now, 100, 'Россия', 'Москва']);
RxMemoryData1.AppendRecord([2, 'Строка с длинным текстом 2', now - 1, 100, 'Россия', 'Ставрополь']);
RxMemoryData1.AppendRecord([3, 'Строка с длинным текстом 3', now - 2, 110, 'Россия', 'Калининград']);
RxMemoryData1.AppendRecord([4, 'Строка с длинным текстом 4', now - 3, 5000, 'Россия', 'Владивасток']);
RxMemoryData1.AppendRecord([5, 'Строка с длинным текстом 5', now - 4, 123.31, 'USA', 'New-York']);
RxMemoryData1.AppendRecord([6, 'Строка с длинным текстом 6', now, 100, 'Россия', 'Москва']);
RxMemoryData1.AppendRecord([7, 'Строка с длинным текстом 7', now - 1, 100, 'Россия', 'Ставрополь']);
RxMemoryData1.AppendRecord([8, 'Строка с длинным текстом 8', now - 2, 110, 'Россия', 'Калининград']);
RxMemoryData1.AppendRecord([9, 'Строка с длинным текстом 9', now - 3, 5000, 'Россия', 'Владивасток']);
RxMemoryData1.AppendRecord([10,'Строка с длинным текстом 10', now - 4, 123.31, 'USA', 'New-York']);
RxMemoryData1.AppendRecord([11,'Строка с длинным текстом 11', now, 100, 'Россия', 'Москва']);
RxMemoryData1.AppendRecord([12,'Строка с длинным текстом 12', now - 1, 100, 'Россия', 'Ставрополь']);
RxMemoryData1.AppendRecord([13,'Строка с длинным текстом 13', now - 2, 110, 'Россия', 'Калининград']);
RxMemoryData1.AppendRecord([14,'Строка с длинным текстом 14', now - 3, 5000, 'Россия', 'Владивасток']);
RxMemoryData1.AppendRecord([15,'Строка с длинным текстом 15', now - 4, 123.31, 'USA', 'New-York']);
RxMemoryData1.AppendRecord([16,'Строка с длинным текстом 16', now, 100, 'Россия', 'Москва']);
RxMemoryData1.AppendRecord([17,'Строка с длинным текстом 17', now - 1, 100, 'Россия', 'Ставрополь']);
RxMemoryData1.AppendRecord([18,'Строка с длинным текстом 18', now - 2, 110, 'Россия', 'Калининград']);
RxMemoryData1.AppendRecord([19,'Строка с длинным текстом 19', now - 3, 5000, 'Россия', 'Владивасток']);
RxMemoryData1.AppendRecord([20,'Строка с длинным текстом 20', now - 4, 123.31, 'USA', 'New-York']);
RxMemoryData1.AppendRecord([1, 'Строка с длинным текстом 1', now, 100, 'Россия', 'Москва', 0]);
RxMemoryData1.AppendRecord([2, 'Строка с длинным текстом 2', now - 1, 100, 'Россия', 'Ставрополь', 1]);
RxMemoryData1.AppendRecord([3, 'Строка с длинным текстом 3', now - 2, 110, 'Россия', 'Калининград', 2]);
RxMemoryData1.AppendRecord([4, 'Строка с длинным текстом 4', now - 3, 5000, 'Россия', 'Владивасток', 0]);
RxMemoryData1.AppendRecord([5, 'Строка с длинным текстом 5', now - 4, 123.31, 'USA', 'New-York', 0]);
RxMemoryData1.AppendRecord([6, 'Строка с длинным текстом 6', now, 100, 'Россия', 'Москва', 0]);
RxMemoryData1.AppendRecord([7, 'Строка с длинным текстом 7', now - 1, 100, 'Россия', 'Ставрополь', 2]);
RxMemoryData1.AppendRecord([8, 'Строка с длинным текстом 8', now - 2, 110, 'Россия', 'Калининград', 1]);
RxMemoryData1.AppendRecord([9, 'Строка с длинным текстом 9', now - 3, 5000, 'Россия', 'Владивасток', 0]);
RxMemoryData1.AppendRecord([10,'Строка с длинным текстом 10', now - 4, 123.31, 'USA', 'New-York', 3]);
RxMemoryData1.AppendRecord([11,'Строка с длинным текстом 11', now, 100, 'Россия', 'Москва', 2]);
RxMemoryData1.AppendRecord([12,'Строка с длинным текстом 12', now - 1, 100, 'Россия', 'Ставрополь', 1]);
RxMemoryData1.AppendRecord([13,'Строка с длинным текстом 13', now - 2, 110, 'Россия', 'Калининград', 0]);
RxMemoryData1.AppendRecord([14,'Строка с длинным текстом 14', now - 3, 5000, 'Россия', 'Владивасток', 3]);
RxMemoryData1.AppendRecord([15,'Строка с длинным текстом 15', now - 4, 123.31, 'USA', 'New-York', 2]);
RxMemoryData1.AppendRecord([16,'Строка с длинным текстом 16', now, 100, 'Россия', 'Москва', 1]);
RxMemoryData1.AppendRecord([17,'Строка с длинным текстом 17', now - 1, 100, 'Россия', 'Ставрополь', 0]);
RxMemoryData1.AppendRecord([18,'Строка с длинным текстом 18', now - 2, 110, 'Россия', 'Калининград', 3]);
RxMemoryData1.AppendRecord([19,'Строка с длинным текстом 19', now - 3, 5000, 'Россия', 'Владивасток', 2]);
RxMemoryData1.AppendRecord([20,'Строка с длинным текстом 20', now - 4, 123.31, 'USA', 'New-York', 1]);
RxMemoryData1.First;
CreateFontDirList;
DebugFonts;
end;
procedure TForm1.InitFonts;
procedure CreateFontDirList;
procedure TForm1.CreateFontDirList;
var
s: String;
begin
@ -105,43 +110,10 @@ begin
{$ENDIF}
end;
{ Duplicates functionality in FontCollection.AddFolder in order to be able to
ignore exceptions due to font read errors (occur on Linux Mint with font
NanumMyeongjo.ttf }
procedure AddFolder(AFolder: string);
var
files: TStringList;
i: integer;
begin
AFolder := ExpandFileName(AFolder);
if (length(AFolder) <> 0) and (AFolder[length(AFolder)] <> PathDelim) then
AFolder += PathDelim;
files := TStringList.Create;
FontCollection.BeginUpdate;
try
FindAllFiles(files, AFolder, '*.ttf', true);
//FindAllFiles(files, AFolder, '*.otf', true);
files.Sort;
for i := 0 to files.Count-1 do
try
FontCollection.AddFile(files[i]);
except
end;
finally
FontCollection.EndUpdate;
files.Free;
end;
end;
var
i: Integer;
procedure TForm1.InitFonts;
begin
if FontDirList = nil then
CreateFontDirList;
for i:=0 to FontDirList.Count-1 do
AddFolder(FontDirList[i]);
end;
procedure TForm1.ShowInfo(AText: string; AParams: array of const);
@ -150,59 +122,22 @@ begin
end;
procedure TForm1.DebugFonts;
procedure DumpFamaly(AFontFamely:string);
var
FFM: TCustomFamilyCollectionItem;
I: Integer;
FFI: TCustomFontCollectionItem;
tiInf: TFreeTypeInformation;
begin
FFM:=FontCollection.Family[AFontFamely];
if not Assigned(FFM) then
begin
ShowInfo('Font Family %s NOT FOUND!', [AFontFamely]);
exit;
end;
ShowInfo('In Family %s count fonts : %d', [AFontFamely, FFM.FontCount]);
for I:=0 to FFM.FontCount-1 do
begin
FFI:=FFM.Font[i];
ShowInfo('Font in file %s - NAME: %s. Styles = %s', [FFI.Filename, FFI.Information[ftiFullName], FFI.Styles]);
end;
FFI:=FFM.GetFont('Regular');
if Assigned(FFI) then
begin
ShowInfo('REGULAR Font in file %s - NAME: %s', [FFI.Filename, FFI.Information[ftiFullName]]);
for tiInf := Low(TFreeTypeInformation) to high(TFreeTypeInformation) do
ShowInfo('%s - %s', [FreeTypeInformationStr[tiInf], FFI.Information[tiInf]]);
end
else
ShowInfo('Regular font not found', []);
end;
i, C, L1, L3: Integer;
K: TFPFontCacheItem;
L: Single;
begin
InitFonts;
Memo1.Lines.Clear;
if Assigned(FontCollection) then
C:=FontDirList.Count;
gTTFontCache.BuildFontFacheIgnoresErrors:=true;
gTTFontCache.SearchPath.Assign(FontDirList);
gTTFontCache.BuildFontCache;
for i:=0 to gTTFontCache.Count-1 do
begin
ShowInfo('FontCollection.FontFileCount = %d', [FontCollection.FontFileCount]);
ShowInfo('FontCollection.FamilyCount = %d', [FontCollection.FamilyCount]);
DumpFamaly('Arial');
DumpFamaly('Sans');
DumpFamaly('Serif');
DumpFamaly('Liberation Sans');
DumpFamaly('Gootville');
DumpFamaly('Oxygen Mono');
DumpFamaly('FreeSans');
DumpFamaly('Noto Sans Tai Viet');
end
else
Memo1.Text:='FontCollection not assigned';
ShowInfo('%s - %s - %s', [gTTFontCache.Items[i].FileName, gTTFontCache.Items[i].FamilyName, gTTFontCache.Items[i].PostScriptName]);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);

View File

@ -37,8 +37,8 @@ interface
{$IF (FPC_FULLVERSION >= 30101)}
uses
Classes, SysUtils, DB, rxdbgrid, LazFreeTypeFontCollection, vclutils, Graphics, fpPDF, EasyLazFreeType,
contnrs;
Classes, SysUtils, DB, rxdbgrid, vclutils, Graphics, fpPDF, contnrs, fpparsettf,
fpTTF;
type
@ -75,23 +75,27 @@ type
TExportFontItem = class
private
FFontColor: TColor;
FFontName: string;
FFontSize: Integer;
FFontStyle: TFontStyles;
FOwner:TExportFonts;
FBold: boolean;
FDefaultFont: boolean;
FFont: TFont;
//
FFreeTypeFont:TFreeTypeFont;
FPdfFont:integer;
function GetFontSize: Single;
procedure SetFontSize(AValue: Single);
FTTFFontInfo: TFPFontCacheItem;
function GetBold: boolean;
function GetItalic: boolean;
procedure SetFontSize(AValue: Integer);
public
constructor Create(AOwner:TExportFonts; AFont:TFont; AFreeTypeFont:TFreeTypeFont);
constructor Create(AOwner:TExportFonts; AFontName:string; AFontStyle: TFontStyles);
destructor Destroy; override;
procedure Activate;
property FontSize:Single read GetFontSize write SetFontSize;
property Bold:boolean read FBold;
property FontStyle: TFontStyles read FFontStyle;
property FontSize:Integer read FFontSize write SetFontSize;
property FontColor:TColor read FFontColor write FFontColor;
property Bold:boolean read GetBold;
property Italic:boolean read GetItalic;
property DefaultFont:boolean read FDefaultFont;
property FontName:string read FFontName;
end;
@ -110,8 +114,8 @@ type
constructor Create(AOwner:TRxDBGridExportPDF);
destructor Destroy; override;
procedure Clear;
function AddItem(AFont: TFont; AFontCollectionItem:TCustomFontCollectionItem; ADefStyle:TFontStyles = []): TExportFontItem;
function FindItem(AFont:TFont; ADefStyle:TFontStyles = []):TExportFontItem;
function AddItem(AFontName: string; AFontStyle:TFontStyles = []): TExportFontItem;
function FindItem(AFontName: string; AFontStyle:TFontStyles = []):TExportFontItem;
property DefaultFontNormal:TExportFontItem read FDefaultFontNormal;
property DefaultFontBold:TExportFontItem read FDefaultFontBold;
property Count:integer read GetCount;
@ -137,13 +141,11 @@ type
FWorkPages:TFPList;
FWorkPagesNeedCount:integer;
FFontCollection:TFreeTypeFontCollection;
FFontItems:TExportFonts;
function GetPdfOptions: TPdfExportOptions;
procedure SetPageMargin(AValue: TRxPageMargin);
procedure SetPdfOptions(AValue: TPdfExportOptions);
function SelectFont(AFont:TFont):TExportFontItem;
function ActivateFont(AFont:TFont; AOwnerFont:TFont):TExportFontItem;
protected
FPDFDocument:TPDFDocument;
@ -154,7 +156,11 @@ type
procedure DoSetupDocHeader;
procedure DoSetupFonts;
//
procedure WriteTextRect(AExportFont:TExportFontItem; X, Y, W, H:integer; AText:string; ATextAlign:TAlignment);
procedure DrawRect(X, Y, W, H: integer; ABorderColor, AFillColor: TColor);
//procedure DrawImage(X, Y, W, H: integer; ABorderColor, AFillColor: TColor);
procedure StartNewPage;
procedure DoExportPage;
@ -163,10 +169,13 @@ type
procedure DoExportFooter;
procedure DoSaveDocument;
function DoExecTools:boolean;override;
function DoSetupTools:boolean; override;
//
procedure InitFonts(AFontCollection:TFreeTypeFontCollection);
//procedure DoTest;
//
procedure InitFonts;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -186,6 +195,13 @@ implementation
{$IF (FPC_FULLVERSION >= 30101)}
uses Grids, rxdconst, FileUtil, Forms, Controls, LCLIntf, LazFileUtils, RxDBGridExportPdfSetupUnit;
const
cInchToMM = 25.4;
function ConvetUnits(AUnits:TPDFFloat):TPDFFloat; inline;
begin
Result := (AUnits * cInchToMM) / gTTFontCache.DPI;
end;
function ColorToDdfColor(C:TColor):TARGBColor;
var
A:array [1..4] of byte absolute C;
@ -231,126 +247,96 @@ begin
FList.Clear;
end;
function TExportFonts.AddItem(AFont: TFont;
AFontCollectionItem: TCustomFontCollectionItem; ADefStyle: TFontStyles
function TExportFonts.AddItem(AFontName: string; AFontStyle: TFontStyles
): TExportFontItem;
var
S1, S2, S3: String;
begin
Result:=nil;
if not Assigned(AFont) then exit;
Result:=FindItem(AFontName, AFontStyle);
if Assigned(Result) then exit;
Result:=FindItem(AFont, ADefStyle);
if not Assigned(AFont) then exit;
Result:=TExportFontItem.Create(Self, AFontName, AFontStyle);
Result:=TExportFontItem.Create(Self, AFont, AFontCollectionItem.CreateFont);
S1:=ExtractFileDir(Result.FTTFFontInfo.FileName);
S2:=ExtractFileName(Result.FTTFFontInfo.FileName);
S3:=AFontName; //AFontCollectionItem.Information[ftiFullName];
S1:=ExtractFileDir(AFontCollectionItem.Filename);
S2:=ExtractFileName(AFontCollectionItem.Filename);
S3:=AFontCollectionItem.Information[ftiFullName];
FOwner.FPDFDocument.FontDirectory:=S1;
Result.FPdfFont:=FOwner.FPDFDocument.AddFont(S2, S3);
end;
function TExportFonts.FindItem(AFont: TFont; ADefStyle: TFontStyles
function TExportFonts.FindItem(AFontName: string; AFontStyle: TFontStyles
): TExportFontItem;
var
K: TExportFontItem;
i: Integer;
begin
Result:=nil;
if not Assigned(AFont) then exit;
if ADefStyle = [] then
ADefStyle:=AFont.Style;
if AFont.Name = 'default' then
if AFontName = 'default' then
begin
for i:=0 to FList.Count - 1 do
begin
//Стили!
K:=TExportFontItem(FList[i]);
if K.DefaultFont then
begin
if (fsBold in ADefStyle) and K.Bold then
begin
Result:=K;
exit;
end
else
if (not (fsBold in ADefStyle)) and not K.Bold then
begin
Result:=K;
exit;
end;
end;
end;
if Graphics.fsBold in AFontStyle then
Result:=FDefaultFontBold
else
Result:=FDefaultFontNormal;
end
else
begin
for i:=0 to FList.Count-1 do
begin
K:=TExportFontItem(FList[i]);
if K.FontName = AFont.Name then
if (K.FontName = AFontName) and (K.FontStyle = AFontStyle) then
begin
if (fsBold in ADefStyle) and K.Bold then
begin
Result:=K;
exit;
end
else
if (not (fsBold in ADefStyle)) and not K.Bold then
begin
Result:=K;
exit;
end;
end;
Result:=K;
exit;
end
end;
end;
end;
{ TExportFontItem }
function TExportFontItem.GetFontSize: Single;
function TExportFontItem.GetBold: boolean;
begin
Result:=FFreeTypeFont.SizeInPixels;
Result:=Graphics.fsBold in FFontStyle;
end;
procedure TExportFontItem.SetFontSize(AValue: Single);
function TExportFontItem.GetItalic: boolean;
begin
FFreeTypeFont.SizeInPixels:=AValue;
Result:=Graphics.fsItalic in FFontStyle;
end;
procedure TExportFontItem.SetFontSize(AValue: Integer);
begin
if AValue = 0 then
FFontSize:=10
else
FFontSize:=AValue;
end;
constructor TExportFontItem.Create(AOwner: TExportFonts; AFont: TFont;
AFreeTypeFont: TFreeTypeFont);
constructor TExportFontItem.Create(AOwner: TExportFonts; AFontName: string;
AFontStyle: TFontStyles);
begin
inherited Create;
FOwner:=AOwner;
FOwner.FList.Add(Self);
FFont:=AFont;
FFreeTypeFont:=AFreeTypeFont;
FFontName:=AFont.Name;
FFontStyle:=AFontStyle;
FFontName:=AFontName;
FTTFFontInfo:=gTTFontCache.Find(AFontName, Graphics.fsBold in AFontStyle, Graphics.fsItalic in AFontStyle);
if not Assigned(FTTFFontInfo) then
raise Exception.CreateFmt('fpTTF:in gTTFontCache not found font "%s" info.', [AFontName]);
end;
destructor TExportFontItem.Destroy;
begin
FreeAndNil(FFreeTypeFont);
inherited Destroy;
end;
procedure TExportFontItem.Activate;
var
FS: Integer;
begin
if FFont.Size = 0 then
FS:=10
else
FS:=FFont.Size;
FFreeTypeFont.SizeInPoints:=FS;
FOwner.FOwner.FCurPage.SetFont(FPdfFont, FS);
FOwner.FOwner.FCurPage.SetColor(ColorToDdfColor(FFont.Color), false);
FOwner.FOwner.FCurPage.SetFont(FPdfFont, FontSize);
FOwner.FOwner.FCurPage.SetColor(ColorToDdfColor(FontColor), false);
end;
{ TPdfExportOptions }
@ -392,66 +378,95 @@ begin
FPdfOptions.Assign(AValue);
end;
function TRxDBGridExportPDF.SelectFont(AFont: TFont): TExportFontItem;
var
i: Integer;
begin
Result:=nil;
for i:=0 to FFontItems.Count-1 do
if FFontItems.Item[i].FFont = AFont then
begin
Result:=FFontItems.Item[i];
Exit;
end;
end;
function TRxDBGridExportPDF.ActivateFont(AFont: TFont; AOwnerFont: TFont
): TExportFontItem;
begin
Result:=SelectFont(AFont);
if not Assigned(Result) then
//Result:=SelectFont(AFont);
Result:=FFontItems.FindItem(AFont.Name, AFont.Style);
{ if not Assigned(Result) then
Result:=SelectFont(AOwnerFont);
if not Assigned(Result) then
Result:=FFontItems.FDefaultFontNormal;
}
if Assigned(Result) then
begin
Result.FontSize:=AFont.Size;
Result.FontColor:=AFont.Color;
Result.Activate
end
else
raise Exception.Create('Font not found');
raise Exception.CreateFmt('Font "%s" not found', [AFont.Name]);
end;
procedure TRxDBGridExportPDF.WriteTextRect(AExportFont: TExportFontItem; X, Y,
W, H: integer; AText: string; ATextAlign: TAlignment);
var
FTW, FTH: Single;
FTW, FTH, ADescender, FTH1, FTH2: Single;
X1: TPDFFloat;
Y1: TPDFFloat;
Y1, fX, fY: TPDFFloat;
fW, fH: Extended;
begin
FTW:=AExportFont.FFreeTypeFont.TextWidth(AText);
FTH:=AExportFont.FFreeTypeFont.TextHeight(AText);
fX := ConvetUnits(X);
fY := ConvetUnits(Y);
fW := ConvetUnits(W);
fH := ConvetUnits(H);
//Calc text width
FTW:=ConvetUnits(AExportFont.FTTFFontInfo.TextWidth(AText, AExportFont.FontSize));
//FTW := (FTW1 * 25.4) / gTTFontCache.DPI;
//Calc text height
FTH1 := AExportFont.FTTFFontInfo.FontData.CapHeight * AExportFont.FontSize * gTTFontCache.DPI / (72 * AExportFont.FTTFFontInfo.FontData.Head.UnitsPerEm);
FTH2 := Abs(AExportFont.FTTFFontInfo.FontData.Descender) * AExportFont.FontSize * gTTFontCache.DPI / (72 * AExportFont.FTTFFontInfo.FontData.Head.UnitsPerEm);
FTH := (FTH1 * 25.4) / gTTFontCache.DPI + (FTH2 * 25.4) / gTTFontCache.DPI;
case ATextAlign of
taLeftJustify:
begin
Y1:=Y;
X1:=X + constCellPadding;
Y1:=fY - FTH2;
X1:=fX + ConvetUnits(constCellPadding);
end;
taRightJustify:
begin
Y1:=Y;
X1:=X + W - FTW - 2;
if X1 < X then
X1:=X;
Y1:=fY - FTH2;
X1:=fX + fW - FTW - ConvetUnits(constCellPadding);
if X1 < fX then
X1:=fX;
end;
taCenter:
begin
Y1:=Y;
X1:=(X + W) / 2 - FTW / 2 - constCellPadding;
if X1 < X then
X1:=X;
Y1:=fY - FTH2;
X1:=fX + fW / 2 - FTW / 2 - ConvetUnits(constCellPadding);
if X1 < fX then
X1:=fX;
end;
end;
FCurPage.WriteText(X1, Y1 - FTH, AText);
FCurPage.WriteText(X1, Y1, AText);
end;
procedure TRxDBGridExportPDF.DrawRect(X, Y, W, H: integer; ABorderColor,
AFillColor: TColor);
var
fX, fY, fW, fH: Extended;
begin
if (AFillColor = clNone) and (ABorderColor = clNone) then exit;
if ABorderColor <> clNone then
FCurPage.SetColor(ColorToDdfColor(ABorderColor), true);
if AFillColor <> clNone then
FCurPage.SetColor(ColorToDdfColor(AFillColor), false);
fX:= ConvetUnits(X);
fY:= ConvetUnits(Y);
fW:= ConvetUnits(W);
fH:= ConvetUnits(H);
FCurPage.DrawRect(fX, fY, fW, fH, 1, AFillColor <> clNone, ABorderColor <> clNone);
end;
procedure TRxDBGridExportPDF.StartNewPage;
@ -464,7 +479,8 @@ begin
begin
P := FPDFDocument.Pages.AddPage;
P.PaperType := FPdfOptions.PaperType;
P.UnitOfMeasure := uomPixels;
//P.UnitOfMeasure := uomPixels;
P.UnitOfMeasure := uomMillimeters; //normal work only whis mm ??
FCurSection.AddPage(P);
FWorkPages.Add(P);
end;
@ -495,11 +511,11 @@ begin
X:=FPageMargin.Left;
end;
FCurPage.SetColor(ColorToDdfColor(FRxDBGrid.BorderColor), true);
FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, false, true);
DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, FRxDBGrid.BorderColor, clNone);
WriteTextRect(ActivateFont(C.Title.Font, FRxDBGrid.TitleFont), X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Title.Caption, C.Title.Alignment);
WriteTextRect(ActivateFont(C.Title.Font, FRxDBGrid.TitleFont),
X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Title.Caption, C.Title.Alignment);
X:=X + C.Width;
end;
@ -532,9 +548,7 @@ begin
X:=FPageMargin.Left;
end;
FCurPage.SetColor(ColorToDdfColor(FRxDBGrid.BorderColor), true); //Border
FCurPage.SetColor(ColorToDdfColor(C.Color), false); // Fill color
FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, true, true);
DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, FRxDBGrid.BorderColor, C.Color);
if Assigned(C.Field) then
WriteTextRect(ActivateFont(C.Font, FRxDBGrid.Font), X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Field.DisplayText, C.Alignment);
@ -551,84 +565,48 @@ begin
FDataSet.Next;
Inc(FPosY, FRxDBGrid.DefaultRowHeight);
if FPosY > FPageHeight - FPageMargin.Bottom then
{ begin
FPosY:=FPageMargin.Top + 20;}
exit;
// end;
end;
end;
procedure TRxDBGridExportPDF.DoSetupFonts;
procedure AddFonts(AFont:TFont);
//Find default font name
function DefFontName:string;
const
DefFontNames : array [1..3] of string =
('Liberation Sans', 'Arial', 'FreeSans');
var
FM: TCustomFamilyCollectionItem;
S: String;
FIH: TCustomFontCollectionItem;
i: Integer;
begin
S:=AFont.Name;
FM:=FFontCollection.Family[S];
if Assigned(FM) then
begin
if fsBold in AFont.Style then
FIH:=FM.GetFont('Bold')
else
FIH:=FM.GetFont('Regular');
if Assigned(FIH) then
FFontItems.AddItem(AFont, FIH);
end;
for i:=1 to 3 do
if Assigned(gTTFontCache.Find(DefFontNames[i], false, false)) then
begin
Result:=DefFontNames[i];
exit;
end;
raise Exception.Create('Not found Sans font');
end;
var
FM: TCustomFamilyCollectionItem;
FIH: TCustomFontCollectionItem;
F: TExportFontItem;
i: Integer;
sDefFontName:string;
begin
InitFonts(FFontCollection);
FM:=nil;
if FRxDBGrid.Font.Name <> 'default' then
FM:=FFontCollection.Family[FRxDBGrid.Font.Name];
if not Assigned(FM) then //Fill default fonts
FM:=FFontCollection.Family['Liberation Sans'];
if not Assigned(FM) then
FM:=FFontCollection.Family['Arial'];
if Assigned(FM) then
begin
FIH:=FM.GetFont('Bold');
if Assigned(FIH) then
begin
F:=FFontItems.AddItem(FRxDBGrid.TitleFont, FIH, [fsBold]);
F.FBold:=true;
F.FDefaultFont:=true;
FFontItems.FDefaultFontBold:=F;
end;
FIH:=FM.GetFont('Regular');
if Assigned(FIH) then
begin
F:=FFontItems.AddItem(FRxDBGrid.Font, FIH, []);
F.FDefaultFont:=true;
FFontItems.FDefaultFontNormal:=F;
end;
end;
if not Assigned(FM) then
raise Exception.Create('Not found Sans font');
InitFonts;
sDefFontName:=DefFontName;
FFontItems.FDefaultFontNormal:=FFontItems.AddItem(sDefFontName, []);
FFontItems.FDefaultFontBold:=FFontItems.AddItem(sDefFontName, [Graphics.fsBold]);
for i:=0 to FRxDBGrid.Columns.Count-1 do
begin
if FRxDBGrid.Columns[i].Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Font);
FFontItems.AddItem(FRxDBGrid.Columns[i].Font.Name, FRxDBGrid.Columns[i].Font.Style);
if FRxDBGrid.Columns[i].Footer.Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Footer.Font);
FFontItems.AddItem(FRxDBGrid.Columns[i].Footer.Font.Name, FRxDBGrid.Columns[i].Footer.Font.Style);
if FRxDBGrid.Columns[i].Title.Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Title.Font);
FFontItems.AddItem(FRxDBGrid.Columns[i].Title.Font.Name, FRxDBGrid.Columns[i].Title.Font.Style);
end;
end;
@ -656,9 +634,7 @@ begin
X:=FPageMargin.Left;
end;
FCurPage.SetColor(ColorToDdfColor(FRxDBGrid.BorderColor), true); //Border
FCurPage.SetColor(ColorToDdfColor(FRxDBGrid.FooterOptions.Color), false); // Fill color
FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, true, true);
DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, FRxDBGrid.BorderColor, FRxDBGrid.FooterOptions.Color);
if FRxDBGrid.FooterOptions.RowCount = 1 then
S:=C.Footer.DisplayText
@ -682,11 +658,11 @@ end;
var
j: Integer;
begin
if FRxDBGrid.FooterRowCount = 1 then
if FRxDBGrid.FooterOptions.RowCount = 1 then
WriteFooterRow(1)
else
begin
for j:=0 to FRxDBGrid.FooterRowCount-1 do
for j:=0 to FRxDBGrid.FooterOptions.RowCount-1 do
begin
if FPosY > FPageHeight - FPageMargin.Bottom then
StartNewPage;
@ -767,7 +743,6 @@ begin
P:=FDataSet.Bookmark;
{$ENDIF}
FFontCollection:=TFreeTypeFontCollection.Create;
FPDFDocument:=TPDFDocument.Create(nil);
FFontItems:=TExportFonts.Create(Self);
FWorkPages:=TFPList.Create;
@ -781,7 +756,7 @@ begin
DoExportPage;
until FDataSet.EOF;
if repExportTitle in FOptions then
if repExportFooter in FOptions then
begin
if FPosY > FPageHeight - FPageMargin.Bottom then
StartNewPage;
@ -789,6 +764,8 @@ begin
DoExportFooter;
end;
//DoTest; //!!!!
DoSaveDocument;
Result:=true;
finally
@ -803,7 +780,6 @@ begin
FreeAndNil(FWorkPages);
FreeAndNil(FPDFDocument);
FreeAndNil(FFontItems);
FreeAndNil(FFontCollection);
end;
if Result and FOpenAfterExport then
@ -835,7 +811,85 @@ begin
end;
RxDBGridExportPdfSetupForm.Free;
end;
(*
procedure TRxDBGridExportPDF.DoTest;
var
lPt1:TPDFCoord;
lFntPtSize, FtText1: Integer;
lFC: TFPFontCacheItem;
lFntInfo: TTFFileInfo;
lHeight, lTextHeightInMM, lDescenderHeightInMM, A1: Extended;
lWidth, lTextWidthInMM: Single;
sFontName, sSampleText: String;
begin
//setup
sSampleText:='Это привет мир!';
lFntPtSize := 23;
lPt1.X := 25; // units in MM
lPt1.Y := 40; // units in MM
StartNewPage;
{ sFontName:='FreeSans';
lFC := gTTFontCache.Find(sFontName, False, False);
if not Assigned(lFC) then
raise Exception.Create('FreeSans font not found');
lFntInfo := lFC.FontData;
FPDFDocument.FontDirectory:=ExtractFileDir(lFC.FileName);
FtText1 := FPDFDocument.AddFont(ExtractFileName(lFC.FileName), sFontName); // TODO: this color value means nothing - not used at all
}
sFontName:=FFontItems.FDefaultFontNormal.FontName;
lFC := gTTFontCache.Find(sFontName, False, False);
if not Assigned(lFC) then
raise Exception.Create('FreeSans font not found');
lFntInfo := lFC.FontData;
FtText1 := FFontItems.FDefaultFontNormal.FPdfFont;
FCurPage:=TPDFPage(FWorkPages[0]);
FCurPage.UnitOfMeasure := uomMillimeters;
{ Page title }
//FCurPage.SetFont(FFontItems.DefaultFontNormal.FPdfFont, 23);
FCurPage.SetFont(FtText1, lFntPtSize);
FCurPage.SetColor(clBlack, false);
FCurPage.WriteText(lPt1.X, lPt1.Y, sSampleText);
{ draw a rectangle around the Page Title text }
{ result is in pixels }
lHeight := lFntInfo.CapHeight * lFntPtSize * gTTFontCache.DPI / (72 * lFntInfo.Head.UnitsPerEm);
{ convert pixels to mm as our PDFPage.UnitOfMeasure is set to mm. }
lTextHeightInMM := (lHeight * 25.4) / gTTFontCache.DPI;
// lTextHeightInMM := lHeight;
lWidth := lFC.TextWidth(sSampleText, lFntPtSize);
{ convert the Font Units to Millimeters }
lTextWidthInMM := (lWidth * 25.4) / gTTFontCache.DPI;
// lTextWidthInMM := lWidth;
{ result is in pixels }
lHeight := Abs(lFntInfo.Descender) * lFntPtSize * gTTFontCache.DPI / (72 * lFntInfo.Head.UnitsPerEm);
A1:=lHeight;
{ convert pixels to mm as you PDFPage.UnitOfMeasure is set to mm. }
lDescenderHeightInMM := (lHeight * 25.4) / gTTFontCache.DPI;
// lDescenderHeightInMM := lHeight;
{ adjust the Y coordinate for the font Descender, because
WriteUTF8Text draws on the baseline. Also adjust the TextHeight
because CapHeight doesn't take into account the Descender. }
FCurPage.SetColor(clRed, true);
FCurPage.DrawRect(lPt1.X, lPt1.Y+lDescenderHeightInMM, lTextWidthInMM, lTextHeightInMM+lDescenderHeightInMM, 1, false, true);
//lFntInfo.Free;
DrawRect(10, 100, Round(lWidth), Round(lHeight + A1), Graphics.clBlack, Graphics.clRed);
end;
*)
procedure TRxDBGridExportPDF.DoSaveDocument;
var
F: TFileStream;
@ -848,14 +902,15 @@ begin
end;
end;
procedure TRxDBGridExportPDF.InitFonts(AFontCollection: TFreeTypeFontCollection
);
procedure TRxDBGridExportPDF.InitFonts;
var
FontDirList: TStringList;
procedure CreateFontDirList;
{$IFDEF WINDOWS}
var
s: String;
{$ENDIF}
begin
{$IFDEF WINDOWS}
s := SHGetFolderPathUTF8(20); // CSIDL_FONTS = 20
@ -870,38 +925,17 @@ begin
FontDirList.Add(GetUserDir + '.fonts/');
{$ENDIF}
end;
procedure AddFolder(AFolder: string);
var
Files: TStringList;
i: integer;
begin
AFolder := AppendPathDelim(ExpandFileName(AFolder));
Files := TStringList.Create;
AFontCollection.BeginUpdate;
try
FindAllFiles(Files, AFolder, '*.ttf', true);
Files.Sort;
for i := 0 to Files.Count-1 do
try
AFontCollection.AddFile(Files[i]);
except
end;
finally
AFontCollection.EndUpdate;
Files.Free;
end;
end;
var
i: Integer;
begin
FontDirList := TStringList.Create;
CreateFontDirList;
for i:=0 to FontDirList.Count-1 do
AddFolder(FontDirList[i]);
FreeAndNil(FontDirList);
if gTTFontCache.Count = 0 then
begin
gTTFontCache.BuildFontFacheIgnoresErrors:=true;
CreateFontDirList;
gTTFontCache.SearchPath.Assign(FontDirList);
FreeAndNil(FontDirList);
gTTFontCache.BuildFontCache;
end;
end;
constructor TRxDBGridExportPDF.Create(AOwner: TComponent);
@ -921,7 +955,6 @@ begin
inherited Destroy;
end;
{$ENDIF}
end.