Vicky Stamatopoulou on 9. August 2011
Those of you who have checked our new post series about “Merlin report templates” know by now…
Now let’s do some magic with the reports.
What if you want to be able to define the size of the project image over the options?
In the standard Merlin report templates, you have the option of enabling the “project image”. Should you choose to output the project image, Merlin checks in the “Misc” tab of the project settings whether you have defined such a file and renders it then into the report page in original size.
In case you have a much too large project image which you definitely need on your report, you would have to scale down the original picture and re-drop it in the project settings dialogue.
To avoid re-scaling, or to be able to do reports for different clients and projects but in a standard way, you may insert an option in the report template and re-size your project images accordingly.
Your workflow
<dict>
<key>key</key>
<string>projectImageScale</string>
<key>title</key>
<string>Project Image Scale</string>
<key>valueClass</key>
<key>possibleValues</key>
<array>
<integer>0</integer>
<integer>100</integer>
<integer>200</integer>
<integer>300</integer>
<integer>400</integer>
<integer>500</integer>
</array>
<key>possibleValueDescriptions</key>
<array>
<string>no change</string>
<string>100 px</string>
<string>200 px</string>
<string>300 px</string><string>400 px</string>
<string>500 px</string>
</array>
<key>restrictToPossibleValues</key>
<true/>
<key>allowNullValue</key>
<false/>
<key>defaultValueString</key>
<string>0</string>
</dict>
self.projectImageScale = 0
It is the area with the conditional
<wbl:Conditional condition=withProjectImage>
<wbl:Image data=project.imageData mimeType=”image/png” key=”logo” width=formImageResizer />
def formImageResizer(self):
myWblImageSizeTag = ""
scale = self.projectImageScale
if scale > 0:
scale = int(scale)
myWblImageSizeTag = str(scale)
return myWblImageSizeTag

Tags: Customize, Merlin report template, Report, Templates
No comments yet.
RSS feed for comments on this post. TrackBack URL