#1 2011-02-21 09:10:44

martin.jeremic
Member
Registered: 2011-02-18
Posts: 1
Website

Question and possible bug (or installation problem?)??

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

#2 2011-02-21 10:51:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Question and possible bug (or installation problem?)??

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

#3 2011-02-22 21:17:03

migajek
Member
Registered: 2010-10-01
Posts: 89

Re: Question and possible bug (or installation problem?)??

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

#4 2013-08-29 07:16:58

bruce
Member
Registered: 2013-08-29
Posts: 1

Re: Question and possible bug (or installation problem?)??

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

#5 2013-08-29 08:41:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Question and possible bug (or installation problem?)??

Sorry, but I still can't understand the concern here...

TGdiPages is not a visual component, by design.
It aims to create report from code.

Offline

#6 2014-02-10 10:20:37

Celery
Member
Registered: 2014-02-10
Posts: 5

Re: Question and possible bug (or installation problem?)??

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. smile

Offline

#7 2014-02-10 10:46:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Question and possible bug (or installation problem?)??

Good idea.
See http://synopse.info/fossil/info/23d5f39c31

Thanks for the feedback!

Offline

Board footer

Powered by FluxBB