Standard service - a fixed amount of work that is performed at a fixed price.  Post Service

  

Thursday, 06 June 2019 19:40

Interactive Adobe. Part 19. How to Merge an Image File with an Adobe PDF?

Written by  https://sapyard.com/interactive-adobe-part-19-how-to-merge-an-image-file-with-an-adobe-pdf/
Rate this item
(0 votes)

It is a very common business case where we need to add an image (jpg/bmp etc.) in an adobe form. We can use Image Field UI and bind

the required image. But today’s topic is different.

How can we merge an image to an existing Adobe PDF form??

But how we can merge an image in existing forms in Adobe? Recently, one of our telegram group members asked solution for this case and solution possibilities.His requirement was to attach the images saved in PO Generic Object Services (GOS) and display along with PO Output Form. If there are 2 image files (mostly in “.jpg”) saved at Purchase Order, these should be merged with PO Output form and send it back to vendor. In short, the requirement was to merge the image files in GOS of PO along with the PDF PO Output Form.

After some head scratching and cool thinking, the below two steps looked a good start:

  1. Convert a JPG file into PDF Raw Data.
  2. Merge the Image PDF Raw Data with existing Adobe form.

Also Read: How to Hide a Table Column Dynamically Using JavaScript?

Let us dig into the actual technicalities now.

1. Create an Adobe form ZPB_TEST_CONVERT_JPG, Interface ZPB_TEST_CONVERT_JPG with an import parameter as GV_CONTENT of type XSTRING.

2. In context of form, create a Graphics Node as follow:

3. Set the graphics node properties as follow:

4. Create an Image field UI in form layout and bind it with GRAPHICS node created in the context.

We are done with creation of 1st Adobe form in which any image from driver program can be uploaded as PDF and then it needs to be merged with any existing Adobe form.

Also Read:How to Execute URL Dynamically by Button Click Event in Adobe Form?

Next, I have created another Adobe form ZPB_HIDE_TABLE_COLUMN with simple table display. Just create one adobe and hard code some table values. This will act like our 2nd PDF file which we want to merge.

5. Create a driver program with the below steps:

i. Call FP_JOB_OPEN

ii. Generate FM for 1st Adobe form:

iii. Upload an image file from local system.

iv. Convert Binary data into Raw data :

v. Call FM for 1st Adobe Form from step 1 and collect it’s Raw data into an internal table GT_PDF:

vi. Call 2nd Adobe form in which we want to merge the image as PDF and collect it’s Raw data in the internal table GT_PDF:

vii. Now, merge both the PDFs (1st Image, 2nd Adobe Form PDF) into one PDF.

LO_CL_MERGE is an object of class cl_rspo_pdf_merge. For more details about this class and other functionalities, please refer the below link:

viii. Close the form processing as:

ix. Now, you can generate the result merged PDF (GV_MERGE) from above step vii with the following code:

Testing Time:

Execute the driver program. Select an image file from your local system (I preferred to choose SAPYARD image) and save the merged PDF in your local drive:

Hope you could take home the solution. As usual, there might be other better ways to do the same thing, but this is the first and the simplest solution I can think of.

If you have some other thoughts, please feel free to write in the comments section below.

In this development, we did not do anything new. We just implemented what we have learnt and performed independently in other business requirements. We knew how to convert the data to RAW. We knew how to create Adobe Forms. We new how to get RAW data of the Adobe Forms. We knew how to merge PDF files. What we did was just bringing together all this answers to one. When we combined all the stand alone tricks it became one solution and this makes you the technical architect of your team. ?

If you think our page is helpful, do not forget to share our links with your friends, colleagues and team members. Do like our facebook page and follow us at twitter and instagram.

Please SUBSCRIBE to ourYoutube channel for free end to end video courses.

We have a very active Telegram (App) SAP Technical Group with more than 4990+ SAP Technical Practitioners from 6 Continents of the SAP World. Please join it using below link.
Telegram SAP Technical Discuss Group. You need to install the Telegram App first on your mobile device. Once you have it on your mobile, you can join the group and also access it from the Web on your computer and laptop.

Free Step by Step Course on Interactive Adobe Forms

Read 38 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.