on 11-27-2013 10:10 AM
Hello everyone,
I am trying to create a PDF file using PDF renderer action block with help of xsl fo.
I am facing problem in inserting an image in PDF. I tried using xsl-fo external graphics bolck and passing its src dynamically from assignment block. But I am not getting image in PDF created. Please help me with the same.
I tried -
<fo:external-graphic src="" />
in my fo:flow
and then dynamically pass value to src.
Pls help.
Thanks,
Minakshi Soni.
Hello,
Is anyone still active on this post? I need urgent help on this. It would really be very helpful if someone can help on this issue.
Regards,
Minakshi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Minakshi,
Happy New Year and yes I am still active on the forum in general along with many others...
Anyway, can you try using the Web -> Image Loader action and then mapping in the "EncodedImage" output from the action to the image src parameter of your action and see if this works as expected. I know that the img tag definitions for an HTML page will accept this encoded image value and render a graphic and I suspect that the above library does too.
Hope this helps,
Sam
Hi Sam,
Wish you too a very Happy New Year .
I tried foloowing things:
1. Image loader output to encoded image src component (Not getting any image or even error).
2. Image loader output to block's background-image component (Not getting any image or even error).
3. Image loader output to block component itself (Getting Encoded text in block area instead of image).
The worst part I am stuck with is that I am not getting any error. Otherwise the solution could have been a bit easier.
Regards,
Minakshi.
Are you sure that the custom action code is not swalowing the exception and hiding the error from you? If you have an uncaught exception when the action finishes this will also appear in the Execution Logger Trace window when the transaction finishes.
If you use System.out.println("") it will always write the string value to the NetWeaver Java logs and if you use this code it will appear in the Execution Logger Trace too:
// This annotation tells the engine that this is an action available to execute.
@Action(name = "ExecuteACommand", icon = "/com/sap/mii/custom/actions/filerunner/icons/scroll_run.png")
// This annotation tells the engine that an XML output called 'Output' is going to be returned.
// The possible ExitValue codes are: 0 for async/successful, -1 for failed, and anything else is tied to the runtime thread exit code
@Outputs(names = { Output, OutputErr, ExitValue}, types = { VariantDataTypes.STRING, VariantDataTypes.STRING, VariantDataTypes.INTEGER })
// This annotation tells the engine that this is the Java Swing class that defines the design time action configuration dialog
@ConfigurationDialog(dialogClass = FileRunnerDialog.class, localizationType = ConfigurationDialogLabelLocalizationType.BUILT_IN)
public static void executeACommand(
// Besides the basic types, the IActionInstance interface is the only other type allowed to be
// defined in parameter list of a custom action.
IActionInstance inst,
// @Input annotations are used to indicate the user modifiable inputs to this action.
@Input(name = Command, defaultValue = "") String command,
@Input(name = InputArgs, defaultValue = "") String args,
@Input(name = AsyncProc, defaultValue = "true") boolean procAsync,
@Input(name = Trace, defaultValue = "false") boolean trace)
// Exceptions can be thrown directly from the actions without causing critical execution failures.
// These exceptions will be caught and logged by the engine and will cause the Success flag to be set to false.
throws InvalidVariableException {
Process p = null;
BufferedReader bri = null;
BufferedReader bre = null;
String outputText = ""; String errorText = "";
try {
// Verify that there is a command to run
if(command != "") {
if(trace) {
inst.log( LogLevel.INFO, "Command is: "+command+" "+args); }
......
Where using the instance of the action, hooks back to the runtime engine, you can generate execution trace messages that print out various informaitonal, warning, error, or fatal level messages. The LogLevel class specifies the severity and you can see the enitre action code in the above snippet in this document here:
Hope this helps,
Sam
Thats an example that I got few years ago from Sam.
Try this for Bitmap inside MII Webfolder:
<fo:external-graphic src='url("/XMII/CM/Folder/Bitmap.jpg")'
content-width="40mm" content-height="scale-to-fit" />
Try this for Bitmap on the filessystem:
<fo:external-graphic src='url("file:/c:/Temp/Bitmap.jpg")'
content-width="40mm" content-height="scale-to-fit" />
BR
Pedro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pedro,
I tries this format also but I am getting blank PDF in my output. My xsl-fo code is as below. Pls correct me if I am missing anything.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="PageMaster">
<fo:region-body margin="5mm 5mm 5mm 5mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="PageMaster">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:external-graphic src='url("/XMII/CM/Folder/Bitmap.GIF")' content-width="40mm" content-height="scale-to-fit"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
Is there any additional thing I am missing?
Regards,
Minakshi
What you find in the NW-Logs? Try also with providing of the complete src (http://.....). Maybe Sam can help you on this.
BR
Pedro
Minakshi,
The relative path should've worked but you can try the fully qualified path too which in your case would be:
http://url:portno/XMII/CM/ProjectName/FolderName/FileName.GIF
Does this image load if you go directly to it via your web browser? Also, are you running the transaction via the workbench or via a scheduled job or http service call to generate the PDF? Finally, does the code work if you hard code the path as you may have an issue with your image location or with it publishing properly to the web?
Finally, try this in your XSLT instead of using 'url':
<fo:external-graphic src='/XMII/CM/Folder/Bitmap.GIF' content-width="40mm" content-height="scale-to-fit"/>
Sam
Hi Sam,
http://url:portno/XMII/CM/ProjectName/FolderName/FileName.GIF is not working.
This image loads when I go through this url. Also it is the same url path that I get when I test my image in web folder. I am running the transaction via an http service call to generate the PDF. I am firstly trying the code using hardcoded path only. I am trying the same xslt that I have posted above. So I guess there is no issue in my image address.
I also tried:
<fo:external-graphic src='/XMII/CM/Folder/Bitmap.GIF' content-width="40mm" content-height="scale-to-fit"/>
Still not working.
I guess I am missing something other than path. Do I need to include any external path for fo:external-graphic or I need to do some other setting in the transaction/action block?
Have you done this before? It will be great if you could post the exact way of doing this.
Regards,
Minakshi
In the back of my memory I thought I remembered there was a way to encode images directly into the document. A quick google returns quite a few examples. Give it a shot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Minakshi,
I think you can try with Image loader action.
Thanks,
Padma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Padma,
Thanks for immediate reply.
I have tried doing that. In it I tried assigning the Encoded image output to my block input. It says output type not PDF. I also tried assigning the Encoded image output to block directly, it gives some encoded text in the block. Is there any thing I have missed?
Thanks,
Minakshi
Hi Minakshi,
You need to use PDF Image action.
Check this link
http://help.sap.com/saphelp_xmii120/helpdata/en/45/1d996b0f515352e10000000a114a6b/frameset.htm
http://scn.sap.com/thread/1482819
Regards,
Padma
Hi Minakshi,
I am not clear what is your exact requirement.
Sorry , I saw in your question as "PDF renderer action" so thought you are asking about PDF actions in MII. (still wonder if there is any PDF renderer action, I know only SVG and Animation renderer)
Can I know few things below
1. Which version of MII you using?
2. Have you already generated PDF? If so how.
(Because as far to my knowledge you need to use PDF actions of MII to generate PDF document).
3. Is there is any specific reason to use xsl-fo?
4. Can tell how you doing now or approach to generate PDF and image in that.
Regards,
Padma
I am using MII 12.2.
My need was to set width and height of PDF tables as per requirement. Which is not possible using PDF table action block.
So I have used a PDF renderer jar file which adds a PDF renderer block in action block list.
Using this, we can apply xsl fo and format our PDF. While doing so, I do not use any other PDF action block. I inserted table using xsl fo itself. And I am successful at it. But I am stuck at inserting an image. I have tried even as background image using xsl-fo external graphic element. But it is not working.Am I clear now?
Regards,
Minakshi
Hi Minakshi,
Great knowing it and thanks for update.
Well I searched and found that you need to specify absolute path, don't know if it helps you. Just tried. Looking forward if any expert can help you which can update my knowledge as well.
<fo:block text-align="center" start-indent = "10.0cm">
<fo:external-graphic>
<xsl:attribute name="src">C:/full path/</xsl:attribute>
</fo:external-graphic>
</fo:block>
Regards,
Padma
Hi Padma,
I was trying the same thing. But cannot find what will be full path in this case. It will be great if someone can explain what it will be.
I have already tried following formats:
1. "ProjectName/FolderName/FileName.GIF"
2. "web://ProjectName/FolderName/FileName.GIF"
3. "http://url:portno/XMII/CM/ProjectName/FolderName/FileName.GIF"
Please let me know if I am missing anything or going wrong.
Regards,
Minakshi
User | Count |
---|---|
11 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.