Generating a PDF-document with some plsql: as_pdf_mini => as_pdf3 tables

Generating a PDF-document with some plsql: as_pdf_mini => as_pdf3

It has been more than a year since I published my previous blog on generating PDF with pl/sql.
In that time I’ve rewritten as_pdf two times, so now its time for as_pdf3

The most important improvement is Truetype Fonts

declare
x pls_integer;
begin
as_pdf3.init;
as_pdf3.write( 'But others fonts and encodings are possible using TrueType fontfiles.' );
x := as_pdf3.load_ttf_font( 'MY_FONTS', 'refsan.ttf', 'CID', p_compress => false );
as_pdf3.set_font( x, 12 );
as_pdf3.write( 'The Windows MSReference SansSerif font contains a lot of encodings, for instance', -1, 700 );
as_pdf3.set_font( x, 15 );
as_pdf3.write( 'Albanian: Kush mund të lexoni këtë diçka si kjo', -1, -1 );
as_pdf3.write( 'Croatic: Tko može čitati to nešto poput ovoga', -1, -1 );
as_pdf3.write( 'Russian: Кто может прочитать это что-то вроде этого', -1, -1);
as_pdf3.write( 'Greek: Ποιος μπορεί να διαβάσει αυτό το κάτι σαν αυτό', -1, -1 );
--
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.write( 'Or by using a TrueType collection file (ttc).', -1, 600 );
as_pdf3.load_ttc_fonts( 'MY_FONTS', 'cambria.ttc', p_embed => true, p_compress => false );
as_pdf3.set_font( 'cambria', 15 ); -- font family
as_pdf3.write( 'Anton, testing 1,2,3 with Cambria', -1, -1 );
as_pdf3.set_font( 'CambriaMath', 15 ); -- fontname
as_pdf3.write( 'Anton, testing 1,2,3 with CambriaMath', -1, -1 );
--
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.write( 'Or if you need to generate a PDF report in Chinese:', -1, 520 );
as_pdf3.set_font( as_pdf3.load_ttf_font( 'MY_DIR', 'simfang.ttf', 'CID', p_compress => false ), 12 );
as_pdf3.write( 'Chinese: 在中国的一个简单的句子', -1, -1 );
--
as_pdf3.save_pdf;
end;

fonts

But some more things, headers en footers:

