PDA

View Full Version : Printing to PDF



vermarajeev
7th December 2006, 03:10
Hi guys,

Is there any way to print the content of the canvas (basically images) on to PDF files using Qt 3.3.5.

Thankx in advance

aamer4yu
7th December 2006, 04:00
Is QPrinter available in Qt 3 ??
u can check QPrinter::PdfFormat in void QPrinter::setOutputFormat ( OutputFormat format )
hope this helps :)

munna
7th December 2006, 04:02
Qt3 does not have print to pdf option. This was introduced only in Qt4. I guess you will need some external application to do this.

vermarajeev
7th December 2006, 05:21
Qt3 does not have print to pdf option. This was introduced only in Qt4. I guess you will need some external application to do this.

Please tell me what I should do?? What do you mean by "some external application"???

Please help me!!!!

Thankx

munna
7th December 2006, 10:08
See if this (http://www.primopdf.com/) helps.

Brandybuck
7th December 2006, 21:53
You can can print to a file, which is in postscript format. Then there are several utilities that convert postscript to PDF. One of them is "ps2pdf".

vermarajeev
8th December 2006, 04:05
See if this (http://www.primopdf.com/) helps.

Ok the link what you have given prints to a PDF.
But my problem is as follows

First I draw images on QFrame, then using QPrinter and QPainter classes defined in Qt3.3.5 I'm able to print into pages. It works quite fine.

I can print to a file. Now I want printing to a pdf file such that I can have a "*.pdf" file. If I'm not clear please see the code below and tell me what I should do????


void printToPrinter()
{
QPrinter printer( QPrinter::HighResolution );
printing = TRUE;
printer.setPageSize ( mappings.pageSize() );
printer.setOrientation( mappings.orientation() );
printer.setOutputFileName ( (const char *)chemGlobals->printerDefaultFilename() );
printer.setOutputToFile ( FALSE );
printer.setFullPage( TRUE );

// Run the printer setup dialog, and if the user clicks 'ok' then
// do the actual printing
#if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
if ( printer.setup( this ) )
#else
// if ( QPrintDialog::getPrinterSetup( &printer ) )
QPrintDialog printerDialog( &printer );
printerDialog.setPrinter( &printer, TRUE );
if( printerDialog.exec() )
#endif
QPainter p;
p.begin( &printer );
//drawToPrinter
p.end
}
This code is to print to a file, how can I print to PDF file???

Thankx

munna
8th December 2006, 04:19
I think the solution that BrandyBuck gave is much better than mine.
With Qt3, it is the user of your application who will need to do the extra stuff to print as pdf and not you.

vermarajeev
11th December 2006, 03:25
You can can print to a file, which is in postscript format. Then there are several utilities that convert postscript to PDF. One of them is "ps2pdf".
Hi Brandybuck,
Can you please tell me what do you mean when you tell "print to a file"??? Also how can I be sure whether the file is in postscript format or not??? Then is the solution you are suggesting is portable???(either windows or else)...I have given a sample program in the above thread, Can you please help me understanding your solution using that code.

I'll be thankful to you!!!!!!

Thankx