cancel
Showing results for 
Search instead for 
Did you mean: 

Script PDF output is printing distorted

bhardwaj_hg
Explorer
0 Kudos

Hi,

At the time of printing script output I have set Option paramter 'ITPO' to generate spool request.I sent this spool request PDF output to external mail by SP01. But when I download this PDF output form mail and print, priting quality gets distorted. Why this is happening? Please help how to overcome this issue.

Regards

Accepted Solutions (0)

Answers (3)

Answers (3)

Sandra_Rossi
Active Contributor
0 Kudos

Hi Arvind, any news? Thanks

Sandra_Rossi
Active Contributor
0 Kudos

> priting quality gets distorted.

Could you tell us more? (if it's about font issues, they are common, check SAP notes)

PS: Aabhas just forgot to tell you that his code is used to convert a sapscript form or smart form into PDF from your own ABAP program, it calls the same converter as the one when you send a spool by mail, so it won't solve your issue.

aabhas_wilmar
Contributor
0 Kudos

>At the time of printing script output

I thought he meant script...

I had a similar issue, and changing the max_linewidth solved my problem.

Arvind - Please provide more details.

Thanks,

Aabhas

Edited by: Aabhas K Vishnoi on May 20, 2010 6:47 PM

bhardwaj_hg
Explorer
0 Kudos

Hi,

Thanks for ur reply.

What I deed and what I want is explained below:

1. I have developed a script form and driver program which is used for invoice printing.

2. Our client wants to send this invoice on external mail. What i deed for this that I am using the spool request which is created during the print of output.

3. Then I am using transaction code SP01 to send spool PDF to external mail.

4. This script PDF output is sent successfully on external mail as an attachment. User saves this PDF attachement and print on their printer.

5. PROBLEM is when user open this attachment and prints this PDF, the printing gets distorted.

Note: I have also used another way by function module and program, but the result is same, PDF attachemnt printing gets distorted. It is not the same as get printing through ZTCODE printing of this script.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = SPOOLID

NO_DIALOG = ' '

  • DST_DEVICE =

  • PDF_DESTINATION =

  • IMPORTING

  • PDF_BYTECOUNT =

  • PDF_SPOOLID =

  • OTF_PAGECOUNT =

  • BTC_JOBNAME =

  • BTC_JOBCOUNT =

TABLES

PDF = PDF

LOOP AT PDF.

TRANSLATE PDF USING ' ~'.

CONCATENATE gd_buffer PDF INTO gd_buffer.

ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

DO.

it_mess_att = gd_buffer.

APPEND it_mess_att.

SHIFT gd_buffer LEFT BY 255 PLACES.

IF gd_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

PERFORM process_email.

FORM process_email.

DESCRIBE TABLE it_mess_att LINES gd_recsize.

CHECK gd_recsize > 0.

PERFORM send_email USING p_email1.

ENDFORM.

FORM send_email USING p_email.

CHECK NOT ( p_email IS INITIAL ).

REFRESH it_mess_bod.

  • Default subject matter

gd_subject = 'Subject'.

gd_attachment_desc = 'Attachname'.

  • CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.

it_mess_bod = 'PDF Attachment'.

APPEND it_mess_bod.

  • it_mess_bod = 'Message Body text, line 2...'.

  • APPEND it_mess_bod.

  • If no sender specified - default blank

IF p_sender EQ space.

gd_sender_type = space.

ELSE.

gd_sender_type = 'INT'.

ENDIF.

  • Send file by email as .xls speadsheet

PERFORM send_file_as_email_attachment

tables it_mess_bod

it_mess_att

using p_email

'Example .xls documnet attachment'

'PDF'

gd_attachment_name

gd_attachment_desc

p_sender

gd_sender_type

changing gd_error

gd_reciever.

ENDFORM.

FORM send_file_as_email_attachment tables it_message

it_attach

using p_email

p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type

changing p_error

p_reciever.

DATA: ld_error TYPE sy-subrc,

ld_reciever TYPE sy-subrc,

ld_mtitle LIKE sodocchgi1-obj_descr,

ld_email LIKE somlreci1-receiver,

ld_format TYPE so_obj_tp ,

ld_attdescription TYPE so_obj_nam ,

ld_attfilename TYPE so_obj_des ,

ld_sender_address LIKE soextreci1-receiver,

ld_sender_address_type LIKE soextreci1-adr_typ,

ld_receiver LIKE sy-subrc.

data: t_packing_list like sopcklsti1 occurs 0 with header line,

t_contents like solisti1 occurs 0 with header line,

t_receivers like somlreci1 occurs 0 with header line,

t_attachment like solisti1 occurs 0 with header line,

t_object_header like solisti1 occurs 0 with header line,

w_cnt type i,

w_sent_all(1) type c,

w_doc_data like sodocchgi1.

ld_email = p_email.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

  • Fill the document data.

w_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle .

w_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

CLEAR w_doc_data.

READ TABLE it_attach INDEX w_cnt.

w_doc_data-doc_size =

( w_cnt - 1 ) * 255 + STRLEN( it_attach ).

w_doc_data-obj_langu = sy-langu.

w_doc_data-obj_name = 'SAPRPT'.

w_doc_data-obj_descr = ld_mtitle.

w_doc_data-sensitivty = 'F'.

CLEAR t_attachment.

REFRESH t_attachment.

t_attachment[] = it_attach[].

  • Describe the body of the message

CLEAR t_packing_list.

REFRESH t_packing_list.

t_packing_list-transf_bin = space.

t_packing_list-head_start = 1.

t_packing_list-head_num = 0.

t_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

  • Create attachment notification

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.

t_packing_list-doc_type = ld_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = ld_attfilename.

t_packing_list-doc_size = t_packing_list-body_num * 255.

APPEND t_packing_list.

  • Add the recipients email address

CLEAR t_receivers.

REFRESH t_receivers.

t_receivers-receiver = ld_email.

t_receivers-rec_type = 'U'.

t_receivers-com_type = 'INT'.

t_receivers-notif_del = 'X'.

t_receivers-notif_ndel = 'X'.

APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

IMPORTING

sent_to_all = w_sent_all

TABLES

packing_list = t_packing_list

contents_bin = t_attachment

contents_txt = it_message

receivers = t_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

  • Populate zerror return code

ld_error = sy-subrc.

  • Populate zreceiver return code

LOOP AT t_receivers.

ld_receiver = t_receivers-retrn_code.

ENDLOOP.

ENDFORM.

*----


Regards

Dinesh Singh

aabhas_wilmar
Contributor
0 Kudos

Hi Arvind / Dinesh,

If you only explore a bit, my previous post should solve your problem. Use 132 instead of 255. I am away from system to help you in great detail but this should be enough.

cheers,

Aabhas

Sandra_Rossi
Active Contributor
0 Kudos

It's very surprising that even with standard, the PDF doesn't display correctly.

Did you check SAP notes?

Do you use Adobe Reader?

Are you sure SCOT is configured to convert SAPscript/Smart form into PDF? (if it converts to another format, and you try to open it with PDF reader, it won't work of course)

> 5. PROBLEM is when user open this attachment and prints this PDF, the printing gets distorted.

Again, what distorted mean exactly? Do you mean Adobe Reader sends an error message which says the PDF is corrupted, and the PDF isn't displayed at all?

Last thing, I don't advise you to send mail with SO_DOCUMENT_SEND_API1, people always have problems with it, it's why SAP told that this function module is obsolete. Use CL_BCS class instead. See good mail examples in SDN wiki: http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage

aabhas_wilmar
Contributor
0 Kudos

Hi Sandra,

I had a similar issue, I understand by disorted he mean that the images are of very low resoulution, not clear enough to understand. The text should be fine. It is because the Adobe reader can handle 132 character format PDF and the default value FM uses is 255.

I don't have enough details as it was long back.

cheers,

Aabhas

Sandra_Rossi
Active Contributor
0 Kudos

I think the main point is about that even with the standard, the PDF doesn't display correctly (as Dinesh says, he sends the spool using SP01 transaction)

aabhas_wilmar
Contributor
0 Kudos

The following code should solve your problem

CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
      max_linewidth         = 132
    IMPORTING
      bin_filesize          = lv_length
    TABLES
      otf                   = ts_otfdata
      lines                 = ts_pdf
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.

***- Change size of table to be compatible when sent as email
  CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    TABLES
      content_in                  = ts_pdf
      content_out                 = ts_pdfdata
    EXCEPTIONS
      err_line_width_src_too_long = 1
      err_line_width_dst_too_long = 2
      err_conv_failed             = 3
      OTHERS                      = 4.

cheers,

Aabhas

bhardwaj_hg
Explorer
0 Kudos

Hi Abhas,

Thanks for ur reply.

Can u send me the complete code of how to use these two function module.

Regards