Report with pictures from files
I have a report that will be created from a database typically with many thousand entries. For each entry there will be a different image that needs to be displayed, the databse just contains a token that allows me to find the relevant image (from disk) to display.
New to FR so not sure how I go about this.
Any help appreciated.
New to FR so not sure how I go about this.
Any help appreciated.
Comments
You should read FR User Manual chapters 2.13 and 2.14 - you'll find a lots of information over there.
create a variable and connect it to the datafield that has your file info.
in the obp event of the pictureview object or the band that contains the pictureview, write code to load from file.
ie
picture1.picture.loadfromfile(<variablename>);
Just one clarification which might make a difference [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> The db does'nt contain an image, it contains a reference that I use to create an image - so basically as each record is processed by fast report I will need some logic to copy (and modify - but that is in hand) the image from one location to another and it is this second location that i will be able to pass to fast Reports. Alternatively I could pass a buffer containing a jpg/png etc - is this doable? Thanks[/img]
TPicture object doesn't have LoadFromStream() method [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> So after you finish a manipulation with your picture according to a certain table / query row, you must save that picture anywhere on disk(s) and then use[/img]LoadFromFile(<Path.fileName.ext>) to read that just saved file.
Alternative to save / load picture to / from file is to make use of your database (temporary or standard) table with long binary (or similar) field. If you try this option then, when your final picture is ready and is still kept in a memory save it to a blob field in this table and have TfrxPictureView to read this field from the table.
the FileExists function is added at runtime using the report.script.addmethod
in the code of the report:
I have the same scenario as the original writer and I found your instructions very helpful.
However, as the FastReports version shipped with Delphi XE3 does not siupport events I had to solve the issue in another way:
1) Assign the datafield into a variable, e.g. 'filename'
2) Assign the FileLink property of the picture object as the variable, i.e '[filename]'
Works nicely at least in FR 4.12.13
The above is for anyone face the same scenario again.
Kr, Kalle