RxFPC:Rewrite work with fonts in RxDBGrid export to pdf

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5092 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-08-18 07:53:51 +00:00
parent fe4f02b653
commit 2047c32696
5 changed files with 766 additions and 287 deletions

View File

@ -3,13 +3,13 @@
<ProjectSession>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="63">
<Units Count="67">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="81" Y="12"/>
<UsageCount Value="61"/>
<UsageCount Value="80"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@ -18,9 +18,9 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<TopLine Value="59"/>
<CursorPos X="106" Y="59"/>
<UsageCount Value="61"/>
<TopLine Value="179"/>
<CursorPos X="8" Y="176"/>
<UsageCount Value="80"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@ -30,14 +30,15 @@
<EditorIndex Value="-1"/>
<TopLine Value="143"/>
<CursorPos X="31" Y="32"/>
<UsageCount Value="16"/>
<UsageCount Value="15"/>
</Unit2>
<Unit3>
<Filename Value="../../rxdbgrid.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="2312"/>
<CursorPos X="30" Y="2329"/>
<UsageCount Value="24"/>
<EditorIndex Value="2"/>
<TopLine Value="482"/>
<CursorPos X="41" Y="496"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="rxdbgridexportpdf.pas"/>
@ -45,28 +46,28 @@
<EditorIndex Value="-1"/>
<TopLine Value="51"/>
<CursorPos X="69" Y="76"/>
<UsageCount Value="17"/>
<UsageCount Value="16"/>
</Unit4>
<Unit5>
<Filename Value="../../rxdconst.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="161"/>
<CursorPos X="18" Y="177"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit5>
<Unit6>
<Filename Value="../../../install/source/fpcsrc/rtl/objpas/classes/reader.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="964"/>
<CursorPos Y="986"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit6>
<Unit7>
<Filename Value="../../../OPTORG/alexs/3/examples/testfppdf.lpr"/>
<EditorIndex Value="-1"/>
<TopLine Value="107"/>
<CursorPos Y="133"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit7>
<Unit8>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
@ -74,25 +75,25 @@
<EditorIndex Value="-1"/>
<TopLine Value="530"/>
<CursorPos X="15" Y="544"/>
<UsageCount Value="25"/>
<UsageCount Value="24"/>
</Unit8>
<Unit9>
<Filename Value="../../registerrxdb.pas"/>
<UnitName Value="RegisterRxDB"/>
<EditorIndex Value="-1"/>
<CursorPos X="23" Y="10"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit9>
<Unit10>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<UnitName Value="RxDBGridExportPdf"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="277"/>
<CursorPos X="9" Y="303"/>
<UsageCount Value="28"/>
<TopLine Value="656"/>
<CursorPos Y="680"/>
<UsageCount Value="38"/>
<Bookmarks Count="1">
<Item0 X="3" Y="382" ID="1"/>
<Item0 Y="696" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit10>
@ -102,51 +103,53 @@
<EditorIndex Value="-1"/>
<TopLine Value="140"/>
<CursorPos X="3" Y="145"/>
<UsageCount Value="17"/>
<UsageCount Value="16"/>
</Unit11>
<Unit12>
<Filename Value="../../../OPTORG/alexs/1/1/testfppdf.lpr"/>
<EditorIndex Value="-1"/>
<TopLine Value="145"/>
<CursorPos X="13" Y="166"/>
<UsageCount Value="21"/>
<UsageCount Value="20"/>
</Unit12>
<Unit13>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-pdf/src/fpparsettf.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="344"/>
<CursorPos Y="365"/>
<UsageCount Value="13"/>
<UsageCount Value="12"/>
</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="7"/>
<UsageCount Value="6"/>
</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="7"/>
<UsageCount Value="6"/>
</Unit15>
<Unit16>
<Filename Value="../../../lazutils/lazfreetypefontcollection.pas"/>
<UnitName Value="LazFreeTypeFontCollection"/>
<EditorIndex Value="-1"/>
<TopLine Value="345"/>
<CursorPos X="3" Y="347"/>
<UsageCount Value="21"/>
<EditorIndex Value="6"/>
<TopLine Value="331"/>
<CursorPos Y="352"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="../../../lazutils/easylazfreetype.pas"/>
<UnitName Value="EasyLazFreeType"/>
<EditorIndex Value="-1"/>
<TopLine Value="1563"/>
<CursorPos X="3" Y="1550"/>
<UsageCount Value="21"/>
<EditorIndex Value="3"/>
<TopLine Value="36"/>
<CursorPos X="3" Y="50"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="../../../../examples/lazfreetype/mainform.pas"/>
@ -156,36 +159,36 @@
<EditorIndex Value="-1"/>
<TopLine Value="51"/>
<CursorPos X="78" Y="61"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit18>
<Unit19>
<Filename Value="../../../lazutils/ttfile.pas"/>
<UnitName Value="TTFile"/>
<EditorIndex Value="-1"/>
<TopLine Value="233"/>
<CursorPos Y="249"/>
<UsageCount Value="9"/>
<TopLine Value="234"/>
<CursorPos X="4" Y="242"/>
<UsageCount Value="13"/>
</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="9"/>
<UsageCount Value="8"/>
</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="9"/>
<UsageCount Value="8"/>
</Unit21>
<Unit22>
<Filename Value="../../../install/source/fpcsrc/rtl/inc/fexpand.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="226"/>
<CursorPos X="10" Y="106"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit22>
<Unit23>
<Filename Value="../../../tachart/tadraweropengl.pas"/>
@ -193,21 +196,22 @@
<EditorIndex Value="-1"/>
<TopLine Value="218"/>
<CursorPos Y="220"/>
<UsageCount Value="13"/>
<UsageCount Value="12"/>
</Unit23>
<Unit24>
<Filename Value="../../../lazutils/fileutil.pas"/>
<UnitName Value="FileUtil"/>
<EditorIndex Value="-1"/>
<CursorPos X="14" Y="22"/>
<UsageCount Value="9"/>
<TopLine Value="220"/>
<CursorPos X="17" Y="235"/>
<UsageCount Value="13"/>
</Unit24>
<Unit25>
<Filename Value="../../../lazutils/fileutil.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="1013"/>
<CursorPos Y="1031"/>
<UsageCount Value="7"/>
<TopLine Value="1019"/>
<CursorPos X="3" Y="1024"/>
<UsageCount Value="13"/>
</Unit25>
<Unit26>
<Filename Value="../../../lazutils/lazfileutils.pas"/>
@ -215,7 +219,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="719"/>
<CursorPos Y="736"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit26>
<Unit27>
<Filename Value="../../../tachart/backup/tadraweropengl.pas"/>
@ -223,13 +227,13 @@
<EditorIndex Value="-1"/>
<TopLine Value="208"/>
<CursorPos X="20" Y="224"/>
<UsageCount Value="7"/>
<UsageCount Value="6"/>
</Unit27>
<Unit28>
<Filename Value="unit1.lfm"/>
<EditorIndex Value="-1"/>
<TopLine Value="231"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
<DefaultSyntaxHighlighter Value="LFM"/>
</Unit28>
<Unit29>
@ -238,14 +242,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="3503"/>
<CursorPos X="3" Y="3506"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit29>
<Unit30>
<Filename Value="C:/lazarus/components/lazutils/easylazfreetype.pas"/>
<UnitName Value="EasyLazFreeType"/>
<EditorIndex Value="-1"/>
<CursorPos X="14" Y="160"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit30>
<Unit31>
<Filename Value="C:/lazarus/components/lazutils/lazfreetypefontcollection.pas"/>
@ -253,28 +257,28 @@
<EditorIndex Value="-1"/>
<TopLine Value="127"/>
<CursorPos X="50" Y="141"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</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="10"/>
<UsageCount Value="9"/>
</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="8"/>
<UsageCount Value="7"/>
</Unit33>
<Unit34>
<Filename Value="../../vclutils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="125"/>
<CursorPos Y="155"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit34>
<Unit35>
<Filename Value="../../rxshortcutunit.pas"/>
@ -284,41 +288,41 @@
<UnitName Value="rxShortCutUnit"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit35>
<Unit36>
<Filename Value="../../rxctrls.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="40"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</Unit36>
<Unit37>
<Filename Value="../../rxapputils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="28"/>
<CursorPos X="83" Y="64"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</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="10"/>
<UsageCount Value="9"/>
</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="9"/>
<UsageCount Value="8"/>
</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="10"/>
<UsageCount Value="9"/>
</Unit40>
<Unit41>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/bufdataset.pas"/>
@ -326,7 +330,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="458"/>
<CursorPos X="3" Y="446"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
<Bookmarks Count="1">
<Item0 X="3" Y="3449" ID="1"/>
</Bookmarks>
@ -335,21 +339,21 @@
<Filename Value="../../../install/source/fpcsrc/packages/fcl-db/src/base/bufdataset_parser.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="20" Y="18"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</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="9"/>
<UsageCount Value="8"/>
</Unit43>
<Unit44>
<Filename Value="../../rxmemds.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="25"/>
<CursorPos X="47" Y="40"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
<Bookmarks Count="1">
<Item0 X="33" Y="131" ID="2"/>
</Bookmarks>
@ -359,63 +363,64 @@
<EditorIndex Value="-1"/>
<TopLine Value="136"/>
<CursorPos X="14" Y="155"/>
<UsageCount Value="8"/>
<UsageCount Value="7"/>
</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="8"/>
<UsageCount Value="7"/>
</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="8"/>
<UsageCount Value="7"/>
</Unit47>
<Unit48>
<Filename Value="../../rxdb/rxmemds_parser.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="186"/>
<CursorPos X="3" Y="189"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</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="9"/>
<UsageCount Value="8"/>
</Unit49>
<Unit50>
<Filename Value="../../../../lcl/grids.pas"/>
<UnitName Value="Grids"/>
<EditorIndex Value="-1"/>
<TopLine Value="1972"/>
<CursorPos X="21" Y="1976"/>
<EditorIndex Value="5"/>
<TopLine Value="11194"/>
<CursorPos Y="11210"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit50>
<Unit51>
<Filename Value="../../../lazutils/lazfreetype.pas"/>
<UnitName Value="LazFreeType"/>
<EditorIndex Value="-1"/>
<TopLine Value="76"/>
<CursorPos Y="76"/>
<UsageCount Value="9"/>
<TopLine Value="512"/>
<CursorPos X="5" Y="520"/>
<UsageCount Value="13"/>
</Unit51>
<Unit52>
<Filename Value="../../../lazutils/ttobjs.pas"/>
<UnitName Value="TTObjs"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</Unit52>
<Unit53>
<Filename Value="../../../lazutils/tttables.pas"/>
<UnitName Value="TTTables"/>
<EditorIndex Value="-1"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</Unit53>
<Unit54>
<Filename Value="../../../../lcl/dbgrids.pas"/>
@ -423,15 +428,15 @@
<EditorIndex Value="-1"/>
<TopLine Value="4071"/>
<CursorPos Y="4090"/>
<UsageCount Value="11"/>
<UsageCount Value="10"/>
</Unit54>
<Unit55>
<Filename Value="../../../../lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="1959"/>
<CursorPos X="29" Y="1970"/>
<UsageCount Value="10"/>
<TopLine Value="48"/>
<CursorPos X="59" Y="63"/>
<UsageCount Value="14"/>
</Unit55>
<Unit56>
<Filename Value="../../../../lcl/lcltype.pp"/>
@ -439,7 +444,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="1629"/>
<CursorPos X="3" Y="1644"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit56>
<Unit57>
<Filename Value="../../../install/source/fpcsrc/packages/fcl-image/src/fpimage.pp"/>
@ -447,7 +452,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="37"/>
<CursorPos X="4" Y="45"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit57>
<Unit58>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
@ -455,12 +460,10 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridExportPdfSetupUnit"/>
<EditorIndex Value="4"/>
<TopLine Value="56"/>
<CursorPos X="5" Y="83"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="57"/>
<CursorPos X="23" Y="81"/>
<UsageCount Value="22"/>
</Unit58>
<Unit59>
<Filename Value="../../rxdbgridexportspreadsheet_paramsunit.pas"/>
@ -471,7 +474,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="3" Y="46"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit59>
<Unit60>
<Filename Value="../../../../lcl/controls.pp"/>
@ -479,150 +482,181 @@
<EditorIndex Value="-1"/>
<TopLine Value="5"/>
<CursorPos X="14" Y="19"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit60>
<Unit61>
<Filename Value="/home/OPTORG/alexs/1/1/testfppdf.lpr"/>
<EditorIndex Value="3"/>
<TopLine Value="297"/>
<CursorPos Y="302"/>
<UsageCount Value="10"/>
<EditorIndex Value="7"/>
<TopLine Value="518"/>
<CursorPos X="23" Y="542"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit61>
<Unit62>
<Filename Value="/home/install/source/fpcsrc/packages/fcl-pdf/src/fppdf.pp"/>
<UnitName Value="fpPDF"/>
<EditorIndex Value="2"/>
<TopLine Value="22"/>
<CursorPos X="3" Y="43"/>
<UsageCount Value="10"/>
<EditorIndex Value="4"/>
<TopLine Value="4191"/>
<CursorPos X="3" Y="4196"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit62>
<Unit63>
<Filename Value="/home/install/source/fpcsrc/rtl/objpas/classes/classesh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="236"/>
<CursorPos X="3" Y="215"/>
<UsageCount Value="9"/>
</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"/>
</Unit64>
<Unit65>
<Filename Value="../../../../lcl/stdctrls.pp"/>
<UnitName Value="StdCtrls"/>
<EditorIndex Value="-1"/>
<TopLine Value="951"/>
<CursorPos X="14" Y="964"/>
<UsageCount Value="9"/>
</Unit65>
<Unit66>
<Filename Value="../../../lazutils/tterror.pas"/>
<UnitName Value="TTError"/>
<EditorIndex Value="-1"/>
<TopLine Value="34"/>
<CursorPos X="3" Y="49"/>
<UsageCount Value="13"/>
</Unit66>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="277" Column="53" TopLine="252"/>
<Caret Line="650" TopLine="632"/>
</Position1>
<Position2>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="142" Column="15" TopLine="127"/>
<Caret Line="652" TopLine="632"/>
</Position2>
<Position3>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="275" Column="70" TopLine="261"/>
<Caret Line="654" TopLine="632"/>
</Position3>
<Position4>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="285" TopLine="226"/>
<Caret Line="655" TopLine="632"/>
</Position4>
<Position5>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="239" Column="61" TopLine="236"/>
<Caret Line="656" TopLine="632"/>
</Position5>
<Position6>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="208" Column="20" TopLine="203"/>
<Caret Line="659" TopLine="634"/>
</Position6>
<Position7>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
<Caret Line="18" Column="30"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="660" TopLine="635"/>
</Position7>
<Position8>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="136" Column="89" TopLine="129"/>
<Caret Line="661" TopLine="637"/>
</Position8>
<Position9>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="477" Column="34" TopLine="457"/>
<Caret Line="663" TopLine="640"/>
</Position9>
<Position10>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
<Caret Line="67" TopLine="39"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="667" TopLine="643"/>
</Position10>
<Position11>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
<Caret Line="83" TopLine="53"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="670" TopLine="649"/>
</Position11>
<Position12>
<Filename Value="../../rxdbgridexportpdfsetupunit.pas"/>
<Caret Line="82" Column="5" TopLine="56"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="673" TopLine="649"/>
</Position12>
<Position13>
<Filename Value="unit1.pas"/>
<Caret Line="166" Column="3" TopLine="148"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="676" TopLine="652"/>
</Position13>
<Position14>
<Filename Value="unit1.pas"/>
<Caret Line="165" Column="3" TopLine="147"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="690" TopLine="669"/>
</Position14>
<Position15>
<Filename Value="unit1.pas"/>
<Caret Line="164" Column="3" TopLine="146"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="668" TopLine="654"/>
</Position15>
<Position16>
<Filename Value="unit1.pas"/>
<Caret Line="167" Column="54" TopLine="146"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="690" TopLine="675"/>
</Position16>
<Position17>
<Filename Value="unit1.pas"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="692" TopLine="675"/>
</Position17>
<Position18>
<Filename Value="unit1.pas"/>
<Caret Line="157" Column="44" TopLine="127"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="679" TopLine="674"/>
</Position18>
<Position19>
<Filename Value="unit1.pas"/>
<Caret Line="156" Column="44" TopLine="126"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="642" TopLine="640"/>
</Position19>
<Position20>
<Filename Value="unit1.pas"/>
<Caret Line="137" Column="65" TopLine="127"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="643" TopLine="637"/>
</Position20>
<Position21>
<Filename Value="unit1.pas"/>
<Caret Line="188" TopLine="164"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="644" TopLine="637"/>
</Position21>
<Position22>
<Filename Value="unit1.pas"/>
<Caret Line="155" TopLine="139"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="645" TopLine="637"/>
</Position22>
<Position23>
<Filename Value="unit1.pas"/>
<Caret Line="156" TopLine="139"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="647" TopLine="637"/>
</Position23>
<Position24>
<Filename Value="unit1.pas"/>
<Caret Line="157" TopLine="139"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="649" TopLine="637"/>
</Position24>
<Position25>
<Filename Value="unit1.pas"/>
<Caret Line="164" Column="42" TopLine="153"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="650" TopLine="651"/>
</Position25>
<Position26>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="276" Column="5" TopLine="260"/>
<Caret Line="652" TopLine="648"/>
</Position26>
<Position27>
<Filename Value="/home/OPTORG/alexs/1/1/testfppdf.lpr"/>
<Caret Line="331" TopLine="307"/>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="654" TopLine="648"/>
</Position27>
<Position28>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="288" TopLine="277"/>
<Caret Line="655" TopLine="648"/>
</Position28>
<Position29>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="143" Column="13" TopLine="134"/>
<Caret Line="656" TopLine="648"/>
</Position29>
<Position30>
<Filename Value="../../rxdbgridexportpdf.pas"/>
<Caret Line="53" Column="3" TopLine="38"/>
<Caret Line="659" TopLine="648"/>
</Position30>
</JumpHistory>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<BreakPoints Count="4">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
@ -630,22 +664,32 @@
<Source Value="../../../lazutils/lazfreetypefontcollection.pas"/>
<Line Value="423"/>
</Item1>
</BreakPoints>
<Watches Count="4">
<Item1>
<Expression Value="fName"/>
</Item1>
<Item2>
<Expression Value="C"/>
<DisplayStyle Value="wdfHex"/>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="685"/>
</Item2>
<Item3>
<Expression Value="A"/>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="668"/>
</Item3>
<Item4>
<Expression Value="Result"/>
<DisplayStyle Value="wdfHex"/>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgridexportpdf.pas"/>
<Line Value="691"/>
</Item4>
</BreakPoints>
<Watches Count="1">
<Item1>
<Expression Value="i"/>
</Item1>
</Watches>
</Debugging>
</CONFIG>

