Imprimir a PDF. ultimo codigo del ejemplo del hilo HPDF no f
Posted: Sat Mar 08, 2014 6:43 pm
Hola.
He leido todo el hilo sobre HMG_HPDF - Export to PDF made easy... (New Version) y por lo que entiendo con esto se puede generar un listado en pdf sin mandarlo a la impresora verdad? (pretendo mandarlo por email sin vista previa). El caso es que el ultimo ejemplo que esta para descargar del hilo lo ejecuto en 3.2 y me da un monton de error redefinition y demas. Saben si ha cambiado algo para que ahora no funcione?
Lo muestro a continuacion, muchas gracias por adelantado.
#xcommand SET PRINTSYSTEM PDF ;
=>;
#include "hmg_hpdf.ch"
#include <hmg.ch>
Function Main
SET PRINTSYSTEM PDF
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 PRINTER 'sample.pdf' TO lSuccess ;
PAPERSIZE PRINTER_PAPER_A4 ;
ORIENTATION PRINTER_ORIENT_LANDSCAPE ;
PREVIEW
SET PRINTDOC COMPRESS ALL
// Set if you wish a password for the generated file
// SET PRINTDOC PASSWORD OWNER 'owner' USER 'user'
if lSuccess
START PRINTDOC
START PRINTPAGE
@ 10, 60 PRINT 'This is sample Left Aligned'
@ 15, 20 PRINT 'This is sample Red Colored' color { 255, 0, 0 }
@ 15, 100 PRINT 'This is sample Another Fantastic Color' color { 150, 100, 100 }
@ 20, 60 PRINT 'This is sample Center Aligned' CENTER
@ 25, 60 PRINT 'This is sample Right Aligned' RIGHT
@ 30, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is left aligned.' to 50, 60
@ 60, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is center aligned.' to 80, 60 CENTER
@ 90, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is right aligned.' to 110, 60 RIGHT
@ 120, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is justify aligned.' to 140, 60 JUSTIFY
@ 150, 10 PRINT line to 160, 10
@ 150, 20 PRINT line to 160, 20 penwidth 0.5
@ 150, 30 PRINT line to 160, 30 penwidth 1 color { 0, 255, 0 }
END PRINTPAGE
START PRINTPAGE
@ 10, 60 PRINT 'This is Page 2'
@ 30, 20 PRINT rectangle to 60, 50
@ 40, 30 PRINT rectangle to 50, 40 penwidth 1 color { 0, 255, 0 }
@ 70, 20 PRINT rectangle to 90, 40 penwidth 1 color { 0, 255, 0 } filled
@ 100, 10 PRINT 'This is text in BIG size' size 30
@ 120, 10 PRINT 'This is in Times-Roman font' font 'Times-Roman' size 18
@ 140, 10 PRINT 'This is in Courier-BoldOblique font' font 'Courier-BoldOblique' size 18
@ 160, 10 PRINT 'This is in Times-Italic font' font 'Times-Italic' size 18
@ 180, 10 PRINT 'This is in Helvetica-Bold font' font 'Helvetica-Bold' size 18
@ 200, 10 PRINT 'This is in Courier font' font 'Courier' size 18
END PRINTPAGE
START PRINTPAGE
@ 10, 60 PRINT 'This is Page 3'
@ 20, 10 PRINT IMAGE 'peacock.png' width 140 height 106
END PRINTPAGE
START PRINTPAGE
@ 20, 20 PRINT CIRCLE RADIUS 10
@ 20, 45 PRINT CIRCLE RADIUS 10 color { 0, 255, 0 }
@ 20, 70 PRINT CIRCLE RADIUS 10 color { 255, 255, 0 } filled
@ 50, 20 PRINT ARC RADIUS 10 ANGLE FROM 0 TO 180 penwidth 2 color { 255, 0, 255 }
@ 50, 50 PRINT ELLIPSE HORIZONTAL RADIUS 10 VERTICAL RADIUS 20 penwidth 2 color { 255, 0, 255 }
@ 50, 90 PRINT ELLIPSE HORIZONTAL RADIUS 20 VERTICAL RADIUS 10 penwidth 2 color { 0, 0, 255 }
@ 50, 140 PRINT ELLIPSE HORIZONTAL RADIUS 20 VERTICAL RADIUS 10 penwidth 2 color { 0, 0, 255 } filled
// try rounded rectangle
@ 100, 70 PRINT CURVE FROM 70, 70 TO 70, 100
@ 70, 200 PRINT CURVE FROM 70, 230 TO 100, 230
@ 150, 70 PRINT CURVE FROM 180, 70 TO 180, 100
@ 180, 200 PRINT CURVE FROM 180, 230 TO 150, 230
@ 70, 100 PRINT LINE TO 70, 200
@ 100, 70 PRINT LINE TO 150, 70
@ 100, 230 PRINT LINE TO 150, 230
@ 180, 100 PRINT LINE TO 180, 200
END PRINTPAGE
END PRINTDOC
endif
// You can open the generated file at any moment
// OPEN FILE 'sample.pdf'
// Or you can print it
// PRINT FILE 'sample.pdf'
return nil
He leido todo el hilo sobre HMG_HPDF - Export to PDF made easy... (New Version) y por lo que entiendo con esto se puede generar un listado en pdf sin mandarlo a la impresora verdad? (pretendo mandarlo por email sin vista previa). El caso es que el ultimo ejemplo que esta para descargar del hilo lo ejecuto en 3.2 y me da un monton de error redefinition y demas. Saben si ha cambiado algo para que ahora no funcione?
Lo muestro a continuacion, muchas gracias por adelantado.
#xcommand SET PRINTSYSTEM PDF ;
=>;
#include "hmg_hpdf.ch"
#include <hmg.ch>
Function Main
SET PRINTSYSTEM PDF
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 PRINTER 'sample.pdf' TO lSuccess ;
PAPERSIZE PRINTER_PAPER_A4 ;
ORIENTATION PRINTER_ORIENT_LANDSCAPE ;
PREVIEW
SET PRINTDOC COMPRESS ALL
// Set if you wish a password for the generated file
// SET PRINTDOC PASSWORD OWNER 'owner' USER 'user'
if lSuccess
START PRINTDOC
START PRINTPAGE
@ 10, 60 PRINT 'This is sample Left Aligned'
@ 15, 20 PRINT 'This is sample Red Colored' color { 255, 0, 0 }
@ 15, 100 PRINT 'This is sample Another Fantastic Color' color { 150, 100, 100 }
@ 20, 60 PRINT 'This is sample Center Aligned' CENTER
@ 25, 60 PRINT 'This is sample Right Aligned' RIGHT
@ 30, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is left aligned.' to 50, 60
@ 60, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is center aligned.' to 80, 60 CENTER
@ 90, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is right aligned.' to 110, 60 RIGHT
@ 120, 10 PRINT 'This is a small paragraph to be printed inside a rectangular area which is justify aligned.' to 140, 60 JUSTIFY
@ 150, 10 PRINT line to 160, 10
@ 150, 20 PRINT line to 160, 20 penwidth 0.5
@ 150, 30 PRINT line to 160, 30 penwidth 1 color { 0, 255, 0 }
END PRINTPAGE
START PRINTPAGE
@ 10, 60 PRINT 'This is Page 2'
@ 30, 20 PRINT rectangle to 60, 50
@ 40, 30 PRINT rectangle to 50, 40 penwidth 1 color { 0, 255, 0 }
@ 70, 20 PRINT rectangle to 90, 40 penwidth 1 color { 0, 255, 0 } filled
@ 100, 10 PRINT 'This is text in BIG size' size 30
@ 120, 10 PRINT 'This is in Times-Roman font' font 'Times-Roman' size 18
@ 140, 10 PRINT 'This is in Courier-BoldOblique font' font 'Courier-BoldOblique' size 18
@ 160, 10 PRINT 'This is in Times-Italic font' font 'Times-Italic' size 18
@ 180, 10 PRINT 'This is in Helvetica-Bold font' font 'Helvetica-Bold' size 18
@ 200, 10 PRINT 'This is in Courier font' font 'Courier' size 18
END PRINTPAGE
START PRINTPAGE
@ 10, 60 PRINT 'This is Page 3'
@ 20, 10 PRINT IMAGE 'peacock.png' width 140 height 106
END PRINTPAGE
START PRINTPAGE
@ 20, 20 PRINT CIRCLE RADIUS 10
@ 20, 45 PRINT CIRCLE RADIUS 10 color { 0, 255, 0 }
@ 20, 70 PRINT CIRCLE RADIUS 10 color { 255, 255, 0 } filled
@ 50, 20 PRINT ARC RADIUS 10 ANGLE FROM 0 TO 180 penwidth 2 color { 255, 0, 255 }
@ 50, 50 PRINT ELLIPSE HORIZONTAL RADIUS 10 VERTICAL RADIUS 20 penwidth 2 color { 255, 0, 255 }
@ 50, 90 PRINT ELLIPSE HORIZONTAL RADIUS 20 VERTICAL RADIUS 10 penwidth 2 color { 0, 0, 255 }
@ 50, 140 PRINT ELLIPSE HORIZONTAL RADIUS 20 VERTICAL RADIUS 10 penwidth 2 color { 0, 0, 255 } filled
// try rounded rectangle
@ 100, 70 PRINT CURVE FROM 70, 70 TO 70, 100
@ 70, 200 PRINT CURVE FROM 70, 230 TO 100, 230
@ 150, 70 PRINT CURVE FROM 180, 70 TO 180, 100
@ 180, 200 PRINT CURVE FROM 180, 230 TO 150, 230
@ 70, 100 PRINT LINE TO 70, 200
@ 100, 70 PRINT LINE TO 150, 70
@ 100, 230 PRINT LINE TO 150, 230
@ 180, 100 PRINT LINE TO 180, 200
END PRINTPAGE
END PRINTDOC
endif
// You can open the generated file at any moment
// OPEN FILE 'sample.pdf'
// Or you can print it
// PRINT FILE 'sample.pdf'
return nil