Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sending smartform output as PDF attachment, Error opening PDF attachment

Hi Experts,

I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&

The information should be on my smartform are some text, company logo and a barcode.

With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."

I tried different ways like only text, text with company logo, text with barcode. I got the following errors:

An unrecognized token 'Td0' was found

There was problem reading this document(16).

There was problem reading this document(111).

Does anyone have idea of these ? Your help is greatly appreciated.

Thank you,

Surya

Former Member
Former Member replied

Hi Surya,

After calling FM Convert_OTF use FM SCMS_XSTRING_TO_BINARY ,you will got the binary file to send . Look at the code below ( it works fine ) .

Let me know.

<i>

data : file_to_send TYPE xstring ,

pdf_document TYPE solix_tab .

*Convert Smartforms into PDF

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = file_size

bin_file = file_to_send

TABLES

otf = tab_otf

lines = i_tline

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

  • add attachment to document

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = file_to_send

TABLES

binary_tab = pdf_document.

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = 'PDF'

i_attachment_subject = att_subject

i_att_content_hex = pdf_document.

</i>

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question