Page 1 of 1
print preview - PDFCreator
Posted: Wed Apr 20, 2011 3:00 pm
by Carlos Reis
Hello all
How can I print a PDF file ?
I'm using the HMG 3.0.35 and I want to print a PDF file
for example:
.....
......
xfile :=" Teste.pdf"
......
......
START PRINTDOC
START PRINTPAGE
// commands for Print the "teste.pdf " file
END PRINTPAGE
END PRINTDOC
Return Nil
[u]Moderator Notes[/u] (Pablo César) wrote:This topic was splitted and moved from HMG Wishlist.
Re: print preview
Posted: Wed Apr 20, 2011 6:20 pm
by mol
i think the best way in this time is to install PDFCreator and select it as printer...
I've tested some time ago a sample with pdf creating, but there were some problems (I don't remember what kind - something about positions... I think)
Re: print preview
Posted: Thu Apr 21, 2011 8:54 am
by gfilatov
mol wrote:i think the best way in this time is to install PDFCreator and select it as printer...
Hello,
I'm agree with your opinion.
Please take a look for the following simple sample of using PDFCreator for the printing:
Code: Select all
#include "minigui.ch"
*------------------------------------------------------------------------------*
Function Main()
*------------------------------------------------------------------------------*
// AVAILABLE LIBRARY INTERFACE LANGUAGES
// SET LANGUAGE TO ENGLISH (DEFAULT)
// SET LANGUAGE TO SPANISH
// SET LANGUAGE TO PORTUGUESE
// SET LANGUAGE TO ITALIAN
// SET LANGUAGE TO GERMAN
// SET LANGUAGE TO FRENCH
Private aColor [10]
aColor [1] := YELLOW
aColor [2] := PINK
aColor [3] := RED
aColor [4] := FUCHSIA
aColor [5] := BROWN
aColor [6] := ORANGE
aColor [7] := GREEN
aColor [8] := PURPLE
aColor [9] := BLACK
aColor [10] := BLUE
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'MiniPrint Library Test' ;
MAIN
DEFINE MAIN MENU
DEFINE POPUP 'File'
MENUITEM 'Default Printer' ACTION PrintTest1()
MENUITEM 'User Selected Printer' ACTION PrintTest2()
MENUITEM 'User Selected Printer And Settings' ACTION PrintTest3()
MENUITEM 'User Selected Printer And Settings (Preview)' ACTION PrintTest4()
END POPUP
END MENU
END WINDOW
MAXIMIZE WINDOW Win_1
ACTIVATE WINDOW Win_1
Return
*------------------------------------------------------------------------------*
Procedure PrintTest1()
*------------------------------------------------------------------------------*
Local DefaultPrinterBak
oPDFC := CreateObject( "PDFCreator.clsPDFCreator" )
oPDFC:cVisible := .F.
If oPDFC:cStart("/NoProcessingAtStartup") = .f.
If oPDFC:cStart("/NoProcessingAtStartup", .t.) = .f.
msginfo("Init printer error!")
return nil
EndIf
EndIf
oPDFC:cOption('UseAutosave',1)
oPDFC:cOption('UseAutosaveDirectory',1)
oPDFC:cOption("AutosaveFormat",0) && PDF format
DefaultPrinterBak := oPDFC:cDefaultprinter
oPDFC:cDefaultprinter := "PDFCreator"
oPDFC:cClearCache()
oPDFC:cOption('AutosaveFilename',"test")
oPDFC:cOption('AutosaveDirectory',GetTempFolder())
SELECT PRINTER DEFAULT ;
ORIENTATION PRINTER_ORIENT_PORTRAIT ;
PAPERSIZE PRINTER_PAPER_LETTER ;
QUALITY PRINTER_RES_MEDIUM
PrintDoc()
oPDFC:cPrinterStop := .f.
oPDFC:cClearcache()
oPDFC:cDefaultprinter := DefaultPrinterBak
oPDFC:cClose()
MsgInfo('Print Finished')
Return
*------------------------------------------------------------------------------*
Procedure PrintTest2()
*------------------------------------------------------------------------------*
Local i
Local cPrinter
cPrinter := GetPrinter()
If Empty (cPrinter)
Return
EndIf
SELECT PRINTER cPrinter ;
ORIENTATION PRINTER_ORIENT_PORTRAIT ;
PAPERSIZE PRINTER_PAPER_LETTER ;
QUALITY PRINTER_RES_MEDIUM
PrintDoc()
MsgInfo('Print Finished')
Return
*------------------------------------------------------------------------------*
Procedure PrintTest3()
*------------------------------------------------------------------------------*
Local i
Local lSuccess
// Measure Units Are Millimeters
SELECT PRINTER DIALOG TO lSuccess
If lSuccess == .T.
PrintDoc()
MsgInfo('Print Finished')
EndIf
Return
*------------------------------------------------------------------------------*
Procedure PrintTest4()
*------------------------------------------------------------------------------*
Local i
Local lSuccess
SELECT PRINTER DIALOG TO lSuccess PREVIEW
If lSuccess == .T.
PrintDoc()
MsgInfo('Print Finished')
EndIf
Return
*------------------------------------------------------------------------------*
Procedure PrintDoc
*------------------------------------------------------------------------------*
Local i
// Measure Units Are Millimeters
START PRINTDOC
FOR I := 1 TO 10
START PRINTPAGE
@ 20,20 PRINT RECTANGLE ;
TO 50,190 ;
PENWIDTH 0.1
@ 25,25 PRINT IMAGE "hmg.jpg" ;
WIDTH 20 ;
HEIGHT 20
@ 30,85 PRINT "PRINT DEMO" ;
FONT "Courier New" ;
SIZE 24 ;
BOLD ;
COLOR aColor [i]
@ 140,60 PRINT "Page Number :" + Str(i,2) ;
FONT "Arial" ;
SIZE 20 ;
COLOR aColor [i]
@ 260,20 PRINT LINE ;
TO 260,190 ;
PENWIDTH 0.1
END PRINTPAGE
NEXT I
END PRINTDOC
Return
Hope that helps
Re: print preview
Posted: Thu Apr 21, 2011 9:07 am
by Carlos Reis
mol wrote:i think the best way in this time is to install PDFCreator and select it as printer...
I've tested some time ago a sample with pdf creating, but there were some problems (I don't remember what kind - something about positions... I think)
Hi
Thanks for your reply.
The problem is that I need to print a document with a part of data from a table and another part from a pre-defenided document in PDF.
Re: print preview
Posted: Thu Apr 21, 2011 9:38 am
by Carlos Reis
Thanks gfilatov for the sample.
I will test it to see if it serves my needs.
Thanks a lot.
Re: print preview
Posted: Sun Apr 24, 2011 7:31 pm
by mol
Great work, Grigori