1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//#include "utilcls.h"
//#include "comobj.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Variant vPDFC, ProgramIsRunning, vPDFCError;
String DefaultPrinter;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// on teste si PDFCreator est deja execute
// si oui
try
{
vPDFC = Variant::GetActiveObject("PDFCreator.clsPDFCreator");
}
// si non
catch(...)
{
vPDFC = Variant::CreateObject("PDFCreator.clsPDFCreator");
}
vPDFCError = Variant::CreateObject("PDFCreator.clsPDFCreatorError");
Variant pdfOptions = vPDFC.OlePropertyGet("cOptions");
vPDFC.OleFunction("cStart", "/NoProcessingAtStart", false) = true;
//ProgramIsRunning = vPDFC.OleProcedure("cProgramIsRunning");
//bool visible = vPDFC.OlePropertyGet("cVisible");
vPDFC.OlePropertySet("cVisible", true);
//int etatWindow = vPDFC.OlePropertyGet("cWindowState");
//vPDFC.OlePropertySet("cWindowState", 0);
//String version = vPDFC.OlePropertyGet("cWindowsVersion");
DefaultPrinter = vPDFC.OlePropertyGet("cDefaultPrinter");
vPDFC.OlePropertySet("cDefaultPrinter", "PDFCreator");
String vPDFPath = "C:\\";
pdfOptions.OlePropertyGet("AutosaveDirectory") = vPDFPath;
//vPDFC.OlePropertyGet("cOption", "AutosaveDirectory") = vPDFPath;
String vPDFName = "teste_memo"; // extension .pdf
//vPDFC.OlePropertyGet("cOption", "AutosaveFilename") = vPDFName;
pdfOptions.OlePropertyGet("AutosaveFilename") = vPDFName;
//vPDFC.OlePropertyGet("cOption", "UseAutosave") = true;
pdfOptions.OlePropertyGet("UseAutosave") = true;
//vPDFC.OlePropertyGet("cOption", "UseAutosaveDirectory") = true;
pdfOptions.OlePropertyGet("UseAutosaveDirectory") = true;
// 0=PDF, 1=Png, 2=jpg, 3=bmp, 4=pcx, 5=tif, 6=ps, 7=eps, 8=txt
//vPDFC.OlePropertyGet("cOption", "AutosaveFormat") = 0;
vPDFC.OlePropertySet("cOption", "cClearCache", true);
//vPDFC.OleFunction("cAddPrintjob", "C:\\teste_memo.txt");
//String prntjbname = vPDFC.OlePropertyGet("cPrintjobFilename", 1);
//int a = vPDFC.OlePropertyGet("cCountOfPrintjobs");
//bool printstop = vPDFC.OlePropertyGet("cPrinterStop");
vPDFC.OleFunction("cPrintFile", "teste_memo.pdf");
vPDFC.OlePropertySet("cPrinterStop", false);
vPDFC.OleFunction("cPrintFile", "teste_memo.txt");
//Variant vVersion = vPDFC.OlePropertyGet("cGhostscriptVersion");
HWND hwnd;
hwnd = FindWindow("ThunderRT6FormDC", "PDFCreator - Moniteur d'impression PDF");
OpenIcon(hwnd);
BringWindowToTop(hwnd);
vPDFCError = vPDFC.OlePropertyGet("cError");
int eNumber = vPDFC.OlePropertyGet("cErrorDetail", "Number");
String eDetail = vPDFC.OlePropertyGet("cErrorDetail", "Description");
//vPDFCError = vPDFC.OlePropertyGet("cErrorDetail");
//DefaultPrinter = vPDFC.OlePropertyGet("cDefaultPrinter");
//vPDFC.OleFunction("cGetLogfile");
//vPDFC.OlePropertyGet("cProgramRelease", true);
//vPDFC.OlePropertyGet("cProgramIsRunning") = true;
//vPDFC.OlePropertyGet("cPDFCreatorApplicationPath");
//vPDFC.OleFunction("cClose");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
vPDFC.OlePropertySet("cDefaultPrinter", DefaultPrinter.c_str());
vPDFC.OleFunction("cClose");
}
//--------------------------------------------------------------------------- |
Partager