cancel
Showing results for 
Search instead for 
Did you mean: 

PDF printing in ABAP - How can I ensure the correct format (A4/A3)?

Janik
Explorer
0 Kudos
320

Hello experts,

I am facing a problem when printing PDFs in ABAP. The PDFs are available as originals for documents and can be opened via transaction CV02N, for example.
Printing works in principle, I do this using ADS_SR_OPEN, ADS_SR_CONFIRM etc.

Now to my problem: Some PDFs are in A4 format, others in A3 format. When printing, however, everything is automatically set to A4, which means that content is cut off for larger formats.

How can I ensure that the PDFs are always printed in the correct format (A4 or A3)?
To make matters worse, I don't know which format a PDF is in before printing.

Many thanks in advance for your help!
Janik

EDIT:
Here is my code: 

CALL FUNCTION 'ADS_SR_OPEN'
  EXPORTING
    dest    = i_printer
    doctype = 'ADSP'
  IMPORTING
    handle   = handle
    partname = partname.
  
CALL FUNCTION 'ADS_GET_PATH'
  IMPORTING
    ads_path = path.

CONCATENATE path '/' partname '.pdf' INTO file.

OPEN DATASET file FOR OUTPUT IN BINARY MODE.

TRANSFER i_pdf_xstring TO file.

CLOSE DATASET file.

DATA filesize TYPE i.
filesize = xstrlen( i_pdf_xstring ).
CALL FUNCTION 'ADS_SR_CONFIRM'
  EXPORTING
    handle   = handle
    partname = partname
    size     = filesize
    pages    = 1.

CALL FUNCTION 'ADS_SR_CLOSE'
  EXPORTING
    handle = handle.

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Janik
Explorer
0 Kudos

deleted

Sandra_Rossi
Active Contributor
Thanks for posting the code inside your question. You may virtually delete this non-solution post by editing it/indicating "deleted" for instance.