More info
PL/PDF program package could be used to generate the following:
- Printouts (bills, delivery notes, etc.) from ERP systems
- Dynamic, customized product catalogues
- Financial reports
- Reports for applications developed in HTML DB
With PL/PDF you can easily produce:
- Page formats: unit of measures, headers, footers, margins, page numbers
- Automatic page breaks
- Use of rows and columns
- Shapes: lines, circles, ovals, rectangles
- JPEG pictures from the database
- Fonts: type, size, colour, style, TrueType
- Use of colours
- Compression of pages
Other advantages of PL/PDF:
- No third-party software or any extra installation is needed, only uses tools installed by an Oracle database
- Directly accesses data from the database, it does not need ODBC/JDBC connectors
- Centralized document creation, can be scheduled
- Pictures stored in an Oracle database can be inserted into any PDF document
Here is a basic example (the infamous "Hello World!") using PL/PDF.
1. Create the PL/SQL package:
CREATE OR REPLACE package test is
procedure pdf;
end;
/
CREATE OR REPLACE package body test is
procedure pdf is
l_blob blob;
begin
plpdf.init; -- initialize
plpdf.NewPage; -- new page
plpdf.SetPrintFont('Arial',null,10); -- set font
plpdf.PrintCell(10,40,'Hello World!'); -- Print a text
plpdf.SendDoc(l_blob); -- save the generated document
-- print
owa_util.mime_header('application/pdf',false);
htp.p('Content-Length: ' || dbms_lob.getlength(l_blob));
owa_util.http_header_close;
wpg_docload.download_file(l_blob);
end;
end;
/
2. After creating the PL/SQL package, the document can be reached through a browser (if MOD_PL/SQL is installed and the Oracle HTTP server is running) at the URL: http://server:port/pls/DAD/test.pdf, where DAD is the Database Access Descriptor. The result is: test.pdf
Our services include:
- Delivery of the basic PL/PDF package to companies that have resources to develop their own PL/PDF based system
- Development of PL/PDF based solutions and products
- Design and development of PL/PDF based customized solutions and products
The data source for data prepared in a dynamically created PDF document is usually a database, often an Oracle RDBMS. On the other hand, it is a general requirement to store the conditions under which the dynamic generation took place as well as the generated document. It is practical to store these data in a database as well, for easy access in the future. If both the source and target of the generated document is in the database then it is best to actually generate the document in the database also. If the database we are talking about is an Oracle database, then the best tool to use for the dynamic generation is the PL/SQL language because:
- It is integrated with the Oracle database; therefore it is the safest, quickest and most efficient way of interacting with the database
- It is a well-known language for anyone who works in an Oracle environment; therefore there is no need for developers to learn a new programming language
- There is no need for a separate server (physical or virtual i.e. separate software); therefore the cost of hardware and operation is reduced. Also, because of the simplicity of the infrastructure, the risks are reduced.
When creating the PL/PDF package, it was a basic goal to allow Oracle developers to develop without in depth knowledge of the structure of the PDF document. In a PDF document, elements are not automatically placed on the page as in an HTML document (e.g. in case of a table), so for each element the actual place where it is required to appear must be specified. To facilitate development, the following two concepts were introduced:
- Actual position: the actual X and Y coordinate on a page, where the object will be placed
- Cell: a rectangular area on the page, where text can be placed. The cell will have an actual coordinate, but the text will be placed automatically according to where the cell is. Using this method, the PDF document is a series of cells.
Here is a simple example:
...
-- header
plpdf.SetPrintFont('Arial','B',12);
plpdf.SetColor4Filling(200,220,255);
plpdf.PrintCell(20,10,'ROWNUM','1',0,'C',1);
plpdf.PrintCell(40,10,'OWNER','1',0,'C',1);
plpdf.PrintCell(100,10,'OBJECT NAME','1',1,'C',1);
-- the data
plpdf.SetPrintFont('Arial',null,12);
for f_obj in (select rownum, owner, object_name from all_objects where rownum < 100) loop
plpdf.PrintCell(20,10,to_char(f_obj.rownum),'1',0);
plpdf.PrintCell(40,10,f_obj.owner,'1',0);
plpdf.PrintCell(100,10,f_obj.object_name,'1',1);
end loop;
...
PL/PDF also provides tools that give further help in formatting the document, such as automatic page breaks. If necessary, the developer can directly specify where a certain text should be placed to achieve a required format.
Of course apart from text, a number of other objects can also be placed in a PDF document:
- Line (thickness and color can be specified)
- Ellipse, circle (line, color and fill can be specified)
- Rectangle (line, color and fill can be specified)
- JPEG picture (size can be specified)
Using PL/PDF not only the cost of hardware and operation, but also development timeframe and consequently the cost of implementation is reduced.