Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Empty PDF after creating report @ runtime

edited April 2007 in General
I am creating a report completely at runtime. The first time I call the
report all is fine, the second time I get an "empty" PDF. The PDF is not
completely empty, it does have the number of pages it should have, but
there is no text on the pages. There is an image on the page, this is
visibile. So it seems like text is not visible, not the right color, ....

The DataSet is closed when entering the routine and has a recordcount of
10 the first and second time. I'm sending some objects to the viewer,
they all have the same properties the first and second time.

This is my routine toe create the report:

procedure TRBuilderRuntimePrinter.PrintDataSet(Trace: IWinTrace; DataSet:
TIBQuery; FileName: string);
var
i: Integer;
PipeLine: TppDBPipeline;
DataSource: TDataSource;
Field: TField;
LeftPos: Integer;
Header: TppBand;
Detail: TppBand;
DisplayWidth: Integer;
CloseDataSet: Boolean;
begin
LeftPos := 2;

Report := TppReport.Create(nil);
PipeLine := TppDBPipeline.Create(nil);
DataSource := TDataSource.Create(nil);
try
Report.NoDataBehaviors := [ndBlankReport, ndMessageOnPage];

DataSource.DataSet := DataSet;
PipeLine.DataSource := DataSource;
Report.DataPipeline := PipeLine;

Header := Report.AddBand(btHeader, 0);
Trace.Debug.SendObject('Header', Header);
Header.spHeight := 20;

Detail := Report.AddBand(btDetail, 0);
Trace.Debug.SendObject('Detail', Detail);
Detail.spHeight := 20;

Trace.Debug.Send('Aanmaken velden');
Trace.Debug.SendObject('DataSet', DataSet);
Trace.Debug.SendValue('Query', DataSet.SQL.Text);

CloseDataSet := not DataSet.Active;
DataSet.Open;
try
DataSet.FetchAll;
Trace.Debug.Send(Format('%d regels', [DataSet.RecordCount]));
DataSet.First;

for i := 0 to DataSet.FieldCount - 1 do
begin
Field := DataSet.Fields[i];
DisplayWidth := Field.DisplayWidth * 10;

Trace.Debug.Send(Format('Veld %s breedte %d, positie %d',
[Field.FieldName, DisplayWidth, LeftPos]));

with TppLabel.Create(Header) do
begin
Caption := Field.DisplayName;
Band := Header;
spLeft := LeftPos;
spTop := Header.spHeight - spHeight;
spWidth := DisplayWidth;
Visible := True;
Alignment := Field.Alignment;
end;

with TppDBText.Create(Detail) do
begin
Band := Detail;
spLeft := LeftPos;
spTop := 2;
spWidth := DisplayWidth;
AutoSize := False;
Visible := True;
DataPipeline := Pipeline;
DataField := Field.FieldName;
Alignment := Field.Alignment;
end;

LeftPos := LeftPos + DisplayWidth;
end;

Report.TextFileName := FileName;
Report.ShowPrintDialog := False;
Report.ShowCancelDialog := False;

Report.AllowPrintToFile := True;
Report.DeviceType := 'PDF';

Report.PDFSettings.Author := 'LEAD Software';
Report.PDFSettings.Title := 'Export to PDF!';
Report.PDFSettings.OpenPDFFile := False;

Trace.Debug.SendObject('Printen', Report);
Report.Print;
Trace.Debug.Send('Gereed');
finally
if CloseDataSet then
DataSet.Close;
end;
finally
Report.Free;
DataSource.Free;
PipeLine.Free;
end;
end;

Versions:

Delphi 2006, all patches
Report Builder 10.0.4

Regards,

Marcel van Beuzekom

Marcel van Beuzekom

--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited April 2007
    Hi Marcel,

    If you trace your routine below, are the text objects being properly created
    and set the second time around? The PDF Device simply generates the pages
    the Report sends. If there are missing components, then they are probably
    not being created properly in the first place. Try previewing the report on
    screen before exporting to PDF and see if the text is there the second time
    you print.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2007
    Nico Cizik (Digital Metaphors) wrote:



    Not sure if it is related, but today had a user with the exact same
    problem. A reportbuilder 10.0.5 report generated a pdf without text.
    Images and shapes were all there, but all text was missing from the pdf
    file. I have to mention that we use ExportDevices to create the pdf. So
    I am not sure if this is a reportbuilder or ExportDevices problem. I
    suspected the latter but reading Marcels post it could well be
    ReportBuilder.

    It gets weirder. The report runs fine on all computeres we tested it
    on. But the user is located in Hong Kong, so I am trying to figure out
    if he uses a Chinese Windows XP version and if that has any influence.
    At the moment I am lost trying to explain what is happening. It is
    quite hard to find the problem if it cannot be replicated.

    Jan Derk
  • edited April 2007
    Hi Nico,

    The objects are created allright. The real program is running in a
    service (providing the reports to an ASP.NET website) but I tested in a
    testproject and did see a filled report in a preview the second time. So
    it seems the problem is in the PDF Device.

    Regards,

    Marcel

    created
    pages
    probably
    report on
    time

    Marcel van Beuzekom

    --- posted by geoForum on http://delphi.newswhat.com
  • edited April 2007
    Hi Marcel,

    I have not seen this behavior before. If possible, please send a small
    example demonstrating the problem to support@digital-metaphors.com and I'll
    take a look at it for you. I also strongly suggest upgrading your version
    of ReportBuilder to 10.06.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2007
    Hi Jan,

    This may have something to do with the way ExtraDevices handles embedded
    fonts. I believe ExtraDevices supports embedded fonts however you might try
    contacting them to see if they can help with this issue.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2007
    Test project is sent to you by email.

    I found out it is a threading issue. If I create a
    TRBuilderRuntimePrinter (my component) directly there is no problem, if
    I create a TThreadPrinter and it creates a TRBuilderRuntimePrinter, the
    PDF is empty the second time. To make it even more difficult this only
    happens on a multi CPU machine.

    Marcel

    I'll
    version



    --- posted by geoForum on http://delphi.newswhat.com
  • edited April 2007
    Nico Cizik (Digital Metaphors) wrote:


    I think the problem is not caused by not having embedded fonts. Correct
    me if I am wrong but if the font is not embedded, the text will still
    be in the pdf and show up in a different font on other computers. The
    text is just not in the pdf. To double check I opened it in Illustrator
    and there is no text at all. It sounds like the threading issue Marcel
    is talking about and I hope it is, because I am basicly just guessing
    until I can actually replicate the problem.

    Jan Derk
  • edited April 2007
    Thanks Marcel,

    We can continue our discussion via. email. I will post a solution to this
    issue when it is found.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.