View File

@ -11,12 +11,12 @@ object Form1: TForm1
LCLVersion = '1.7'
object Panel1: TPanel
Left = 0
Height = 50
Top = 347
Height = 51
Top = 346
Width = 1043
Align = alBottom
AutoSize = True
ClientHeight = 50
ClientHeight = 51
ClientWidth = 1043
TabOrder = 0
object Button1: TButton
@ -34,26 +34,50 @@ object Form1: TForm1
TabOrder = 0
end
object CheckBox1: TCheckBox
Left = 1
AnchorSideLeft.Control = Panel1
AnchorSideBottom.Control = Edit1
AnchorSideBottom.Side = asrBottom
Left = 7
Height = 24
Top = 18
Width = 99
Caption = 'CheckBox1'
Top = 20
Width = 85
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 6
Caption = 'Use filter'
OnChange = CheckBox1Change
TabOrder = 1
end
object Edit1: TEdit
Left = 137
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Button1
Left = 247
Height = 37
Top = 7
Width = 295
Width = 223
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabOrder = 2
Text = 'ID=1'
end
object Label1: TLabel
AnchorSideLeft.Control = CheckBox1
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = Edit1
AnchorSideBottom.Side = asrBottom
Left = 92
Height = 20
Top = 24
Width = 149
Anchors = [akLeft, akBottom]
Caption = 'Enter filter expression^'
ParentColor = False
end
end
object PageControl1: TPageControl
Left = 0
Height = 347
Height = 346
Top = 0
Width = 1043
ActivePage = TabSheet1
@ -62,11 +86,11 @@ object Form1: TForm1
TabOrder = 1
object TabSheet1: TTabSheet
Caption = 'Test data'
ClientHeight = 313
ClientHeight = 312
ClientWidth = 1033
object RxDBGrid1: TRxDBGrid
Left = 0
Height = 313
Height = 312
Top = 0
Width = 1033
ColumnDefValues.BlobText = '(данные)'
@ -86,21 +110,6 @@ object Form1: TForm1
Filter.ItemIndex = -1
Footers = <>
end
item
Color = clCream
Font.Color = clPurple
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Title.Caption = 'Наименование продукта'
Width = 364
FieldName = 'NAME'
EditButtons = <>
Filter.DropDownRows = 0
Filter.EmptyValue = '(Нет)'
Filter.EmptyFont.Style = [fsItalic]
Filter.ItemIndex = -1
Footers = <>
end
item
Color = clYellow
Title.Alignment = taCenter
@ -115,6 +124,39 @@ object Form1: TForm1
Filter.ItemIndex = -1
Footers = <>
end
item
Color = clCream
Font.Color = clPurple
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Title.Caption = 'Наименование продукта'
Width = 364
FieldName = 'NAME'
EditButtons = <>
Filter.DropDownRows = 0
Filter.EmptyValue = '(Нет)'
Filter.EmptyFont.Style = [fsItalic]
Filter.ItemIndex = -1
Footer.Alignment = taRightJustify
Footer.Value = 'Итого:'
Footer.ValueType = fvtStaticText
Footers = <
item
Alignment = taRightJustify
Value = 'Итого:'
ValueType = fvtStaticText
end
item
Alignment = taRightJustify
Value = 'Минимум:'
ValueType = fvtStaticText
end
item
Alignment = taRightJustify
Value = 'Максимум:'
ValueType = fvtStaticText
end>
end
item
Title.Alignment = taCenter
Title.Orientation = toHorizontal
@ -126,7 +168,29 @@ object Form1: TForm1
Filter.EmptyValue = '(Нет)'
Filter.EmptyFont.Style = [fsItalic]
Filter.ItemIndex = -1
Footers = <>
Footer.Alignment = taRightJustify
Footer.DisplayFormat = '#,##0.00'
Footer.FieldName = 'SUM'
Footer.ValueType = fvtSum
Footers = <
item
Alignment = taRightJustify
DisplayFormat = '#,##0.00'
FieldName = 'SUM'
ValueType = fvtSum
end
item
Alignment = taRightJustify
DisplayFormat = '#,##0.00'
FieldName = 'SUM'
ValueType = fvtMin
end
item
Alignment = taRightJustify
DisplayFormat = '#,##0.00'
FieldName = 'SUM'
ValueType = fvtMax
end>
end
item
Title.Alignment = taCenter
@ -210,11 +274,16 @@ object Form1: TForm1
ShortCut = 16451
Enabled = True
end>
FooterOptions.DrawFullLine = False
OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgAllowQuickFilter, rdgAllowToolMenu]
FooterOptions.Active = True
FooterOptions.Color = clYellow
FooterOptions.RowCount = 3
FooterOptions.DrawFullLine = True
OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgFooterRows, rdgAllowQuickFilter, rdgAllowToolMenu]
FooterColor = clYellow
FooterRowCount = 3
Align = alClient
Color = clWindow
DrawFullLine = False
DrawFullLine = True
FocusColor = clRed
SelectedColor = clHighlight
GridLineStyle = psSolid
@ -226,7 +295,7 @@ object Form1: TForm1
end
object TabSheet2: TTabSheet
Caption = 'Debug window'
ClientHeight = 313
ClientHeight = 312
ClientWidth = 1033
object Memo1: TMemo
Left = 0
@ -242,32 +311,39 @@ object Form1: TForm1
end
end
object RxMemoryData1: TRxMemoryData
Active = True
FieldDefs = <
item
Name = 'ID'
DataType = ftAutoInc
Precision = -1
end
item
Name = 'NAME'
DataType = ftString
Precision = -1
Size = 220
end
item
Name = 'PDATE'
DataType = ftDate
Precision = -1
end
item
Name = 'SUM'
DataType = ftCurrency
Precision = 2
end
item
Name = 'Country'
DataType = ftString
Precision = -1
Size = 100
end
item
Name = 'Sity'
DataType = ftString
Precision = -1
Size = 100
end>
PacketRecords = 0
@ -342,7 +418,6 @@ object Form1: TForm1
object RxDBGridExportPDF1: TRxDBGridExportPDF
RxDBGrid = RxDBGrid1
Caption = 'Export to PDF file'
ShowSetupForm = True
FileName = 'test111.pdf'
Options = [repExportTitle, repExportColors, repExportFooter]
PdfOptions.Options = []

