Need TImage/TBitmap from first Page in PreviewForm without Background
Hello,
after starting the Print Preview the Report renders the first page and then I need the image (TBitmap) from this page without the grayed background of the
So far I use
in the body of
I need the pure Page Image without any scaling, borders or margin background. Is this possible?
Thanks,
Utzel
after starting the Print Preview the Report renders the first page and then I need the image (TBitmap) from this page without the grayed background of the
PreviewForm.Viewer.ScreenDevice
. Where can I find this?So far I use
TppViewer(ppReport.PreviewForm.Viewer).ScreenDevice.PageImage
in the body of
TppReport.OnEndFirstPass
event, but this is not perfect as it may include the grayed viewer background and additional it is depending on the zoom options.I need the pure Page Image without any scaling, borders or margin background. Is this possible?
Thanks,
Utzel
Comments
The ScreenDevice renders the page(s) and background all as a single image. If you would like to extract individual pages as images, I suggest using the ImageDevice. This will give you just the page image without background and scaled as you need. See the following article on using this device.
http://rbwiki.digital-metaphors.com/output/image/image-device-fundamentals/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Could I call this from within printing, e.g. in background of showing the preview to the end-user? Otherwise I would have to run the report twice, once for my internal image and once for the regular preview.
The goal is to save a preview image and show this in the next time when the user is looking for a report but without to execute all of the given report templates before.
Unfortunately due to the threading nature of the screen device, it is not possible to export to image and screen simultaneously. Since I'm guessing you only need an image of the first page, it would be fairly simple (and fast) to export the first page of a report to image before or after the preview has finished and save that file as the preview image.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
but we have the TppViewer(ppReport.PreviewForm.Viewer).ScreenDevice.PageImage with margin background, so it would be perfect when the ScreenDevice additional could have a property (e.g.) PageImageOrigin like the PageImage without the background. Would that be realizable for a future release? I think that could be helpful for other developer too.
Otherwise okay, then I have to start the report twice. But we have some big data reports. Could you explain what the process should look like in order to lose as little time as possible with additional data access, please? And how can I ensure that only the first page is saved as an image when the first start, and not the entire report?
Best regards and thanks a lot!
In the first call I unfortunately have to use "Print" instead of "PrintToDevices" because otherwise no image will be saved. This has the disadvantage that dialogs are shown during the output. Is there no better solution for this?
Another problem is the file name. For dtPDF this works as expected, but for dtJPEG (dtBMP ...) the file name is extended with an unwanted "_1". How can I fix it?
Rather than altering the DeviceType, try creating your own TppImageDevice descendent. Also, you can implement the ImageDevice.OnAssignFilename event to take control over the default image naming (underscore + page number). Below is some sample code.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com