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

Urgent Problem 11.01 - Archive Viewer - Print

edited December 2008 in General
All

The procedure below has worked well for a large number of years but with
11.01 is giving problems.

We use the Archive Reader to display copy invoices, the images for which we
have stored in a .raf file (field INVOICE_RAF) - this continues to work fine

We have a print button on our invoice Preview Screen to print a copy of the
Invoice.

When the print button is selected we now get an Access Violation .....
Access violation at address 00000002. Write of address 00000008.

Below are extracts from the code we use in the hope that this may give a
clue as to where this exception is occuring.

One thing which may be unusual is that we use the PageReceiveEvent to add
text to the invoice to indicate this is a certified copy of an original
invoice.

I have marked this as urgent as we are now getting a number of customers
reporting this issue.

Thanks in advance

Philip L Jackson

DBArchiveReader.DataBaseSettings
.BLOBField = INVOICE_RAF
.DataPipeline = plCopyInvoice
.Name (set below on print
.NameField = INVOICE_NO


This code loads the template into the Viewer
if winInvCopy.CopyGroup.ItemIndex = 1 then
winInvCopy.InvoiceTable.First;
plCopyInvoice.DataSource :=
winInvCopy.InvoiceData;
DBArchiveReader.DatabaseSettings.BLOBField :=
'INVOICE_RAF';
DBArchiveReader.DatabaseSettings.NameField :=
'INVOICE_NO';
DBArchiveReader.DatabaseSettings.Name :=
winInvCopy.InvoiceTable.FieldByName('INVOICE_NO').value;
ppviewer1.report :=
DBArchiveReader;
ppViewer1.RegenerateReport;

This code Prints the invoice.....
lsName :=
winInvCopy.InvoiceTable.FieldByName('INVOICE_NO').AsString;
MyCopies := StrToInt(edtCopies.Text); //this may be
changed after 1st print by Print Dialog

if (lsName <> '') then
begin
DBArchiveReader.DatabaseSettings.Name := lsName;
ppViewer1.Print; <<<<< Access violation at address
00000002. Write of address 00000008.
end;

The following code adds a statement the "This is a certified copy of the
Original Invoice" to the print........

procedure TwinInvRB.DBArchiveReaderBeforePrint(Sender: TObject);
begin
if DBArchiveReader.PrinterDevice <> nil then
DBArchiveReader.PrinterDevice.OnPageReceive :=
PageReceiveEvent;

end;

procedure TwinInvRB.PageReceiveEvent(Sender, aPage: TObject);
begin
CreateDrawCommand(aPage);

end;

procedure TwinInvRB.CreateDrawCommand(aPage: TObject);
var xLen, xPos :integer;
lDrawText: TppDrawText;
documentType, st1, st2:string;
begin

lDrawText := TppDrawText.Create(nil);
lDrawText.Page := TppPage(aPage);

if MainDataModule.SystemTable.FindKey(['142']) then
begin
try
lDrawText.Text :=
MainDataModule.SystemTable.FieldByName('CONTROL').AsString;
MainDataModule.SystemTable.Next;
lDrawText.Text := lDrawText.Text + ' '
+MainDataModule.SystemTable.FieldByName('CONTROL').AsString;
if pos('',lDrawText.Text) > 0 then
begin
case winInvRB.Tag of
998: documentType := 'Credit Note';
else documentType := 'Invoice';
end;// end of case

xPos := pos('',lDrawText.Text);
xLen := Length(lDrawText.Text);
st1 := Copy(lDrawText.Text,1,xPos-1);
st2 := Copy(lDrawText.Text, xPos + 3,(xLen - xPos - 3));
lDrawText.Text := st1 + documentType + st2;
end;
lDrawText.Transparent := True;
lDrawText.IsMemo := False;
MainDataModule.SystemTable.Next;
lDrawText.Font.Name :=
MainDataModule.SystemTable.FieldByName('CONTROL').AsString;
MainDataModule.SystemTable.Next;
lDrawText.Font.Size :=
MainDataModule.SystemTable.FieldByName('CONTROL').AsInteger;
MainDataModule.SystemTable.Next;
lDrawText.Font.Color :=
StringToColor(MainDataModule.SystemTable.FieldByName('CONTROL').AsString);
lDrawText.Autosize := True;
MainDataModule.SystemTable.Next;
lDrawText.Left :=
MainDataModule.SystemTable.FieldByName('CONTROL').AsInteger; //Microns
MainDataModule.SystemTable.Next;
lDrawText.Top :=
MainDataModule.SystemTable.FieldByName('CONTROL').AsInteger; //Microns
except on e:exception do
begin
lDrawText.Text := 'Certified Report';
lDrawText.Transparent := True;
lDrawText.IsMemo := False;
lDrawText.Font.Name := 'Arial';
lDrawText.Font.Size := 18;
lDrawText.Font.Color := clRed;
lDrawText.Autosize := True;
lDrawText.Left := 100000; //Microns
lDrawText.Top := 10000; //Microns
end;
end;

end else
begin
lDrawText.Text := 'Certified Report';
lDrawText.Transparent := True;
lDrawText.IsMemo := False;
lDrawText.Font.Name := 'Arial';
lDrawText.Font.Size := 18;
lDrawText.Font.Color := clRed;
lDrawText.Autosize := True;
lDrawText.Left := 100000; //Microns
lDrawText.Top := 10000; //Microns
end;
end;

Comments

  • edited December 2008
    Hi Philip,

    Which version of Delphi are you using? If you trace into the ReportBuilder
    source by adding RBuilder\Source to your library path, where is the AV
    occuring?

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2008
    Hi

    Environment id Delphi 2007 Professional

    Access Violation occurs in class TppProducer
    Unit ppProd.pas Line 1798

    Hope this helps.

    Regards

    Philip L Jackson
  • edited December 2008
    Hi Philip,

    Line 1798 is a generic modal exception. Unfortunately the issue is most
    likely somewhere else.

    If possible, please send a simple example that demonstrating this issue in
    .zip format to support@digital-metaphors.com and I'll try to track down the
    problem here on my machine.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2008
    >Line 1798 is a generic modal exception.

    The purpose of that line is to re-raise any exception that occurs while
    generating the report from the modal preview form.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2008
    Hi

    I have run this in more detail and the exception occurs on line 1795
    FCancelDialog.ppShowModal;

    I will endeavour to create a small application to demonstrate this.

    Regards

    PLJ

    {display cancel dialog}
    if (FCancelDialog <> nil) then
    begin
    if FModalCancelDialog then
    begin
    {for modal dialog, must call PrintToDevice from the forms Activate
    event}
    FCancelDialog.ppOnShowModal := CancelDialogShowModalEvent;
    if FModalException <> nil then
    begin
    raise FModalException;
    FModalException := nil;
    end;

    end
    else
    begin
    FCancelDialog.Show;

    PrintToDevices;
    end;
    end


  • edited December 2008
    Hi

    Sample Program and data sent.

    Regards

    PLJ

  • edited December 2008

    That is where the exception gets re-raised. :)



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2008
    Thanks for the example. :)

    The error can occur when printing an archived report containing rich text to
    the printer.

    There is now a patch to RB 11.01 that fixes the issue. Registered users can
    email support@digital-metaphors.com and request the patch.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.