cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying images dynamically on PDF

Former Member
0 Kudos

hi web dynrpo gurus,

I have created a application and it retrieves data from the back end R/3 system and I am creating a Interactive form based PDF to display that data.

Now my application involves two PDFs generated based on the selection of the user whether he wants to open an Invoice or a Credit Memo.

Now my problem is that the application would be configured on diffwerent protals which have different logos to be displayed.

Is there any option such that I could see that the logo is selected dynamically, based on the Portal in which it is configured.

Thanks and regards,

kris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

include the information about the used portal in the context of your interactive form. Then add a formcalc script inside the pdf form to display/ hide the required/ not required image.

Regards

Sebastian

Former Member
0 Kudos

hi Sebastian Voss,

Thanks for the reply.

Can you be more brief on this, as I could not understand completely ur words, as how to go ahead.

I have four logos to be dispalyed in four different portals and I have one application that is being configured in all the portals.

Please guide me how to achieve that.

Thanks and regards,

kris

Former Member
0 Kudos

Kris,

1.

in your webdynpro application add all needed images to "src/mimes/Components/<component_name>".

2.

create a context attribute "imageUrl" in the value node which is used by the interactive form UI.

3.

in wdDoInit() add the following code:


try {

	// determine the current portal and select the appropriate image
	String logo = "xyz.gif";

	String path =
		WDURLGenerator.getAbsoluteWebResourceURL(
			wdComponentAPI.getDeployableObjectPart(), logo);

wdContext.currentPdfSourceElement().setImageUrl(path);
			
} catch(WDURLException e1) {
}

4.

Add an image field to your form template and set the default binding to "None". Enter "$record.imageUrl" in the URL property field.

5.

Attach the following formcalc script to this image field:

Event: initialize

Language: FormCalc

Run At: Client


this.value.image.href = xfa.resolveNode(this.value.image.href).value;
ImageField1.access = "nonInteractive";

Regards

Sebastian

Former Member
0 Kudos

hi Sebastian Voss,

Thanks for your answer, but when I am trying to open the PDFs again and again, then I am getting the script error window popping up.

Do you have any idea why is this happening.

Thanks and regards,

kris

Former Member
0 Kudos

Could you please post the error message here in the forum.

Regards

Sebastian

PS: Think about rewarding some points

Former Member
0 Kudos

hi Sebastian,

I am getting the following error:

Script failed (language is formcalc;context is

xfa[0].form[0].BAPI_Input[0].#subform[0].ImageField1[0])

script=this.value.image.href=xfa.resolveNode(this.value.image.href).value;

ImageField1.access="nonInteractive";

Error:Argument mismatch in property or function argument

Do u have any idea how to resolve this.

Thanks and regards,

kris

Former Member
0 Kudos

Hi,

xfa.resolveNode only works on valid somExpressions, so try changing the script to:

this.value.image.href = xfa.resolveNode(this.value.image.somExpression).value;

ImageField1.access = "nonInteractive";

let us know if this helps.

Regards, Marijn Sponselee

Former Member
0 Kudos

Hi Experts

I was following the instructions given in the post, but unable to get desired result

I'm getting the following error:

<i>Script failed (language is formcalc;context is

xfa[0].form[0].Main[0].Session[0].Image[0])

script=this.value.image.href=xfa.resolveNode(this.value.image.href).value;

Image.access="nonInteractive";

Error:Malformed SOM Expression</i>

I've followed all steps, yet result doesn't come

I've even tried the following expression

<i>this.value.image.href=xfa.resolveNode(this.value.image.somExpression).value;</i>

Any pointers.

Thanks

Srikant

Answers (1)

Answers (1)

Former Member
0 Kudos

closing