Application Development and Automation 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: 
Read only

OTF to PDF Conversion, PDF document not correct

Former Member
0 Likes
3,353

Hi,

I am using the Function Module CONVERT_OTF_2_PDF to get the PDF content. I then send this PDF content out via an email. When I open the PDF document I can see that the output does not reflect what the printed output would. It appears that the output has been flipped over. So everything that appears on the left hand side of the printed output is now on the right, and everything that was on the right hand side of the printed output is now on the left when looking at the PDF.

Has anybody else come across this same issue?

Any help is much appreciated.

Thanks


Martin

Hi,

I am using the Function Module CONVERT_OTF_2_PDF to get the PDF content. I then send this PDF content out via an email. When I open the PDF document I can see that the output does not reflect what the printed output would. It appears that the output has been flipped over. So everything that appears on the left hand side of the printed output is now on the right, and everything that was on the right hand side of the printed output is now on the left when looking at the PDF.

Has anybody else come across this same issue?

Any help is much appreciated.

Thanks


Martin

14 REPLIES 14
Read only

rosenberg_eitan
Active Contributor
0 Likes
2,826

Hi,

If for mail try this:

FORM mail_1_prep_5
  CHANGING
    ob_document_bcs TYPE REF TO cl_document_bcs .

  DATA: customer    TYPE  scustom .
  DATA: bookings    TYPE  ty_bookings .
  DATA: connections TYPE  ty_connections   .

  DATA: formname TYPE tdsfname .
  DATA: fm_name  TYPE rs38l_fnam .

  formname = p_fname .

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = p_fname
    IMPORTING
      fm_name            = fm_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.

  IF sy-subrc NE 0 .
    RETURN .
  ENDIF .

  DATA: st_control_parameters TYPE ssfctrlop .
  DATA: st_output_options     TYPE ssfcompop .
  DATA: st_job_output_info    TYPE ssfcrescl .

  st_control_parameters-no_dialog = abap_true .
  st_control_parameters-getotf    = abap_true .

  CALL FUNCTION fm_name
    EXPORTING
      control_parameters = st_control_parameters
      output_options     = st_output_options
      customer           = customer
      bookings           = bookings
      connections        = connections
    IMPORTING
      job_output_info    = st_job_output_info
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.

  IF sy-subrc EQ 4 .
    RETURN .
  ENDIF .

  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  DATA: bin_file TYPE xstring .
  DATA: it_lines_dummy TYPE tline_tab .
  DATA: bin_filesize TYPE i .

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
    IMPORTING
      bin_file              = bin_file
      bin_filesize          = bin_filesize
    TABLES
      otf                   = st_job_output_info-otfdata
      lines                 = it_lines_dummy
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      err_bad_otf           = 4
      OTHERS                = 5.

  DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>xstring_to_solix
    EXPORTING
      iv_xstring = bin_file
    RECEIVING
      et_solix   = it_solix.

  DATA: attachment_subject TYPE so_obj_des .

  MESSAGE s000(oo) WITH 'attachment PDF hex' space INTO attachment_subject .

  TRY.
      CALL METHOD ob_document_bcs->add_attachment
        EXPORTING
          i_attachment_type    = 'pdf'
          i_attachment_subject = attachment_subject
          i_att_content_hex    = it_solix.
    CATCH cx_document_bcs .
  ENDTRY.

ENDFORM .                    "mail_1_prep_5

Regards.

Full program :

Read only

Former Member
0 Likes
2,826

Hi Martin,

Please check below threads i believe you will get the answer if not please let me know i can help.

Best Regards,

Dnyaneshwar Lande

SAP ABAP Consultant

Read only

Former Member
0 Likes
2,826

Hi

Is this a generic problem? I mean it occurs for every print you try to convert? or it's valid only for a particular print?

Because it seems a problem of the fm CONVERT_OTF_2_PDF, you should look for some notes, anyway you can try to call directly fm CONVERT_OTF instead of CONVERT_OTF_2_PDF

Max

Read only

0 Likes
2,826

Hi Max,

I get the same issue with CONVERT_OTF also. It does appear to happen for two different document (hence two different SAPScripts).


The first processing of the email output works ok. Subsequent repeats causes this issue. This baffles me even more as its the same code being ran.

Thanks

Martin

Read only

Private_Member_7726
Active Contributor
0 Likes
2,826

Hi,

In addition to what Max wrote, you must use CONVERT_OTF, because the description of CONVERT_OTF_2_PDF (in German) says that that FM is obsolete.

1) what form are you using: smartform, sapscript, something else..? (didn't see your last reply before replying)

2) please verify that OTF is correctly formatted (for example, by inserting call to FM SSFCOMP_PDF_PREVIEW right after you retrieve OTF table and processing form in dialog)

cheers

Janis

Message was edited by: Jānis B

Read only

0 Likes
2,826

Hi Janis,


Thanks for your message. I have changed the code to use CONVERT_OTF. I have also used SSFCOMP_PDF_PREVIEW. The output from this Function has also resulted in the output being flipped.


So, I presume the issue is with the OTF data.


What could cause the OTF data to be causing the output to be flipped though.


Thanks


Martin

Read only

0 Likes
2,826

Hi Martin,

How are you getting OTF data ??

Regards,

Dnyaneshwar Lande

SAP ABAP Consultnat

Read only

0 Likes
2,826

Odd, very odd indeed... I suspect something somewhere goes awry with the LTR/RTL language settings. We have to somehow isolate this further... Could you perhaps send the output of the correct form and the first flipped form to spool and download and attach the spool request contents? Or somehow export the OTF table from the debugger?

What are the logon language and the language attributes of the forms, btw? And what DEVICE (for OPEN_FORM - the default is PRINTER) and what device type (TDPRINTER in print options) is this stuff being formatted for?

cheers

Janis

Read only

0 Likes
2,826

Hi

Try to change the print, I mean to try to use a print having a different device output

And instead of to send a mail, try to download on your pc a pdf file

Max

Read only

0 Likes
2,826

Fixed it. It was all my fault. I was setting the field itcpp-TDRTL to 'X', which was outputting the text right to left.

Thanks to everyone for their help.

Read only

0 Likes
2,826

You're welcome; I didn't even know there was such stuff

Read only

0 Likes
2,826

Me too,

I dind't know that flag

Good

Max

Read only

0 Likes
2,826

I was Aware however didn't thought about that

Read only

Former Member
0 Likes
2,826

Hi,

Correct, As i have also used the same CONVERT_OTF and it will give you correct data output.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = v_len_in

TABLES

otf = i_otf

lines = i_tline

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Regards,

dnyaneshwar Lande

SAP ABAP Consultant