• Welcome to the new forum! We upgraded our forum software with a host of new boards, capabilities and features. It is also more secure.
    Jump in and join the conversation! You can learn more about the upgrade and new features here.

Including image in reports

MDE

Apprentice
Joined
Aug 9, 2017
Messages
3
Reaction score
0
I like that you can add an image to a recipe instead of the standard glass, but when you print a report you only get the standard glass. Is there a way of including the recipe image on a custom report? Otherwise the only way I can see to do it is to save the output html and hack that, which would be a bit of a pain each time.
Thanks
 
I do not currently have that option - sorry.

Brad
 
I did the following to add a custom image to my reports, and it also works when you print it out.

**I'm a Windows user so this would need to be edited for Mac users. Hopefully someone here can help with the file paths and locations.
[If using BeerSmith2 replace BeerSmith3 with BeerSmith2]

For the Windows version, do the following:
1) Copy your images into the following folder location: C:\Users\[YourUserDirectory]\Documents\BeerSmith3\Reports

2) Add the code below to your Recipe report "NewRecipe.htm" add/or your Brew Steps report "NewBrewsheet.htm". I also use it for my custom reports.

3) In the "Taste Notes" text box, in the "Notes" section, type the file name you want to use with [* in front of the file name and followed with *] after the file name. Do not add a space in front or in back of the file name. (i.e. [*image.jpg*] )

Putting the [* *] around the file name will allow you to still use the "Taste Notes" field for any notes you want to add. If the tags are there, the script will pull it out of the text field regardless of what is in front or behind it and display that image.

The "NewRecipe.htm" and "NewBrewsheet.htm" files are in the C:\Program Files (x86)\BeerSmith3\Reports folder.

You can use note pad to edit the file. I recommend making a backup of the file first. Because of user rights, you may need to copy the file into another directory and then copy & replace the file back into the reports folder. When pasting the code, the format of the text may look different, but it still works.

In the report file, look for:

<img src='$GLASS' style="width:5.3em; height:9em;"/>

and replace it with the following text:

<script>
var varTasteNotes = "$TASTE_NOTES";
var varOpen = varTasteNotes.indexOf("[*");
var varClose = varTasteNotes.indexOf("*]");
var varCustomGlass = "";
varCustomGlass = varTasteNotes.substring(varOpen + 2, varClose);
var varFileExt = varCustomGlass.substring(varCustomGlass.lastIndexOf(".") + 1);
var varGlassSRM = "$GLASS".substring("$GLASS".lastIndexOf("/") + 1);
var varGlass = "file:///C:/Program%20Files%20(x86)/BeerSmith3/icons/" + varGlassSRM;
if (varFileExt == "png" || varFileExt == "jpg" || varFileExt == "gif"){
document.write('<img src=' + varCustomGlass + ' height="115" width="68" />');
} else {
document.write('<img src=' + varGlass + ' height="115" width="68" />');
}
</script>



Hope this works for you, Cheers!
 
Back
Top