Set DPI value in TppPNGDevice without _1 file
We have a problem with TppPNGDevice. If we do not specify OutputStream, the TPPReport.PrintToDevices saves a file named"_1" at the execution location. Unfortunately, this is not a good solution because our application is started several times in certain constellations and the following error occurs repeatedly: File "C:\Daten\Apps\Loader\_1" cannot be created. The process cannot access the file because it is being used by another process.
However, if we specify OutputStream (PngDevice.OutputStream := MemStream), the set DPI value is not included in the output image.
This is probably due to the different assignments of the image to the TppPNGDevice.
If the DPI value is specified, we use TPngDevice.PNG.SaveToStream(MemStream). This is how the DPI assignment works if the OutputStream is not set.
If the DPI value is not specified, we use MemStream := (PngDevice.OutputStream As TMemoryStream).
Long story short: How can we specify the DPI value for a TppPNGDevice without writing a _1 file (using the MemoryStream)?
However, if we specify OutputStream (PngDevice.OutputStream := MemStream), the set DPI value is not included in the output image.
This is probably due to the different assignments of the image to the TppPNGDevice.
If the DPI value is specified, we use TPngDevice.PNG.SaveToStream(MemStream). This is how the DPI assignment works if the OutputStream is not set.
If the DPI value is not specified, we use MemStream := (PngDevice.OutputStream As TMemoryStream).
Long story short: How can we specify the DPI value for a TppPNGDevice without writing a _1 file (using the MemoryStream)?
Comments
1. For the image device, each page of a report is exported with an underscore then page number as a suffix for the file name. If you are getting "_1" then you are not defining an initial file name (TppReport.TextFileName property). If you would like to give each file a unique name, you can use the TppImageDevice.OnAssignFileName event to do so.
2. I am unsure how you are setting the DPI of the image. The TPNGImage class does not appear to contain a DPI property. This however is un-needed to increase the resolution of an image exported with ReportBuilder. Images viewed on screen at 100% are viewed in screen resolution. If you wish to create a higher resolution image, you will need to increase the size of the image using the TppImageDevice.Scale property. For instance, setting the scale property to 3, will give you a roughly 300dpi image (when printed to a 300dpi printer). This can be scaled down to fit on your screen, but when printed, all pixels will be present.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your quick reply.
For clarification:
We set the DPI via TppPNGDevice.scale := DPI value / 96. We set the DPI value because a label printer from our customer requires this . But if we set the DPI value and at the same time TppPNGDevice.outputStream := MemStream; the DPI value in the image is lost.
If we do not set OutputStream, the DPI value remains correct, but we get the unwanted _1 file.
The solution to this is to give your image a file name and then implement the OnAssignFileName event of the image device. See #1 from my initial response.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Sorry for my late answer, but I was on vacation for a while. Can you try your example again with Scale = 2.08333333333 (200 / 96)? I tried that as you described, but the value seems to keep jumping back to the even value. Can you reproduce that?
I tried the exact example above only changing the scale from 2 to 2.08333333333 and received the expected results.
Exporting a report with a scale of 2 gave image dimensions of 1632 x 2112.
Exporting a report with a scale of 2.08333333333 gave image dimensions of 1699 x 2199.
If you would like to try my exact example, send a short email to support@digital-metaphors.com and I'll send it to you for testing.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com