Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
High Quality Printing withAPEX & PL/PDF                             Scott Spendolini                   Executive Director,...
WELCOME          2
About the Presenter Scott Spendolini  scott.spendolini@enkitec.com  @sspendol  Ex-Oracle Employee of 10 years    Seni...
About Enkitec Oracle Platinum Partner  Established in 2004  Headquartered in Dallas, TX  Locations throughout the US &...
Agenda Overview Installation APEX Integration Common APIs Extras Summary                     5
OVERVIEW           6
APEX & Printing APEX is over 10 years old  Initial code was started on 4-AUG-1999 As much as it has advanced over the y...
Poll What printing technology do you use in  conjunction with APEX?  “Printer Friendly” Mode  Apache FOP  Crystal Repo...
Options                                                Add’l      Name          Ease of Use        Power                  ...
What is PL/PDF? Third party product designed by Oranext  http://plpdf.com Provides a set of PL/SQL based APIs that can ...
PL/PDF Features Robust reporting engine Charts  Bar, Line & Pie Barcode Printing Use Existing PDF files as Templates...
Licensing Licensed per instance of Oracle  $600 per instance Can download a trial for free  5 Page Maximum  Watermark...
The BLOB! Result of PL/PDF is nothing more than an Oracle  BLOB Thus, you can do anything with PL/PDF output  that you c...
Simple Exampleplpdf.init;plpdf.NewPage;plpdf.SetPrintFont(Arial,NULL,12);plpdf.PrintCell(50,10,Hello World);plpdf.SendDoc(...
Complex Example eSERT Evaluation Summary Report                                    15
Layout & Control All layout is handled via API calls  There is no GUI tool to design a PL/PDF report Seems limiting, an...
Sweet Spots PL/PDF is the best solution when:  The core report definition does not change often  End Users do not need ...
INSTALLATION               18
Installation Options PL/PDF comes with a Windows-based installer  Can use to install on any target OS  Need to be able ...
Where to Put It Since PL/PDF is a set of PL/SQL objects, you’ll  need to select a schema to put it in  Typically use PLP...
APEX INTEGRATION                   21
APEX Integration Once installed and the corresponding grants are  created to your parse as schema, there is  NOTHING ADDI...
APEX Integration PL/PDF must be called as part of the Page  Rendering process in APEX  And it must occur before anything...
APEX INTEGRATIOND E M O N S T R A T I O N                            24
COMMON APIS              25
Common APIs PL/PDF is nothing more than a set of PL/SQL APIs  Like any other API set, there’s a learning curve Most API...
LAYOUT & CONTROL                   27
init Called once to initialize PL/PDF Parameters:  p_orientation  p_unit  p_format                                   ...
newPage Creates a new page Called anytime a new page is needed  PL/PDF will automatically create a new page when   need...
setPrintFont Sets the font family and style used for text Parameters:  p_family  p_style  p_size                     ...
printCell Prints a line of text on the page Parameters:   •   p_w                •   p_align   •   p_h                • ...
sendDoc Returns the PDF document to a BLOB variable Parameters:  p_blob                                                32
BASIC REPORTD E M O N S T R A T I O N                            33
lineBreak Places the cursor on the next line Parameters:  p_h                                       34
LINE BREAKD E M O N S T R A T I O N                            35
setCurrentXY Sets the position of the cursor Parameters:  p_x  p_y Similar:  setCurrentX  setCurrentY              ...
SET CURSOR POSITIOND E M O N S T R A T I O N                            37
setColor4Text Sets the font color used for text Parameters:  p_r  p_g  p_b Alternatively:  p_color                 ...
setColor4Filling Sets the background color used for text Parameters:  p_r  p_g  p_b Alternatively:  p_color        ...
API for the API In some cases, you may want to create your own  API to simplify the number of PL/PDF API calls  required...
set_font APIPROCEDURE set_font   (   p_family     IN   VARCHAR2   DEFAULT      Arial,   p_size       IN   NUMBER     DEFAU...
set_font APIplpdf.SetPrintFont(  p_family => p_family,  p_style => p_style,  p_size => p_size);plpdf.SetColor4Text(  p_r =...
Download File API You can also create a single procedure to handle  file downloads  Pass in the BLOB and filename  All ...
SET_FONT &DOWNLOAD_FILE       APID E M O N S T R A T I O N                            44
setHeaderProcName Sets which procedure to call to produce the page  header Parameters:  p_proc_name  p_height         ...
setFooterProcName Sets which procedure to call to produce the page  footer Parameters:  p_proc_name  p_height         ...
Note on Privileges The procedure named in the header and footer  calls must be able to be called by the schema in  which ...
PAGE HEADER & FOOTERD E M O N S T R A T I O N                            48
REPORTS          49
Printing a Report Whether you’re printing a report that is 1 or 100  pages, there are better, more specific APIs for  tha...
query_print Designed to enable developers to quickly take a  SQL statement and generate a PDF document  from it  Limited...
query_print Technically a one-off API not included in the  PL/PDF Distribution Can be downloaded from PL/PDF’s site  Fo...
query_print Parameters: procedure query_print_01(   p_query       varchar2,   p_height      number,   p_header_fill numbe...
QUERY_PRINTD E M O N S T R A T I O N                            54
row_print ROW_PRINT allows for a lot more flexibility than  QUERY_PRINT Typically called from inside a loop  FOR X IN (...
row_print Sample Parameters  p_data  p_width  p_align  p_style  p_maxline  p_links  p_h  p_fill  p_min_height  ...
ROW_PRINTD E M O N S T R A T I O N                            57
Table of Contents PL/PDF allows you to automatically crete a Table  of Contents  You can add “bookmarks” throughout your...
TABLE OF CONTENTSD E M O N S T R A T I O N                            59
EXTRAS         60
Extras In addition to its core APIs, PL/PDF offers a  number of extra features  Templates  Charts   Bar, Line & Pie  ...
Templates PL/PDF allows you to include a PDF template as a  background for any page  No need to use PL/PDF to create the...
Templates            63
TEMPLATESD E M O N S T R A T I O N                            64
Charts Support for three types of charts  Line  Bar  Pie                                      65
Charts  sumnevaSERT  Settings Summary                                                                    28 out of 37 poss...
Barcodes Support for a number of types of barcodes:Feline Adult 20/22LB       Feline Adult 20/22LB       Feline Adult 20/...
Other Features Ability to encrypt PDF files Support for OpenOffice PDF Forms LZW compression TrueType Font Support    ...
SUMMARY          69
Summary PL/PDF provides a robust, cost effective  solution for producing high quality PDF  documents from any APEX applic...
Download This and all other Enkitec presentations can be  downloaded for free from: http://enkitec.com/presentations     ...
http://www.enkitec.com                         72
Upcoming SlideShare
Loading in …5
×

High Quality Printing with APEX and PL/PDF

6,203 views

Published on

Since it's introduction, Oracle APEX has evolved from a basic toolkit for small applications to an enterprise-ready platform for applications of almost any size. However, one area has been at almost a standstill since its inception: printing.

This session will discuss how to integrate PL/PDF - a 3rd party PL/SQL-based printing solution - with Oracle APEX, so that you can provide your end users with beautiful PDF reports in almost no time. It will use real-world examples and discuss now only basic reports, but also charts, templates and bar codes.

Published in: Technology
  • Be the first to comment

High Quality Printing with APEX and PL/PDF

  1. 1. High Quality Printing withAPEX & PL/PDF Scott Spendolini Executive Director, Enkitec 1
  2. 2. WELCOME 2
  3. 3. About the Presenter Scott Spendolini  scott.spendolini@enkitec.com  @sspendol  Ex-Oracle Employee of 10 years  Senior Product Manager for Oracle APEX from 2002 through 2005  Founded Sumner Technologies in October 2005  Co-Founded Sumneva in January 2010  Joined Enkitec in June 2012  Oracle Ace Director  Co-Author, Pro Oracle Application Express  Author, Secure APEX Development Best Practices  “Scott” on OTN Forums 3
  4. 4. About Enkitec Oracle Platinum Partner  Established in 2004  Headquartered in Dallas, TX  Locations throughout the US & EMEA Specialties include  Exadata Implementations  Development Services  PL/SQL / Java / APEX  DBA/Data Warehouse/RAC  Business Intelligence 4
  5. 5. Agenda Overview Installation APEX Integration Common APIs Extras Summary 5
  6. 6. OVERVIEW 6
  7. 7. APEX & Printing APEX is over 10 years old  Initial code was started on 4-AUG-1999 As much as it has advanced over the years, there is still no de-facto,“go to” printing solution 7
  8. 8. Poll What printing technology do you use in conjunction with APEX?  “Printer Friendly” Mode  Apache FOP  Crystal Reports  Jasper Reports  Oracle BI Publisher  PL/PDF  File > Print  Other 8
  9. 9. Options Add’l Name Ease of Use Power Cost ServerPrinter Friendly ★★★★★ FreeModeApache FOP ★★★★★ ★★ ✔ FreeJasper Reports ★★★★ ★★★★ ✔ $$Crystal Reports ★★★★ ★★★★ ✔ $$$Oracle BI ★★★★ ★★★★★ ✔ $$$$$PublisherPL/PDF ★★★ ★★★★ $ 9
  10. 10. What is PL/PDF? Third party product designed by Oranext  http://plpdf.com Provides a set of PL/SQL based APIs that can generate PDF files from the Oracle database Easy to securely integrate with APEX Can be called from a Page or Application Process 10
  11. 11. PL/PDF Features Robust reporting engine Charts  Bar, Line & Pie Barcode Printing Use Existing PDF files as Templates TrueType Font Embedding Encrypted PDF Documents Native Support for PNG & JPEG images  Other types supported via Oracle InterMedia 11
  12. 12. Licensing Licensed per instance of Oracle  $600 per instance Can download a trial for free  5 Page Maximum  Watermark Appears on all pages No additional hardware is required  PL/PDF installs into the same database as APEX 12
  13. 13. The BLOB! Result of PL/PDF is nothing more than an Oracle BLOB Thus, you can do anything with PL/PDF output that you can with an Oracle BLOB:  E-Mail it as an attachment  Download it to a browser  Store it in a table  Index it with Oracle Text  Schedule a procedure to generate and e-mail PDF files 13
  14. 14. Simple Exampleplpdf.init;plpdf.NewPage;plpdf.SetPrintFont(Arial,NULL,12);plpdf.PrintCell(50,10,Hello World);plpdf.SendDoc(l_blob); 14
  15. 15. Complex Example eSERT Evaluation Summary Report 15
  16. 16. Layout & Control All layout is handled via API calls  There is no GUI tool to design a PL/PDF report Seems limiting, and can be at times  Template feature allows you to use any tool to create the structure of a document and use PL/PDF APIs only to populate the data  Also, there are APIs that minimize the amount of code required when creating reports 16
  17. 17. Sweet Spots PL/PDF is the best solution when:  The core report definition does not change often  End Users do not need to create one-off reports  You have an abundance of PL/SQL resources and little money 17
  18. 18. INSTALLATION 18
  19. 19. Installation Options PL/PDF comes with a Windows-based installer  Can use to install on any target OS  Need to be able to connect to the target database via SQL*Net Alternatively, you can run the scripts manually via command prompt In either case, installation should take about 5-10 minutes 19
  20. 20. Where to Put It Since PL/PDF is a set of PL/SQL objects, you’ll need to select a schema to put it in  Typically use PLPDF, but can name the schema anything Best to use its own schema and then create grants & synonyms to access from other schemas  You’ll need to do this manually  Start with just PLPDF & PLPDF_TYPE; synonyms for other objects can be added as needed 20
  21. 21. APEX INTEGRATION 21
  22. 22. APEX Integration Once installed and the corresponding grants are created to your parse as schema, there is NOTHING ADDITIONAL TO CONFIGURE in order to integrate PL/PDF with APEX PL/PDF - like APEX - is PL/SQL  Thus, as long as your parse-as schema can access the PL/PDF objects, that’s all you’ll need  Seriously.  There’s nothing else to configure.  Try it. You’ll see. 22
  23. 23. APEX Integration PL/PDF must be called as part of the Page Rendering process in APEX  And it must occur before anything else Best Practice:  Create an On Load PL/SQL Process that calls PL/PDF  Set the Condition to Request = Expression 1  Add a button/link to that page which sets the Request to trigger the PL/PDF call 23
  24. 24. APEX INTEGRATIOND E M O N S T R A T I O N 24
  25. 25. COMMON APIS 25
  26. 26. Common APIs PL/PDF is nothing more than a set of PL/SQL APIs  Like any other API set, there’s a learning curve Most APIs have default values on most parameters  Thus you only need to pass values to those you wish to set  Use param => value notation for best results Refer to the documentation for full details 26
  27. 27. LAYOUT & CONTROL 27
  28. 28. init Called once to initialize PL/PDF Parameters:  p_orientation  p_unit  p_format 28
  29. 29. newPage Creates a new page Called anytime a new page is needed  PL/PDF will automatically create a new page when needed if data overflows the current page Parameters:  p_orientation 29
  30. 30. setPrintFont Sets the font family and style used for text Parameters:  p_family  p_style  p_size 30
  31. 31. printCell Prints a line of text on the page Parameters: • p_w • p_align • p_h • p_fill • p_txt • p_link • p_border • p_clipping • p_ln 31
  32. 32. sendDoc Returns the PDF document to a BLOB variable Parameters:  p_blob 32
  33. 33. BASIC REPORTD E M O N S T R A T I O N 33
  34. 34. lineBreak Places the cursor on the next line Parameters:  p_h 34
  35. 35. LINE BREAKD E M O N S T R A T I O N 35
  36. 36. setCurrentXY Sets the position of the cursor Parameters:  p_x  p_y Similar:  setCurrentX  setCurrentY 36
  37. 37. SET CURSOR POSITIOND E M O N S T R A T I O N 37
  38. 38. setColor4Text Sets the font color used for text Parameters:  p_r  p_g  p_b Alternatively:  p_color 38
  39. 39. setColor4Filling Sets the background color used for text Parameters:  p_r  p_g  p_b Alternatively:  p_color 39
  40. 40. API for the API In some cases, you may want to create your own API to simplify the number of PL/PDF API calls required For example, a single API can consolidate the following three PL/PDF APIs:  setPrintFont  setColor4Text  setColor4Filling 40
  41. 41. set_font APIPROCEDURE set_font ( p_family IN VARCHAR2 DEFAULT Arial, p_size IN NUMBER DEFAULT 10, p_style IN VARCHAR2 DEFAULT NULL, p_r IN NUMBER DEFAULT 0, p_g IN NUMBER DEFAULT 0, p_b IN NUMBER DEFAULT 0, p_r_bkg IN NUMBER DEFAULT 255, p_g_bkg IN NUMBER DEFAULT 255, p_b_bkg IN NUMBER DEFAULT 255 )IS Called without parameters, the font will be set to Arial 10 normal (black on white)BEGIN 41
  42. 42. set_font APIplpdf.SetPrintFont( p_family => p_family, p_style => p_style, p_size => p_size);plpdf.SetColor4Text( p_r => p_r, p_g => p_g, p_b => p_b);plpdf.SetColor4Filling( p_r => p_r_bkg, p_g => p_g_bkg, p_b => p_b_bkg);END; 42
  43. 43. Download File API You can also create a single procedure to handle file downloads  Pass in the BLOB and filename  All PL/PDF reports can call this procedure In fact, it is recommended that PL/PDF reports be based on a package  Reusability  Security 43
  44. 44. SET_FONT &DOWNLOAD_FILE APID E M O N S T R A T I O N 44
  45. 45. setHeaderProcName Sets which procedure to call to produce the page header Parameters:  p_proc_name  p_height 45
  46. 46. setFooterProcName Sets which procedure to call to produce the page footer Parameters:  p_proc_name  p_height 46
  47. 47. Note on Privileges The procedure named in the header and footer calls must be able to be called by the schema in which PL/PDF is installed  Not a problem is PL/PDF is installed in the same schema as your PL/SQL You can not pass parameters to this procedure directly, but can do so via SYSCONTEXT 47
  48. 48. PAGE HEADER & FOOTERD E M O N S T R A T I O N 48
  49. 49. REPORTS 49
  50. 50. Printing a Report Whether you’re printing a report that is 1 or 100 pages, there are better, more specific APIs for that  QUERY_PRINT  Pass a SQL Statement, get a report  ROW_PRINT  Allows you to loop through a SQL statement or Dynamic SQL and have more control over the resulting report 50
  51. 51. query_print Designed to enable developers to quickly take a SQL statement and generate a PDF document from it  Limited formatting options and control  Eight different variations are available: QUERY_PRINT_01 through QUERY_PRINT_08 51
  52. 52. query_print Technically a one-off API not included in the PL/PDF Distribution Can be downloaded from PL/PDF’s site  For Developers > Examples > PLPDF-SDK > Complex Examples > Query Print 52
  53. 53. query_print Parameters: procedure query_print_01( p_query varchar2, p_height number, p_header_fill number default 0 ); procedure query_print_09( p_query varchar2, p_height number, p_cellwidth number, p_numbercells number, p_datecells number, p_maxcells number default 0, p_header_fill number default 0 ); 53
  54. 54. QUERY_PRINTD E M O N S T R A T I O N 54
  55. 55. row_print ROW_PRINT allows for a lot more flexibility than QUERY_PRINT Typically called from inside a loop  FOR X IN (SELECT * FROM ...)  DBMS_SQL Four different variations are available: ROW_PRINT through ROW_PRINT4 55
  56. 56. row_print Sample Parameters  p_data  p_width  p_align  p_style  p_maxline  p_links  p_h  p_fill  p_min_height  p_clipping 56
  57. 57. ROW_PRINTD E M O N S T R A T I O N 57
  58. 58. Table of Contents PL/PDF allows you to automatically crete a Table of Contents  You can add “bookmarks” throughout your application that link back to the main table of contents  Fully automated; no need to calculate anything 58
  59. 59. TABLE OF CONTENTSD E M O N S T R A T I O N 59
  60. 60. EXTRAS 60
  61. 61. Extras In addition to its core APIs, PL/PDF offers a number of extra features  Templates  Charts  Bar, Line & Pie  Bar Codes  Encryption  OpenOffice Forms  TrueType Font Support 61
  62. 62. Templates PL/PDF allows you to include a PDF template as a background for any page  No need to use PL/PDF to create the structure of a document; focus on filling in the data  Any PDF document can be used  Easy to create PDF documents from Word, Acrobat, etc. 62
  63. 63. Templates 63
  64. 64. TEMPLATESD E M O N S T R A T I O N 64
  65. 65. Charts Support for three types of charts  Line  Bar  Pie 65
  66. 66. Charts sumnevaSERT Settings Summary 28 out of 37 possible points 75.68% Session Duration 0% Authentication Scheme: 1 0 out of 2 possible points Security 60% 6 out of 10 possible points Application Settings 84.62% 11 out of 13 possible points Session Duration: 2 Security: 4 Authentication Scheme 91.67% 11 out of 12 possible points Application Settings: 2 Exceptions Awaiting Approval No Data Found Stale Exceptions No Data Found 66
  67. 67. Barcodes Support for a number of types of barcodes:Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB8543 8543 8543 8543 $36.99 $36.99 $36.99 $36.99101262640 101262640 101262640 101262640Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB8543 8543 8543 8543 $36.99 $36.99 $36.99 $36.99101262640 101262640 101262640 101262640Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB8543 8543 8543 8543 $36.99 $36.99 $36.99 $36.99101262640 101262640 101262640 101262640Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB Feline Adult 20/22LB8543 8543 8543 8543 $36.99 $36.99 $36.99 $36.99101262640 101262640 101262640 101262640 67
  68. 68. Other Features Ability to encrypt PDF files Support for OpenOffice PDF Forms LZW compression TrueType Font Support 68
  69. 69. SUMMARY 69
  70. 70. Summary PL/PDF provides a robust, cost effective solution for producing high quality PDF documents from any APEX application  Not always the right tool for every job; but in many cases, it works quite well  Low cost and zero footprint means that it should at least be seriously considered 70
  71. 71. Download This and all other Enkitec presentations can be downloaded for free from: http://enkitec.com/presentations 71
  72. 72. http://www.enkitec.com 72

×