declare
t_rc sys_refcursor;
t_query varchar2(1000);
begin
as_pdf3.init;
as_pdf3.load_ttf_font( 'MY_FONTS', 'COLONNA.TTF', 'CID' );
as_pdf3.set_page_proc( q'~
begin
as_pdf3.set_font( 'helvetica', 8 );
as_pdf3.put_txt( 10, 15, 'Page #PAGE_NR# of "PAGE_COUNT#' );
as_pdf3.set_font( 'helvetica', 12 );
as_pdf3.put_txt( 350, 15, 'This is a footer text' );
as_pdf3.set_font( 'helvetica', 'B', 15 );
as_pdf3.put_txt( 200, 780, 'This is a header text' );
as_pdf3.put_image( 'MY_DIR', 'amis.jpg', 500, 15 );
end;~' );
as_pdf3.set_page_proc( q'~
begin
as_pdf3.set_font( 'Colonna MT', 'N', 50 );
as_pdf3.put_txt( 150, 200, 'Watermark Watermark Watermark', 60 );
end;~' );
t_query := 'select rownum, sysdate + level, ''example'' || level from dual connect by level as_pdf3.query2table( t_query );
open t_rc for t_query;
as_pdf3.refcursor2table( t_rc );
as_pdf3.save_pdf;
end;

Generating a PDF-document with some plsql: as_pdf_mini => as_pdf3 tables

And the code for this package: as_pdf3

See also this blog for some additions.

** Changelog:
** Date: 13-08-2012
** added two procedure for Andreas Weiden
** see https://sourceforge.net/projects/pljrxml2pdf/
** Date: 16-04-2012
** changed code for parse_png
** Date: 15-04-2012
** only dbms_lob.freetemporary for temporary blobs
** Date: 11-04-2012
** Initial release of as_pdf3

153 Comments

  1. naga May 21, 2015
    • Anton Scheffer May 21, 2015
  2. Zouhaier April 27, 2015
    • Anton Scheffer April 27, 2015
  3. Saeed April 25, 2015
    • Anton Scheffer April 27, 2015
  4. michelle March 13, 2015
  5. Alan Lawlor February 18, 2015
    • Anton Scheffer February 18, 2015
  6. Michelle February 14, 2015
    • Anton Scheffer February 16, 2015
  7. Miki February 2, 2015
    • Anton Scheffer February 4, 2015
  8. Hojjat December 5, 2014
    • Anton Scheffer December 5, 2014
  9. roel November 20, 2014
    • Anton Scheffer November 22, 2014
  10. milk November 3, 2014
    • Anton Scheffer November 3, 2014
  11. milk November 3, 2014
  12. arkad October 30, 2014
  13. souluran October 2, 2014
    • Anton Scheffer October 2, 2014
      • souluran October 2, 2014
  14. souluran October 2, 2014
  15. Richard September 17, 2014
  16. mrbrightwork August 13, 2014
  17. Monali July 21, 2014
  18. Mathew July 15, 2014
  19. vadim boyarkin July 15, 2014
  20. Valerio July 2, 2014
    • Anton Scheffer July 2, 2014
  21. Ola June 18, 2014
    • Ola June 18, 2014
      • Ola June 18, 2014
  22. Ola May 23, 2014
    • Anton Scheffer May 23, 2014
      • Ola May 23, 2014
        • Anton Scheffer May 23, 2014
          • Ola May 23, 2014
    • Anton Scheffer May 23, 2014
      • Ola May 23, 2014
  23. Andreas Weiden May 1, 2014
  24. Jobi April 30, 2014
    • Anton Scheffer April 30, 2014
  25. Andrew April 21, 2014
    • Anton Scheffer April 21, 2014
  26. André March 6, 2014
    • Anton Scheffer March 6, 2014
  27. Martin February 27, 2014
    • Anton Scheffer February 27, 2014
  28. Piero February 4, 2014
    • Anton Scheffer February 4, 2014
  29. Neil January 29, 2014
    • Anton Scheffer January 29, 2014
      • Sietze June 19, 2014
        • Anton Scheffer June 19, 2014
  30. Peter January 22, 2014
  31. Jason January 10, 2014
    • Anton Scheffer January 11, 2014
  32. prigano November 26, 2013
    • Anton Scheffer November 26, 2013
    • JpalG January 28, 2014
      • Anton Scheffer January 29, 2014
        • sunny June 25, 2014
          • Anton Scheffer June 25, 2014
          • sunny June 26, 2014
          • Anton Scheffer June 26, 2014
          • sunny June 27, 2014
  33. Zakaria November 1, 2013
  34. Zakaria October 31, 2013
  35. Guillermo October 22, 2013
    • Anton Scheffer October 22, 2013
      • Guillermo October 22, 2013
        • Anton Scheffer October 22, 2013
          • Guillermo October 22, 2013
          • Anton Scheffer October 22, 2013
  36. Jim G. September 27, 2013
  37. Dimitris K September 19, 2013
    • Anton Scheffer September 19, 2013
  38. francesco.patea@bticino.it December 19, 2012
    • Anton Scheffer December 19, 2012
  39. francesco.patea@bticino.it December 11, 2012
    • Anton Scheffer December 11, 2012
  40. DarkZoro79 November 30, 2012
    • Anton Scheffer December 1, 2012
  41. francesco.patea@bticino.it November 30, 2012
    • Anton Scheffer November 30, 2012
  42. Ruben November 27, 2012
    • Anton Scheffer November 27, 2012
  43. Senthil Murugan November 4, 2012
  44. scott August 26, 2012
    • Anton Scheffer August 27, 2012
  45. scott August 26, 2012
    • Anton Scheffer August 27, 2012
      • SCOTT August 28, 2012
        • Anton Scheffer August 28, 2012
  46. Jeff August 2, 2012
    • Anton Scheffer August 3, 2012
      • Jeff August 4, 2012
        • Anton Scheffer August 4, 2012
  47. scott July 21, 2012
  48. scott July 18, 2012
    • Anton Scheffer July 18, 2012
  49. scott July 12, 2012
  50. scott July 7, 2012
  51. scott July 5, 2012
    • Anton Scheffer July 5, 2012
      • scott July 5, 2012
        • Anton Scheffer July 6, 2012
          • scott July 7, 2012
      • scott July 6, 2012
        • Anton Scheffer July 6, 2012
          • scott July 10, 2012
          • Anton Scheffer July 10, 2012
          • scott July 12, 2012
          • Anton Scheffer July 12, 2012
          • scott July 15, 2012
          • scott July 15, 2012
          • Anton Scheffer July 15, 2012
  52. w0rtez June 14, 2012
  53. GB June 11, 2012
    • Anton Scheffer June 12, 2012
  54. Andreas Weiden May 25, 2012
    • Anton Scheffer May 27, 2012
      • Andreas Weiden May 27, 2012
        • Anton Scheffer May 27, 2012
          • Andreas Weiden May 28, 2012
          • Anton Scheffer May 28, 2012
  55. Tony Quinn May 2, 2012
    • Anton Scheffer May 2, 2012
  56. Richard April 30, 2012
    • Dean Attewell May 1, 2012
    • Anton Scheffer May 1, 2012
  57. Dean Attewell April 30, 2012
    • Anton Scheffer April 30, 2012
  58. Anton Scheffer April 26, 2012
  59. Devel April 26, 2012
  60. Tony Quinn April 19, 2012
  61. Andreas Weiden April 16, 2012
    • Anton Scheffer April 16, 2012
  62. Andreas Weiden April 14, 2012
    • Anton Scheffer April 15, 2012
    • Andreas Weiden April 25, 2014
  63. Apexer April 12, 2012
    • Anton Scheffer April 12, 2012
      • Apexer April 17, 2012
        • Anton Scheffer April 17, 2012
          • Apexer April 17, 2012
          • Anton Scheffer April 17, 2012
          • Devel April 26, 2012
          • Anton Scheffer April 26, 2012