Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert TIFF format to PDF format in ABAP

Former Member
0 Kudos

Hi,

We have a TIFF file on a Documentum Server. We are getting the XString format of this TIFF image through a web service. This XString o/p needs to be passed to Portal. But Portal - WebDynpro JAVA for Mobile devices is not able to display TIFF images as of now. However it is able to display PDF images.

Our requirement is to convert the XString format of the TIFF image to an XString format of a PDF. How can this be achieved? What FMs have to be used?

Any pointers are highly appreciated.

regards

Deepthi

18 REPLIES 18

satyajit_mohapatra
Active Contributor
0 Kudos

Please check this link.....

It has code snippet for converting tiff to JPEG format. I hope the java webdynpro will support JPEG format....

0 Kudos

None of the image formats(jpeg, tiff, bmp, gif etc.) are opening using WD Java for Mobile devices. Only PDFs are opening .

satyajit_mohapatra
Active Contributor
0 Kudos

Are you sending it as an attachment in the Blackberry? Then may be it's not possible to view it directly and another jpeg viewer software is required to be installed on Blackberry.

But, I think it should work if the image is embedded in a webpage and the url is accessed through the Blackberry. Could you tell me about the documentum server where the TIFF files are stored? Is it BDS or GOS?

0 Kudos

Nope, it is not sent as an attachment. The requirement is to view the image on the click of a button in a custom application on the Blackberry. Image viewer softwares are already available on the Blackberry.

The TIFF files are stored in the Documentum server and accessed in SAP through Archive Link - RFC archive. The images do not have any HTTP address configured.

Regards

Deepthi

0 Kudos

Another possible way can be....

1. Load the tiff file to a standard text through RSTXLDMC

2. Convert it to OTF using FM PRINT_TEXT

3. Convert the OTF to PDF using CONVERT_OTF

Your TIFF XSTRING needs to be converted to binary initially using FM SCMS_XSTRING_TO_BINARY to upload and the final PDF content can be used in webdynpro.

0 Kudos

I was trying this method......

1. Created a standard text in SO10 with the following parameters

YSM_TIF

ST

EN

2. Goto program RSTXLDMC and upload the TIFF file to this text.Enter the type as BCOL and entering standard text name as YSM_TIF.

3. Now, run this code.



DATA: int_lines  TYPE TABLE OF tline,
        int_otf    TYPE TABLE OF itcoo,
        int_pdf    TYPE TABLE OF tline,
       wa_thead   TYPE thead,
       wa_options TYPE itcpo.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    id                      = 'ST'
    language                = 'E'
    name                    = 'YSM_TIF'
    object                  = 'TEXT'
  IMPORTING
    header                  = wa_thead
  TABLES
    lines                   = int_lines.
  
IF sy-subrc EQ 0.

  wa_options-tdgetotf = 'X'.

  CALL FUNCTION 'PRINT_TEXT'
    EXPORTING
      dialog                   = ' '
      header                   = wa_thead
      OPTIONS                  = wa_options
    TABLES
      lines                    = int_lines
      otfdata                  = int_otf.
    
  IF sy-subrc EQ 0.

    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
      TABLES
        otf                   = int_otf
        lines                 = int_pdf.
      
    IF sy-subrc EQ 0.

      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:\Documents and Settings\satyajit.mohapatra\Desktop\tiff.pdf'
          filetype                = 'BIN'
        TABLES
          data_tab                = int_pdf.
      
    ENDIF.
  ENDIF.
ENDIF.

In your scenario, may be you need to create a custom program copying of RSTXLDMC, so that the Tiff content can be directly uploaded from program without the filepath. This custom program can be used with SUBMIT PROGRAM statement and rest of the logic will remain same.

0 Kudos

Check this link with a similar requirement....

0 Kudos

In the URL given, a BMP image is considered for upload. But I have a TIFF image to be used. So the code suggested is not working.

0 Kudos

I tried uploading the TIFF file using RSTXLDMC, but I get the error: TIFF format error: No baseline TIFF 6.0 file

0 Kudos

1. The link given is for BMP, but the same approach is being followed. The only difference is we need to upload the TIFF file through RSTXLDMC, whereas the BMP file can be directly uploaded to SE78. Have you tried the code given in my earlier post after uploading the Tiff file through RSTXLDMC?

2.

I tried uploading the TIFF file using RSTXLDMC, but I get the error: TIFF format error: No baseline TIFF 6.0 file