View File

@ -18,6 +18,7 @@ type
CheckBox1: TCheckBox;
DataSource1: TDataSource;
Edit1: TEdit;
Label1: TLabel;
Memo1: TMemo;
PageControl1: TPageControl;
Panel1: TPanel;
@ -58,6 +59,7 @@ uses EasyLazFreeType, LazFreeTypeFontCollection,
procedure TForm1.FormCreate(Sender: TObject);
begin
RxDBGridExportPDF1.ShowSetupForm:=true;
PageControl1.ActivePageIndex:=0;
RxMemoryData1.Open;
RxMemoryData1.AppendRecord([1, 'Строка с длинным текстом 1', now, 100, 'Россия', 'Москва']);
@ -119,6 +121,7 @@ end;
FontCollection.BeginUpdate;
try
FindAllFiles(files, AFolder, '*.ttf', true);
//FindAllFiles(files, AFolder, '*.otf', true);
files.Sort;
for i := 0 to files.Count-1 do
try
@ -153,6 +156,7 @@ var
FFM: TCustomFamilyCollectionItem;
I: Integer;
FFI: TCustomFontCollectionItem;
tiInf: TFreeTypeInformation;
begin
FFM:=FontCollection.Family[AFontFamely];
if not Assigned(FFM) then
@ -171,7 +175,12 @@ begin
FFI:=FFM.GetFont('Regular');
if Assigned(FFI) then
ShowInfo('REGULAR Font in file %s - NAME: %s', [FFI.Filename, FFI.Information[ftiFullName]])
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;
@ -187,6 +196,10 @@ begin
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';
@ -194,7 +207,9 @@ end;
procedure TForm1.Button1Click(Sender: TObject);
begin
RxDBGridExportPDF1.ShowSetupForm:=false;
RxDBGridExportPDF1.Execute;
RxDBGridExportPDF1.ShowSetupForm:=true;
end;
procedure TForm1.CheckBox1Change(Sender: TObject);

