Skip to Content
0

How to generate a PDF in SAP Cloud Integration / HCI

Sep 14, 2017 at 02:19 PM

180

avatar image

Hi,

I am looking for the best way to generate a pdf in SAP Cloud Integration based upon incoming data.
I assume this needs to be done with scripting but I am not sure how or which libraries to use for this (Ghost4J maybe).

What would be the procedure ?

Thanks

Tom

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Sep 15, 2017 at 08:00 AM
0

Hi tom,

You can you itext package also to generate pdf through groovy, Please see below link that might help you.

https://milkedeek.wordpress.com/2012/01/03/itext-on-the-jvm/

Regards

GB

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Gagandeep,

I am working with the web ui and apparently need a way to add external packages.
Am I correct in assuming the external jars must be in package src.main.resources.lib?

I am not sure if this is already possible via the web ui, maybe via download integration and edit. Otherwise revert to Eclipse for these cases.

Regards

Tom

0
Tom van Rooijen Sep 15, 2017 at 09:48 AM
0

Hi Gagandeep,

Thanks for your answer.

I saw that itext package as well. the problem I have with this (and other packages) that they do not seem to import in groovy. I get error messages like this:

javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script261.groovy: 9: unable to resolve class com.itextpdf.text.pdf.PdfWriter @ line 9, column 1. import com.itextpdf.text.pdf.PdfWriter ^

Script261.groovy: 6: unable to resolve class com.itextpdf.text.Document @ line 6, column 1. import com.itextpdf.text.Document ^

Script261.groovy: 7: unable to resolve class com.itextpdf.text.DocumentException @ line 7, column 1. import com.itextpdf.text.DocumentException ^

Script261.groovy: 8: unable to resolve class com.itextpdf.text.Paragraph @ line 8, column 1. import com.itextpdf.text.Paragraph ^

Am I missing something basic here?

Thanks

Tom

Share
10 |10000 characters needed characters left characters exceeded
Sriprasad Shivaram Bhat
Sep 18, 2017 at 06:31 AM
0

Hello Tom,

If you are using eclipse perspective for integration design create package src.main.resources.lib and import your external jar file.Then you can use the respective methods of that particular jar in your script.

Regards,

Sriprasad Shivaram Bhat

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Sriprasad,

That works, thanks. Also export ui integration and an adding the src.main.resources.lib in the zip and upload again works.

Now I still have the challenge of adding the created attachment to the mail adapter. I've seen examples that send mail from groovy, but obviously that is not what I want.

The mail adapter supports adding attachment from either Header or Body, I do not see a possibility for using the camel attachment property.

I think I have the pdf within my script, but do not know how to pass it on to the mail adapter.

Any Ideas?

Thanks

Tom

0

Hello Tom,

Why dont you set your attachment to header in your script and later access it in Mail Adapter as header.

Regards,

Sriprasad Shivaram Bhat

0

Hello Sriprasad,

What would be the syntax for that?

If I use something like

message.setHeader("hdrname", "text.pdf");

the header will only contain the string "text.pdf". If I remove the quotes around the filename the script crashes.

So how do I set a header parameter to an object within groovy?

Thanks a lot

Tom

message.Seth

0