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

Problems converting to PDF?

Former Member
0 Likes
450

I am converting the report documentation into PDF. It all works fine but the print format from PDF is very very small. I am not using SMARTFORMS but rather calling FM to get the report documentation and then converting into PDF. I am attaching the code below, please run the code and you will understand what i mean when you try to print from the converted PDF file. Please give me some suggestion, solution, or sample code. It will be appreciated.

Thanks

Nahman

*Start of code

ATA: header LIKE thead,

options LIKE itcpo.

DATA: lines LIKE tline OCCURS 0 WITH HEADER LINE,

otfdata LIKE itcoo OCCURS 0 WITH HEADER LINE,

pdflines LIKE tline OCCURS 0 WITH HEADER LINE,

doc_itab LIKE docs OCCURS 0 WITH HEADER LINE,

binfilesize TYPE i,

filenm TYPE string.

PARAMETERS: program LIKE trdir-name OBLIGATORY,

filenam LIKE rlgrap-filename DEFAULT 'c:\temp\pdftest.pdf'.

START-OF-SELECTION.

CALL FUNCTION 'DOC_OBJECT_GET'

EXPORTING

class = 'RE'

name = program

language = sy-langu

IMPORTING

header = header

TABLES

itf_lines = lines

EXCEPTIONS

object_not_found = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

options-tdgetotf = 'X'.

options-tdprogram = 'SAPLSHL2'.

options-tddest = 'LP01'.

CALL FUNCTION 'PRINT_TEXT'

EXPORTING

application = 'TD'

device = 'PRINTER'

dialog = ' '

header = header

OPTIONS = options

TABLES

lines = lines

otfdata = otfdata

.

IF sy-subrc <> 0.

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

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

ENDIF.

REFRESH lines.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = binfilesize

TABLES

otf = otfdata

lines = pdflines

.

IF sy-subrc <> 0.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = binfilesize

filename = filenm

filetype = 'BIN'

TABLES

data_tab = pdflines[]

.

IF sy-subrc <> 0.

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

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

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
406

Hi,

Check the sample code,

http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm

Regards,

Azaz.

Read only

sridhar_k1
Active Contributor
0 Likes
406

That's because, PRINT_TEXT fm not inserting any page breaks, and PDF converter is not separating the spool in to different pages. Work around is, in the adobe reader print window, select None in Page scalling field.

Regards

Sridhar