View File

@ -37,7 +37,8 @@ interface
{$IF (FPC_FULLVERSION >= 30101)}
uses
Classes, SysUtils, DB, rxdbgrid, LazFreeTypeFontCollection, vclutils, Graphics, fpPDF, EasyLazFreeType;
Classes, SysUtils, DB, rxdbgrid, LazFreeTypeFontCollection, vclutils, Graphics, fpPDF, EasyLazFreeType,
contnrs;
type
@ -67,6 +68,56 @@ type
end;
type
TRxDBGridExportPDF = class;
TExportFonts = class;
{ TExportFontItem }
TExportFontItem = class
private
FFontName: string;
FOwner:TExportFonts;
FBold: boolean;
FDefaultFont: boolean;
FFont: TFont;
//
FFreeTypeFont:TFreeTypeFont;
FPdfFont:integer;
function GetFontSize: Single;
procedure SetFontSize(AValue: Single);
public
constructor Create(AOwner:TExportFonts; AFont:TFont; AFreeTypeFont:TFreeTypeFont);
destructor Destroy; override;
procedure Activate;
property FontSize:Single read GetFontSize write SetFontSize;
property Bold:boolean read FBold;
property DefaultFont:boolean read FDefaultFont;
property FontName:string read FFontName;
end;
{ TExportFonts }
TExportFonts = class
private
FDefaultFontBold: TExportFontItem;
FDefaultFontNormal: TExportFontItem;
FOwner:TRxDBGridExportPDF;
FList:TFPList;
function GetCount: integer;
function GetItem(Index: integer): TExportFontItem;
public
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;
property DefaultFontNormal:TExportFontItem read FDefaultFontNormal;
property DefaultFontBold:TExportFontItem read FDefaultFontBold;
property Count:integer read GetCount;
property Item[Index:integer]:TExportFontItem read GetItem;
end;
{ TRxDBGridExportPDF }
@ -87,33 +138,33 @@ type
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;
FCurSection: TPDFSection;
FDataSet:TDataSet;
FPosY : integer;
FHeaderFont:integer;
FBodyFont:integer;
FFooterFont:integer;
FExportFontHeader: TFreeTypeFont;
FExportFontBody: TFreeTypeFont;
procedure DoSetupDocHeader;
procedure DoSetupFonts;
procedure WriteTextRect(AExportFont:TFreeTypeFont; X, Y, W, H:integer; AText:string; ATextAlign:TAlignment);
procedure WriteTextRect(AExportFont:TExportFontItem; X, Y, W, H:integer; AText:string; ATextAlign:TAlignment);
procedure StartNewPage;
procedure DoExportPage;
procedure DoExportTitle;
procedure DoExportBody;
procedure DoSetupFonts;
procedure DoExportFooter;
procedure DoSaveDocument;
procedure DoSetupDocHeader;
procedure DoExportPage;
function DoExecTools:boolean;override;
function DoSetupTools:boolean; override;
procedure DoSaveDocument;
//
procedure InitFonts(AFontCollection:TFreeTypeFontCollection);
public
@ -145,6 +196,163 @@ begin
Result:={A[1] shl 24 +} A[1] shl 16 + A[2] shl 8 + A[3];
end;
{ TExportFonts }
function TExportFonts.GetCount: integer;
begin
Result:=FList.Count;
end;
function TExportFonts.GetItem(Index: integer): TExportFontItem;
begin
Result:=TExportFontItem(FList[Index]);
end;
constructor TExportFonts.Create(AOwner: TRxDBGridExportPDF);
begin
inherited Create;
FOwner:=AOwner;
FList:=TFPList.Create;
end;
destructor TExportFonts.Destroy;
begin
Clear;
FreeAndNil(FList);
inherited Destroy;
end;
procedure TExportFonts.Clear;
var
I: Integer;
begin
for I:=0 to FList.Count-1 do
TExportFontItem(FList[i]).Free;
FList.Clear;
end;
function TExportFonts.AddItem(AFont: TFont;
AFontCollectionItem: TCustomFontCollectionItem; ADefStyle: TFontStyles
): TExportFontItem;
var
S1, S2, S3: String;
begin
Result:=nil;
if not Assigned(AFont) then exit;
Result:=FindItem(AFont, ADefStyle);
if not Assigned(AFont) then exit;
Result:=TExportFontItem.Create(Self, AFont, AFontCollectionItem.CreateFont);
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
): 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
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;
end
else
begin
for i:=0 to FList.Count-1 do
begin
K:=TExportFontItem(FList[i]);
if K.FontName = AFont.Name 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;
end;
end;
{ TExportFontItem }
function TExportFontItem.GetFontSize: Single;
begin
Result:=FFreeTypeFont.SizeInPixels;
end;
procedure TExportFontItem.SetFontSize(AValue: Single);
begin
FFreeTypeFont.SizeInPixels:=AValue;
end;
constructor TExportFontItem.Create(AOwner: TExportFonts; AFont: TFont;
AFreeTypeFont: TFreeTypeFont);
begin
inherited Create;
FOwner:=AOwner;
FOwner.FList.Add(Self);
FFont:=AFont;
FFreeTypeFont:=AFreeTypeFont;
FFontName:=AFont.Name;
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);
end;
{ TPdfExportOptions }
procedure TPdfExportOptions.AssignTo(Dest: TPersistent);
@ -184,15 +392,44 @@ begin
FPdfOptions.Assign(AValue);
end;
procedure TRxDBGridExportPDF.WriteTextRect(AExportFont: TFreeTypeFont; X, Y, W,
H: integer; AText: string; ATextAlign: TAlignment);
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(AOwnerFont);
if not Assigned(Result) then
Result:=FFontItems.FDefaultFontNormal;
if Assigned(Result) then
Result.Activate
else
raise Exception.Create('Font not found');
end;
procedure TRxDBGridExportPDF.WriteTextRect(AExportFont: TExportFontItem; X, Y,
W, H: integer; AText: string; ATextAlign: TAlignment);
var
FTW, FTH: Single;
X1: TPDFFloat;
Y1: TPDFFloat;
begin
FTW:=AExportFont.TextWidth(AText);
FTH:=AExportFont.TextHeight(AText);
FTW:=AExportFont.FFreeTypeFont.TextWidth(AText);
FTH:=AExportFont.FFreeTypeFont.TextHeight(AText);
case ATextAlign of
taLeftJustify:
begin
@ -217,6 +454,24 @@ begin
FCurPage.WriteText(X1, Y1 - FTH, AText);
end;
procedure TRxDBGridExportPDF.StartNewPage;
var
P: TPDFPage;
i: Integer;
begin
FWorkPages.Clear;
for i:=0 to FWorkPagesNeedCount - 1 do
begin
P := FPDFDocument.Pages.AddPage;
P.PaperType := FPdfOptions.PaperType;
P.UnitOfMeasure := uomPixels;
FCurSection.AddPage(P);
FWorkPages.Add(P);
end;
FPosY:=FPageMargin.Top + 20;
end;
procedure TRxDBGridExportPDF.DoExportTitle;
var
i, X, CP: Integer;
@ -231,7 +486,8 @@ begin
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i];
if C.Visible then
begin
if X + C.Width > FPageWidth - FPageMargin.Right then
begin
Inc(CP);
@ -243,13 +499,11 @@ begin
FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, false, true);
FCurPage.SetFont(FHeaderFont, 10);
FExportFontHeader.SizeInPoints:=10;
FCurPage.SetColor(ColorToDdfColor(C.Title.Font.Color), false);
WriteTextRect(FExportFontHeader, 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;
end;
Inc(FPosY, FRxDBGrid.DefaultRowHeight);
end;
@ -269,6 +523,8 @@ begin
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i];
if C.Visible then
begin
if X + C.Width > FPageWidth - FPageMargin.Right then
begin
Inc(CP);
@ -281,15 +537,11 @@ begin
FCurPage.DrawRect(X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, 1, true, true);
if Assigned(C.Field) then
begin
FCurPage.SetFont(FBodyFont, 10);
FExportFontBody.SizeInPoints:=10;
FCurPage.SetColor(ColorToDdfColor(C.Font.Color), false);
WriteTextRect(FExportFontBody, X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Field.DisplayText, C.Alignment);
end;
WriteTextRect(ActivateFont(C.Font, FRxDBGrid.Font), X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, C.Field.DisplayText, C.Alignment);
X:=X + C.Width;
end;
end;
end;
begin
@ -299,23 +551,47 @@ begin
FDataSet.Next;
Inc(FPosY, FRxDBGrid.DefaultRowHeight);
if FPosY > FPageHeight - FPageMargin.Bottom then
begin
FPosY:=FPageMargin.Top + 20;
{ begin
FPosY:=FPageMargin.Top + 20;}
exit;
end;
// end;
end;
end;
procedure TRxDBGridExportPDF.DoSetupFonts;
procedure AddFonts(AFont:TFont);
var
FM: TCustomFamilyCollectionItem;
FIH, FI: TCustomFontCollectionItem;
B: Boolean;
S: String;
FIH: TCustomFontCollectionItem;
begin
FExportFontHeader:=nil;
FFontCollection:=TFreeTypeFontCollection.Create;
InitFonts(FFontCollection);
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;
end;
var
FM: TCustomFamilyCollectionItem;
FIH: TCustomFontCollectionItem;
F: TExportFontItem;
i: Integer;
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'];
@ -325,35 +601,98 @@ begin
FIH:=FM.GetFont('Bold');
if Assigned(FIH) then
begin
B:=FIH.Bold;
FPDFDocument.FontDirectory := ExtractFileDir(FIH.Filename);
FHeaderFont := FPDFDocument.AddFont(ExtractFileName(FIH.Filename), FIH.Information[ftiFullName]);
FExportFontHeader:=FIH.CreateFont;
F:=FFontItems.AddItem(FRxDBGrid.TitleFont, FIH, [fsBold]);
F.FBold:=true;
F.FDefaultFont:=true;
FFontItems.FDefaultFontBold:=F;
end;
FI:=FM.GetFont('Regular');
if Assigned(FI) then
FIH:=FM.GetFont('Regular');
if Assigned(FIH) then
begin
B:=FI.Bold;
FPDFDocument.FontDirectory := ExtractFileDir(FI.Filename);
FBodyFont := FPDFDocument.AddFont(ExtractFileName(FI.Filename), FI.Information[ftiFullName]);
FExportFontBody:=FI.CreateFont;
F:=FFontItems.AddItem(FRxDBGrid.Font, FIH, []);
F.FDefaultFont:=true;
FFontItems.FDefaultFontNormal:=F;
end;
if not Assigned(FIH) then
FHeaderFont:=FBodyFont;
FFooterFont := FHeaderFont;
end;
FFontCollection.Free;
if not Assigned(FM) then
raise Exception.Create('Not found Sans font');
for i:=0 to FRxDBGrid.Columns.Count-1 do
begin
if FRxDBGrid.Columns[i].Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Font);
if FRxDBGrid.Columns[i].Footer.Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Footer.Font);
if FRxDBGrid.Columns[i].Title.Font.Name <> 'default' then
AddFonts(FRxDBGrid.Columns[i].Title.Font);
end;
end;
procedure TRxDBGridExportPDF.DoExportFooter;
begin
procedure WriteFooterRow(AFooterRow:Integer);
var
i, X, CP, FS: Integer;
S: String;
C: TRxColumn;
begin
X:=FPageWidth + FPageMargin.Right;
CP:=-1;
FCurPage:=nil;
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i];
if C.Visible then
begin
if X + C.Width > FPageWidth - FPageMargin.Right then
begin
Inc(CP);
FCurPage:=TPDFPage(FWorkPages[CP]);
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);
if FRxDBGrid.FooterOptions.RowCount = 1 then
S:=C.Footer.DisplayText
else
begin
if C.Footers.Count > AFooterRow then
S:=C.Footers[AFooterRow].DisplayText
else
S:='';
end;
if (S<>'') then
WriteTextRect(ActivateFont(C.Footer.Font, FRxDBGrid.Font), X, FPosY, C.Width, FRxDBGrid.DefaultRowHeight, S, C.Footer.Alignment);
X:=X + C.Width;
end;
end;
Inc(FPosY, FRxDBGrid.DefaultRowHeight);
end;
var
j: Integer;
begin
if FRxDBGrid.FooterRowCount = 1 then
WriteFooterRow(1)
else
begin
for j:=0 to FRxDBGrid.FooterRowCount-1 do
begin
if FPosY > FPageHeight - FPageMargin.Bottom then
StartNewPage;
WriteFooterRow(j);
end;
end;
end;
procedure TRxDBGridExportPDF.DoSetupDocHeader;
@ -390,6 +729,8 @@ begin
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i];
if C.Visible then
begin
if W + C.Width > FPageWidth - FPageMargin.Right then
begin
Inc(FWorkPagesNeedCount);
@ -398,6 +739,7 @@ begin
W:=W + C.Width;
end;
end;
end;
end;
procedure TRxDBGridExportPDF.DoExportPage;
@ -405,21 +747,10 @@ var
P: TPDFPage;
i: Integer;
begin
FWorkPages.Clear;
for i:=0 to FWorkPagesNeedCount - 1 do
begin
P := FPDFDocument.Pages.AddPage;
P.PaperType := FPdfOptions.PaperType;
P.UnitOfMeasure := uomPixels;
FCurSection.AddPage(P);
FWorkPages.Add(P);
end;
FPosY:=FPageMargin.Top + 20;
StartNewPage;
if repExportTitle in FOptions then
DoExportTitle;
DoExportBody;
end;
@ -436,7 +767,9 @@ begin
P:=FDataSet.Bookmark;
{$ENDIF}
FFontCollection:=TFreeTypeFontCollection.Create;
FPDFDocument:=TPDFDocument.Create(nil);
FFontItems:=TExportFonts.Create(Self);
FWorkPages:=TFPList.Create;
try
DoSetupFonts;
@ -448,6 +781,14 @@ begin
DoExportPage;
until FDataSet.EOF;
if repExportTitle in FOptions then
begin
if FPosY > FPageHeight - FPageMargin.Bottom then
StartNewPage;
DoExportFooter;
end;
DoSaveDocument;
Result:=true;
finally
@ -461,9 +802,8 @@ begin
FreeAndNil(FWorkPages);
FreeAndNil(FPDFDocument);
if Assigned(FExportFontHeader) then
FreeAndNil(FExportFontHeader);
FreeAndNil(FFontItems);
FreeAndNil(FFontCollection);
end;
if Result and FOpenAfterExport then
@ -476,6 +816,7 @@ begin
RxDBGridExportPdfSetupForm.FileNameEdit1.FileName:=FileName;
RxDBGridExportPdfSetupForm.cbOpenAfterExport.Checked:=FOpenAfterExport;
RxDBGridExportPdfSetupForm.cbExportColumnHeader.Checked:=repExportTitle in FOptions;
RxDBGridExportPdfSetupForm.cbExportColumnFooter.Checked:=repExportFooter in FOptions;
Result:=RxDBGridExportPdfSetupForm.ShowModal = mrOk;
if Result then
@ -486,6 +827,11 @@ begin
FOptions:=FOptions + [repExportTitle]
else
FOptions:=FOptions - [repExportTitle];
if RxDBGridExportPdfSetupForm.cbExportColumnFooter.Checked then
FOptions:=FOptions + [repExportFooter]
else
FOptions:=FOptions - [repExportFooter];
end;
RxDBGridExportPdfSetupForm.Free;
end;

View File

@ -74,7 +74,6 @@ object RxDBGridExportPdfSetupForm: TRxDBGridExportPdfSetupForm
Width = 162
BorderSpacing.Around = 6
Caption = 'Export column footer'
Enabled = False
TabOrder = 3
end
object cbExportCellColors: TCheckBox