It's a problem with Tiff file format. Check this link for details....

If the file format can't be fixed try to convert it to BMP and you can follow the same process in the link as given in my earlier post for BMP..

Edited by: Satyajit on Jun 3, 2010 6:32 PM

0 Kudos

As mentioned before, I would not have direct access to the TIFF files. I can get only the XString or Binary format of these images to be used for conversion to PDF.

So I cannot modify the TIFF format to BMP.

0 Kudos

Yes, the binary content only needs to be converted to desired format. I think it's possible using cl_igs_image_converter class as given in my first post in this thread....

The current format and converted format must be maintained in MIME types in SMW0.

I've not tried it myself. Need to check.

Clemenss
Active Contributor
0 Kudos

Hi Deepthi,

no complete solution including source code, but a way that you may go:

Having the graphics stored in BDS business document services, it should be possible to integrate into a (dummy) smartform. Smartforms are integrated much better with PDF. If you do not get the smartforms output as PDF directly, you can create OTF printer output and convert it to PDF (I.e. CALL FUNCTION 'CONVERT_OTF'..EXPORTING FORMAT = 'PDF').

This way you can download a graphic as pdf.

Regards,

Clemens

satyajit_mohapatra
Active Contributor
0 Kudos

I was looking into it and got some solutions. No need to convert the TIFF to BMP. Check this code it will upload the TIFF file directly to SE78 and from SE78 we can create the PDF.



DATA:  wf_res         TYPE stxbitmaps-resolution,
       int_command    TYPE TABLE OF tline,
       wa_command     TYPE tline,
       wa_thead       TYPE thead,
       wa_options     TYPE itcpo,
       int_otf        TYPE TABLE OF itcoo,
       int_pdf        TYPE TABLE OF tline.

* Upload TIFF file to SE78
 perform graphic_import_bds
          IN PROGRAM saplstxbitmaps
                            using    'C:\Documents and Settings\satyajit.mohapatra\Desktop\sample.TIF'
                                     'YSM_TEST'
                                     'GRAPHICS'
                                     'BMAP'
                                     'BCOL'
                                     'TEST'
                                     space
                                     'X'
                                     space
                            changing wf_res.

* Get OTF
CALL FUNCTION 'SAPSCRIPT_GENERATE_BMP_COMMAND'
  EXPORTING
    bm_name    = 'YSM_TEST'
    bm_object  = 'GRAPHICS'
    bm_id      = 'BMAP'
    bm_type    = 'BCOL'
  IMPORTING
    bm_command = wa_command.

APPEND wa_command TO int_command.
wa_options-tdgetotf = 'X'.

CALL FUNCTION 'PRINT_TEXT'
  EXPORTING
    dialog  = ' '
    header  = wa_thead
    OPTIONS = wa_options
  TABLES
    lines   = int_command
    otfdata = int_otf.

* Get PDF
CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format = 'PDF'
  TABLES
    otf    = int_otf
    lines  = int_pdf.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:\Documents and Settings\satyajit.mohapatra\Desktop\New Folder\photo.pdf'
    filetype = 'BIN'
  TABLES
    data_tab = int_pdf.

CALL FUNCTION 'SAPSCRIPT_DELETE_GRAPHIC_BDS'
  EXPORTING
    i_name  = 'YSM_TEST'
    i_id    = 'BMAP'
    i_btype = 'BCOL'
    dialog  = ' '.


0 Kudos

Now, there are two issues.......

1. You have the TIFF content in binary and no specific filepath is available in presentation server.....

Goto subroutine 'graphic_import_bds' in program 'saplstxbitmaps'->goto subroutine 'import_bitmap_bds' in line 169->On line 387 in subroutine 'import_bitmap_bds', you will find call to FM GUI_UPLOAD to upload the content in binary format. You have to create a custom subroutine replacing the FM GUI_UPLOAD with rest of the logic intact and using the binary data table directly.

2. TIFF file format problem.......

The TIFF file format should be TIFF 6.0. Need to see how to handle older verions.

Please give it a try and let me know in case of any issues....

Former Member
0 Kudos

Till now, I know how to convert tiff to pdf. but how the reverse is possible, i mean convert pdf to tiff?

Is there any way to get the size of Pdf for conversion? any sample code?

please help?

0 Kudos

Hi,

How did you achieve this? I have similar requirement. Converting Multi page tiff image to PDF format.

0 Kudos

Hi,

Did you manage to find a solution?

Kind Regards

Deon