PDA

View Full Version : Is possible to change the parameters of an external application using Qt?



SkripT
12th April 2006, 18:27
Hi all, In my application I need to generate a PDF document using Qt4.1. Before generating the document, the aplication allow the user to configure some issues of the final document: if it can be printed or not, block copy/paste of the text and images, enable/disable it's modification,... To print (generate) the document I use PDFCreator on WindowsXp that let specify all these options to generate the PDF file in a configuration menu. My question is: anybody knows how could I change/set these settings of PDFCreator using Qt? Thanks.

prakash
13th April 2006, 06:15
I am also interested in the reply on this thred.

Can any one reply - Is possible to change the parameters of an external application using Qt?

Thanks.

nupul
13th April 2006, 07:43
Well I tried this once...and the only way that i could figure out was if to pass command line arguments to the app using QProcess - but this is true only for apps which provide the command line options :p ...... sounds imbecile but this is the advantage of Unix!

SkripT
13th April 2006, 10:03
Thanks nupul. I've been asking it in a forum of PDFCreator and the answer is that is possible to change it's configuration using COM. The problem is that I've never used it, so anyone could tell me if Qt supports COM and where could I find some examples of its usage? I've seen in the PDFCreator manual that exists public classes, properties, methods and events for working with COM but I don't know how to use them with Qt :confused: I only want to set these properties in the creation of the COM object (i don't know if it's exactly in this way):

Public PDFDisallowCopy As Long
Public PDFDisallowModifyAnnotations As Long
Public PDFDisallowModifyContents As Long
Public PDFDisallowPrinting As Long



Thanks.

wysota
13th April 2006, 11:26
so anyone could tell me if Qt supports COM
Yes.

and where could I find some examples of its usage?
In the ActiveQt section of the docs :)

Conel
13th April 2006, 15:27
This is the example code which shows how Adobe Distiller can be used via COM using QAxObject. Distiller performs its work in a separate thread. This allows not to block UI while distiller is working



void MyThread::run()
{
OleInitialize(NULL);
QAxObject* distiller = new QAxObject();
bool result = distiller->setControl("{1CD675B2-ECD1-11D1-B976-00600802DB86}");
QObject::connect(distiller, SIGNAL(OnPercentDone(int)), m_pParentDialog, SLOT(onpercentdone(int)));
QObject::connect(distiller, SIGNAL(OnPageNumber(int)), m_pParentDialog, SLOT(onpagenumber(int)));
QObject::connect(distiller, SIGNAL(OnLogMessage(const QString&)), m_pParentDialog, SLOT(onlogmessage(const QString&)));
QValueList<QVariant> params;
params << inputfile;
params << outfile;
params << joboptions;
int res = distiller->dynamicCall( "FileToPDF(const QString&,const QString&,const QString&)", params ).toInt();
delete distiller;
OleUninitialize();
}


Distiller converts PostScript files into PDF. It has some signals that can be handled by my own objects.

If you want to get some help info about using COM object you can generate HTML file using dumpdoc utility from Qt package. Example:

dumpdoc.exe "{1CD675B2-ECD1-11D1-B976-00600802DB86}" > helpDistiller.html

Parameter for this utility should be CLSID of the COM server

SkripT
13th April 2006, 18:16
Hi all, today I've been reading the ActiveQt section from the docs. I've never worked with COM and I've found it a bit hard. But I think that finally I have understood how it works (the code that Conel has posted has been very helpful too, thanks):

1) Declare a QAxObject or a QAxWidget
2) Set the name of the COM object wrapped by the object with "setControl"
3) Call the methods of the COM object using "dynamicCall".
My question is, in the PDFCreator docs COM section defines the class "clsPDFCreatorOptions" with the members that I need to use:
Public PDFDisallowCopy As Long
Public PDFDisallowModifyAnnotations As Long
Public PDFDisallowModifyContents As Long
Public PDFDisallowPrinting As Long
Are these members avaible using dynamicCall if I create a QAxObject with control "clsPDFCreatorOptions" or I have to use the "QObject::setProperty"? I think that I haven't understand at all this part...
Another question is: should I have to manage the generation of the PDF file using the QAxObject or, if I use QPrinter, it will mantain the properties fixed in QAxObject for the generation of the PDF doc?