2019 Jun 20 2:54 PM
Hi ,
I have a requirement to convert a HTML string ( which has html tags, texts and base 64 encoded images) into PDF file and attach it to an email using ABAP code.
I tried by
1. feeding the HTML string to a smartform and fetched the OTF data and converted into PDF. This didnt work as the smartform text doesnt recognize the HTML tags and the encoded image.
2. creating a spool and then converting to PDF. This failed, because the html is written as text into to spool and hence it also didn't workout.
As i am out of ideas. It would be a great help if someone could help me with some ideas.
Thanks in advance
Rian
Hi ,
I have a requirement to convert a HTML string ( which has html tags, texts and base 64 encoded images) into PDF file and attach it to an email using ABAP code.
I tried by
1. feeding the HTML string to a smartform and fetched the OTF data and converted into PDF. This didnt work as the smartform text doesnt recognize the HTML tags and the encoded image.
2. creating a spool and then converting to PDF. This failed, because the html is written as text into to spool and hence it also didn't workout.
As i am out of ideas. It would be a great help if someone could help me with some ideas.
Thanks in advance
Rian
2019 Jun 20 3:46 PM
Hi,
Try bellow link it may help you to find solution
https://sapintegrationhub.com/abap/base64/base64-encoding-and-decoding-in-sap-abap/
2019 Jun 20 3:55 PM
There are programs and web services that convert html to pdf. For example htm2pdf.co.uk has an API. I've no connection to this site; it's just the first that came up when I googled.
Buy a license for that, or any other similar, and call it from your ABAP with your html. Get the pdf file in return (as xstring) and attach to your email, using all the BCS stuff.
Or get one of the programs and install on your application server, and create a command that you can run from abap to do the conversion.
2019 Jun 20 6:56 PM
This has already been discussed over here and the question has been answered. Some of the possible solutions were discussed and one of them already suggested by Matthew above.
2019 Jun 21 1:44 PM
Hi Rameez,
Thanks for providing the reference link.
But as i mentioned i was trying to find a solution using just the Abap code without using any third party tools.
But thanks for sharing the link, it looks interesting.
2019 Jun 24 6:15 AM
Well, HTML is an open format and PDF is an open format, so there's nothing to stop you writing a converter.
2019 Jun 21 2:33 PM
Nawanandana Edirisinghe I see no relationship between base64 and the question, can you explain how it can help the OP?
2019 Jun 21 7:50 PM
Hey Sandra Rossi IF Rian getting BASE64 format , it can decode using SSFC_BASE64_DECODE and export to PDF , that will be possibility i thought.
2019 Jun 22 9:23 AM
Nawanandana Edirisinghe images inside the HTML are in base64 (I guess: <img src="data:<mimetype>;base64,<base64>">), but the question is much larger, so the solution is only to use an external tool which is able to convert any HTML code into PDF. No need to rewrite an existing conversion tool into ABAP language, just call this external tool, and it will be able to decode the base64 images and convert them into PDF embedded images.
2019 Jun 24 4:38 AM
you may try using cl_abap_browser to display html file with print button and print from there. copy the demo: DEMO_PICTURE_IN_HTML and try yourself...
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |