HMG_HPDF - Export to PDF made easy...
Posted: Fri Sep 28, 2012 4:14 pm
Dear friends,
I have tried to implement similar commands to HMG Print system using official HaruPDF library.
Some points to note:
- I could not implement 'Rounded' rectangle alone. All other commands are implemented.
- Font Bold, Italics, underline and strikeout are also not implemented as they are not available in this library.
- TTF fonts can also be used if you provide the exact path to the font file (like "c:\windows\fonts\myfont.ttf") or copy the font to the application folder and provide ("myfont.ttf"). The TTF font will be embedded into the PDF file automatically.
- Only image files with png extension can be drawn.
This is the initial version. Please give your valuable suggestions for improvement.
Now the sample application code:
I have tried to implement similar commands to HMG Print system using official HaruPDF library.
Some points to note:
- I could not implement 'Rounded' rectangle alone. All other commands are implemented.
- Font Bold, Italics, underline and strikeout are also not implemented as they are not available in this library.
- TTF fonts can also be used if you provide the exact path to the font file (like "c:\windows\fonts\myfont.ttf") or copy the font to the application folder and provide ("myfont.ttf"). The TTF font will be embedded into the PDF file automatically.
- Only image files with png extension can be drawn.
This is the initial version. Please give your valuable suggestions for improvement.
Now the sample application code:
Code: Select all
#include <hmg.ch>
#include "hmg_hpdf.ch"
Function Main
define window main at 0, 0 width 300 height 300 main title 'HMG HPDF Sample'
define button print
row 100
col 100
caption 'Create PDF'
action pdf_create()
end button
end window
main.center
main.activate
Return
function pdf_create
local lSuccess := .f.
SELECT HPDFDOC 'sample.pdf' TO lSuccess papersize HPDF_PAPER_A4
if lSuccess
START HPDFDOC
START HPDFPAGE
@ 10, 60 HPDFPRINT 'This is sample Left Aligned'
@ 15, 60 HPDFPRINT 'This is sample Red Colored' color { 255, 0, 0 }
@ 20, 60 HPDFPRINT 'This is sample Center Aligned' CENTER
@ 25, 60 HPDFPRINT 'This is sample Right Aligned' RIGHT
@ 30, 10 HPDFPRINT 'This is a small paragraph to be printed inside a rectangular area which is left aligned.' to 50, 60
@ 60, 10 HPDFPRINT 'This is a small paragraph to be printed inside a rectangular area which is center aligned.' to 80, 60 CENTER
@ 90, 10 HPDFPRINT 'This is a small paragraph to be printed inside a rectangular area which is right aligned.' to 110, 60 RIGHT
@ 120, 10 HPDFPRINT 'This is a small paragraph to be printed inside a rectangular area which is justify aligned.' to 140, 60 JUSTIFY
@ 150, 10 HPDFPRINT line to 160, 10
@ 150, 20 HPDFPRINT line to 160, 20 penwidth 0.5
@ 150, 30 HPDFPRINT line to 160, 30 penwidth 1 color { 0, 255, 0 }
END HPDFPAGE
START HPDFPAGE
@ 10, 60 HPDFPRINT 'This is Page 2'
@ 30, 20 HPDFPRINT rectangle to 60, 50
@ 40, 30 HPDFPRINT rectangle to 50, 40 penwidth 1 color { 0, 255, 0 }
@ 70, 20 HPDFPRINT rectangle to 90, 40 penwidth 1 color { 0, 255, 0 } filled
@ 100, 10 HPDFPRINT 'This is text in BIG size' size 30
@ 120, 10 HPDFPRINT 'This is in Times-Roman font' font 'Times-Roman' size 18
@ 140, 10 HPDFPRINT 'This is in Courier-BoldOblique font' font 'Courier-BoldOblique' size 18
@ 160, 10 HPDFPRINT 'This is in Times-Italic font' font 'Times-Italic' size 18
@ 180, 10 HPDFPRINT 'This is in Helvetica-Bold font' font 'Helvetica-Bold' size 18
@ 200, 10 HPDFPRINT 'This is in Courier font' font 'Courier' size 18
END HPDFPAGE
START HPDFPAGE
@ 10, 60 HPDFPRINT 'This is Page 3'
@ 20, 10 HPDFPRINT IMAGE 'peacock.png' width 140 height 106
END HPDFPAGE
END HPDFDOC
endif
execute file 'sample.pdf'
return nil