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

Print Directly to JPEG:

Greetings All,

I need the ability to print directly to a JPEG file.

I have tired this code, but no file is created.

Can anyone tell me what I may be doing wrong?

Thanks,
Mike

uses ppTypes;
...

//* Call to procedure below
ProcessData(False, 'C:\Temp\123456-1 Debt Info.jpg');


procedure TdtmDebtInformation.ProcessData(RedactInfo: Boolean; ExportFileName: String);
var
...
sFileExt: String;
begin
inherited;
sFileExt := UpperCase(ExtractFileExt(ExportFileName));
...

with rptDebtInformation do
begin
if sFileExt = '.JPG' then
begin
ShowPrintDialog := False;
DeviceType := dtJPEG;
DefaultFileDeviceType := 'JPEG';
end
else
begin
ShowPrintDialog := True;
DeviceType := dtScreen;
DefaultFileDeviceType := 'PDF';
end;

TextFileName := ExportFileName;

Print;
end;
...
end;

Comments

  • Note:
    I decided to temporarily show the print dialog and following were pre-set:

    Print to File is checked,
    Type is set to "JPEG File", and
    Where is set to "C:\Temp\309711-1 DebtInfo.jpg"

    I then clicked "OK" and the file is still not created.

    Still open to any tips.


  • Please disregard for the moment as even though I have data in the dataset I'm ending up with a blank report. Tracing now.
  • OK, I figured out what is going on, but do not understand why it is happening.

    I set this property to:
    rptDebtInformation.TextFileName := 'C:\Temp\309711-1 DebtInfo.jpg'

    and then print
    rptDebtInformation.Print;

    It is creating a file named "309711-1 DebtInfo_1.jpg" in the Temp directory. Notice the "_1" between "Debt Info" and ".jpg"

    How could this possibly be?

    Very Strange indeed.
  • Hi Michael,

    When exporting to images, ReportBuilder exports each page as a single image. To differentiate the pages, each file has a page number suffix.

    See the help topic for TppImageDevice.ImageFileName for more information on how image exports works in ReportBuilder. If you would like to take control over the naming mechanism, you can implement the OnAssignFileName event of the image device.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.