Hello community,
the Debenu company offers here the Quick PDF Library Lite. With this COM library you have the possibility to create PDF files from ABAP via OLE interface easily. This library is free and you can download it from here. It offers basic functionalities to create and manipulate PDF files.
To use this library I programmed a wrapper class, which is available in my GitHub repository here. With this class you can use all functions from the Debenu Quick PDF Library Lite 11.14 easily inside ABAP. Here an example:
"-Begin-----------------------------------------------------------------
Program zTest01.
"-Variables---------------------------------------------------------
Data PDF Type Ref To zDebenuPDFLibraryLite.
Data OutText Type String Value ''.
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.
PDF->Server = 0.
If PDF->LoadLib( ) = 1.
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 = '1.0' Green = '0.0' Blue = '0.0' ).
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-------------------------------------------------------------------
As you can see it is very simple to create basic PDF files on this way.
In the wrapper class is an attribute, called Server, to switch between front- and backend service. In our example above it is set to null PDF->Server = 0. If it is set it to one, the wrapper class use Background Light - which I introduced here. So it is possible to use Debenu Quick PDF Library also as server application, e.g. to use it in background processes.
Use Case
Often developers must code programs without the a real infrastructure. In our case a change request requires an interface to a PDF converter solution, which converts e-mail attachments from CRM Electronic Response Management System (ERMS) to PDF files, to archive them. With this way we have the possibility to simulate a PDF converter solution roughly, via Debenu Quick Library Lite. Good enough to build the interface basically and to get first experiences for this kind of development. And Background Light offers the additional perspective of the operation as a server environment. So the developers can test their programs much better.
Cheers
Stefan