You are not logged in.
Did you notice the SQLite3Pages units?
It's a reporting unit included in our SQlite3 framework, but it can be used standalone...
You create your report from code, then you can preview it on the screen.
You can then print or export the report as PDF.
Note that the report drawing uses GDI+, even if you embed .emf files or TMetaFile in them: with antialiaising, they just look smooth on screen.
Just right click on the report preview to see options.
Here is some code sample to create a report:
procedure TForm1.btn1Click(Sender: TObject);
var i: integer;
begin
with TGDIPages.Create(self) do
try
// the title of the report
Caption := self.Caption;
// now we add some content to the report
BeginDoc;
// header and footer
AddTextToHeader(paramstr(0));
SaveLayout;
Font.Style := [fsItalic];
TextAlign := taRight;
AddTextToFooterAt('http://synopse.info',RightMarginPos);
RestoreSavedLayout;
AddTextToFooter(DateTimeToStr(Now));
// main content (automaticaly split on next pages)
NewHalfLine;
DrawTitle(edt1.Text,true);
for i := 1 to 10 do
DrawText('This is some text '+IntToStr(i));
NewLine;
AddColumns([10,20,50]);
AddColumnHeaders(['#','Two','Three'],true,true);
for i := 1 to 100 do
DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'Some text here']);
NewLine;
DrawTitle('This is your text:');
DrawText(mmo1.Text);
EndDoc;
// this method will show a preview form, and allow basic actions
// by using the right click menu
ShowPreviewForm;
finally
Free;
end;
end;
You can download a sample project source code (together with its compiled exe file) from http://synopse.info/files/pdf/SQLite3Pages.7z
You should need other Synopse units, available from synpdf.zip.
The resulting pdf file can be downloaded from http://synopse.info/files/pdf/SQLite3Pages%20Test.pdf
Source code is licensed under a MPL/GPL/LGPL tri-license.
Offline
Here is how to create a report content from a TRichEdit component:
Offline
Note that you have a true Canvas property in the TGDIPages class.
So you can use TGDIPages to create a print preview and pdf export, by using TGDIPages.Canvas instead of Printer.Canvas.
Offline
Administrator,
How do you add a bmp image in this example with TGDIPages?
Something like:
Var
image: TBitmat;
image: TBitmap.Create = (nil)
image.LoadFromFile ('c: \ ...
I appreciate your help
Eraldo
Last edited by eraldo (2010-09-03 07:14:48)
Offline
Reporting has just been enhanced (in our source code repository): now handle bookmarks, links, and document outline, and life-navigation within the report preview. The generated PDF file also handle those links and outline tree. Some issues were also fixed (about bitmaps or underlined text). And one bitmap will be stored only once in the PDF, if it's drawn several times on the report.
So make sure you're using the latest source code repository version.
Offline
Here is some sample code, showing some new features of the SQLite3Pages unit:
procedure TForm1.btn1Click(Sender: TObject);
var i: integer;
Bmp: TBitmap;
s: string;
begin
Bmp := TBitmap.Create;
try
Bmp.Width := ClientWidth;
Bmp.Height := ClientHeight;
PaintTo(Bmp.Canvas,0,0); // create some bitmap content
with TGDIPages.Create(self) do
try
// the name of the report is taken from main Window's caption
Caption := self.Caption;
// now we add some content to the report
BeginDoc;
// header and footer
Font.Name := 'Georgia';
Font.Size := 11;
SaveLayout;
Font.Style := [fsItalic,fsUnderline];
TextAlign := taRight;
AddTextToHeaderAt('http://synopse.info',RightMarginPos);
Font.Style := [];
AddLineToFooter(false);
AddPagesToFooterAt('Page %d/%d',RightMarginPos);
RestoreSavedLayout;
AddTextToHeader(ExtractFileName(paramstr(0)));
AddTextToFooter(DateTimeToStr(Now));
AddLineToHeader(false);
Font.Size := 12;
// main content (automaticaly split on next pages)
NewHalfLine;
TextAlign := taJustified;
s := 'This is some big text which must be justified on multiple lines. ';
DrawText(s+s+s+s);
NewLine;
TextAlign := taLeft;
DrawTitle(edt1.Text,true);
for i := 1 to 10 do
DrawText('This is some text '+IntToStr(i));
NewLine;
DrawBMP(Bmp,maxInt,50,'Some bitmap in the report');
AddBookMark('bookmarkname');
WordWrapLeftCols := true;
AddColumns([10,20,50]);
AddColumnHeaders(['#','Two','Three'],true,true);
for i := 1 to 100 do
DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'Some text here. '+s]);
NewLine;
DrawBMP(Bmp,maxInt,50,'Some bitmap in the report (twice)');
DrawTitle('This is your text',false,0,'','bookmarkname');
DrawText(mmo1.Text);
EndDoc;
// set optional PDF export options
// ExportPDFForceJPEGCompression := 80;
// ExportPDFEmbeddedTTF := true;
// ExportPDFUseUniscribe := true;
// show a preview form, and allow basic actions via the right click menu
ShowPreviewForm;
// ExportPDFA1 := true;
// ExportPDF(ChangeFileExt(paramstr(0),'.pdf'),true,true);
finally
Free;
end;
finally
Bmp.Free;
end;
Close;
end;
The AddBookMark method is used to create a bookmark at the current Y position.
Then 'bookmarkname' is added to the DrawTitle() method, so that clicking on this title will browse back to the bookmark position.
All titles are now automatically added to the global outline of the document, which is accessible via the right click menu.
During the export to PDF, all outilines and links are also handled and exported as such.
Offline
Hello,
I am trying to use the code in Post #8 in Delphi XE6 and am getting errors like DrawBMP not found.
Am I missing something here?
TIA
Yogi Yang
Offline
I guess you are using an old version of the unit.
Please download the latest version from the trunk.
The easiest is to download via http://synopse.info/files/mORMotNightlyBuild.zip and get the units you need.
See also http://synopse.info/files/html/Synopse% … l#TITL_113
Offline
Thanks,
I have managed to solve my problem.
I had to update the file SynCommons.pas
with these lines:
{$elseif defined(VER250)} 'Delphi XE4'
{$elseif defined(VER260)} 'Delphi XE5'
{$elseif defined(VER270)} 'Delphi XE6'
Offline
Ok thanks.
Offline
Hello again,
I have got around 1000 images in one single folder.
I am trying to get their thumbnails to print like http://s3.postimg.org/dj4witwk3/2015_11_23_213907.jpg
But I am getting only image per line instead of multiple images on the same line.
Here is the main code that I am using for inserting image in PDF
LL := Col * 2500;
Bmp.Assign(ieTemp.Bitmap);
DrawBMP(Bmp,LL,50,FileName)
Col := Col +1;
What mistake am I making here?
TIA
Yogi Yang
Offline
DrawBMP(Bmp,maxInt,50,'Some bitmap in the report');
In this line why do you use maxInt?
If I try to use any other value the image just does not print. Why?
TIA
Yogi Yang
Offline
I am attempting to get this demo to work with the latest sources (from the nightly build, no less). The preview looks fine, but when I attempt "PDF Export" all I get is three blank pages. If I Print to Microsoft PDF printer it works. I am using XE5 on Win10/64.
Any suggestions?
Thanks,
Dave
p.s. The "PDF Export" function from the pre-compiled demo TestSQLite3Pages.exe (compiled in 2010) works properly on my system.
Offline