Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

Create PDF Files Easily

I presented here a wrapper class for the Quick PDF Library Lite from Debenu. You can download here a wrapper class for the actual Quick PDF Library with wrapper methods for all functionalities of the library. You can download an evaluation version of the library here – it is without any restrictions, but for 30 days. So it is absolut easy to create any kind of PDF document.

Here an example:

"-Begin-----------------------------------------------------------------
  Program zTest.

    "-Variables---------------------------------------------------------
      Data PDF Type Ref To zDebenuPDFLibraryAX1115.
      Data LibraryVersion Type String.
      Data LicenseInfo Type String.
      Data OutText Type String.
      Data rc Type Integer.

    "-Main--------------------------------------------------------------
      OutText = 'Hello World from ABAP'.
      OutText = OutText && cl_abap_char_utilities=>cr_lf.
      OutText = OutText && 'Hello World from ABAP again'.

      Create Object PDF.
      If PDF->LoadLib( ) = 1.

        PDF->LibraryVersionEx( Importing Result = LibraryVersion ).
        Write: / `Library version: `, LibraryVersion.

        PDF->LicenseInfo( Importing Result = LicenseInfo ).
        Write: / `Valid license key: `, LicenseInfo.

        PDF->SetMeasurementUnits(
          Exporting MeasurementUnits = 1 ).                 "Millimetres
        PDF->SetPageSize( Exporting PaperName = 'A4' ).
        PDF->SetOrigin( Exporting Origin = 1 ).                "Top Left

        PDF->AddStandardFont( Exporting StandardFontID = 0 ).   "Courier
        PDF->SetTextSize( Exporting TextSize = 15 ).
        PDF->SetTextColor( Exporting Red = '0.9' Green = '0.2' Blue = '0.5' ).

        PDF->DrawTextBox(
          Exporting Left = 50 Top = 50 Width = 100 Height = 25
            Text = OutText Options = 1 ).        "Vertical alignment top

        PDF->SetInformation( Exporting Key = 1               "Set author
            NewValue = 'Stefan Schnell' ).
        PDF->SetInformation( Exporting Key = 2                "Set title
            NewValue = 'ABAP Test' ).

        PDF->SaveToFile(
          Exporting FileName = 'C:\Dummy\Test.pdf'
          Importing  Result = rc ).
        If rc = 0.
          Message 'The PDF file could not be created' Type 'I'.
        EndIf.

        PDF->FreeLib( ).
      EndIf.

"-End-------------------------------------------------------------------


Hint:
The example is the same as for PDF Quick Library Lite, with a few additions. The reason is that PDF Quick Library Lite is a subset of PDF Quick Library, with the exception that you must specify a license key.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sathees Kannan
      Sathees Kannan

      Hi Stefan,

       

      Nice Document, If i want to do the same with Adobe Acrobat Library is it possible?