You are not logged in.
Hil everyone. My question is is it posible to load existing pdf document in to control just for reading?
Also, i added units from download to existing package on my delphi 2007 configuration, build them and added new component, TGDIPages. But when i add GDIPages to a form in my application i can't click on it... Every click on component (designtime) raise "List Index Out Of Bounds (0)" error...
Thanks in advance
Martin
Offline
About loading an existing pdf document, it's not possible yet, because a pdf parser is needed.
If you want to contribute, you're welcome!
See http://synopse.info/fossil/tktview?name=4e8685d8a3
But it's some huge work.
About TGdiPages, it's not meant to be used at design time.
(that's why there is no "Register" procedure available)
Since all report content is to be created from code, it does not make sense to have a void report on your IDE.
You'll have to create the component instance at runtime, and add it to your form (in the OnFormShow event, e.g.).
Offline
Arnaud, possibly it's the same problem I had when dealing with empty TGDIPages.
I wanted to create instance of TGDIPages on application startup, then - later - fill it with data.
creating empty TGDIPages and assigning a parent caused List index out of bounds(0) error.
I had no time for tracking the issue so I simply added those two lines
fReport.BeginDoc;
fReport.EndDoc;
but I guess it might be the same problem as Martin had.
Offline
I had exactly the same problem as Martin.
It's nothing to do with loading pdf's...
I downloaded the latest source and build with Delphi 2010
Add a TGDIPages to an empty form and it crashes with the error message:
List Index out of bounds(0).
TGDIPages is not a visual component!
But then, it shouldn't even appear on the component palette.
I did a bit of searching to find the reason (actually, it was even pointed out on this page but I didn't click at the time).
Here is the example I found
procedure TForm2.Button3Click(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('footnote',RightMarginPos);
RestoreSavedLayout;
AddTextToFooter(DateTimeToStr(Now));
// main content (automaticaly split on next pages)
NewHalfLine;
DrawTitle('Sample Report', 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),'Row '+IntToStr(i),'Some text here']);
NewLine;
DrawTitle('This is your text:');
DrawText(memo1.text);
EndDoc;
// this method will show a preview form, and allow basic actions
// by using the right click menu
ShowPreviewForm;
finally
Free;
end;
end;
Last edited by bruce (2013-08-29 07:32:24)
Offline
Hi!
Sorry for digging up an old thread.
Even if TGdiPages isn't a visual component I find it convenient to be able to assign properties and events at designtime and not having to do everything in code.
The "List index out of bounds" error can be avoided by adding an if-statement to the top of TGDIPages.PreviewPaint(). Here is my solution, in case someone else is interested, or if you'd like to add it to the official source code.
procedure TGDIPages.PreviewPaint(Sender: TObject);
var R: TRect;
P1,P2: TPoint;
begin
if csDesigning in ComponentState then
begin
R := fPreviewSurface.ClientRect;
fPreviewSurface.Canvas.Brush.Color := Color;
fPreviewSurface.Canvas.FillRect(R);
end
else
begin
// Here goes existing code unchanged, except indented
end;
end;
I've been using it with Delphi 7, XE2 and XE5 without any complications..... so far.
Offline
Good idea.
See http://synopse.info/fossil/info/23d5f39c31
Thanks for the feedback!
Offline