Originally Posted by
munna
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()
{
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 ) )
printerDialog.setPrinter( &printer, TRUE );
if( printerDialog.exec() )
#endif
p.begin( &printer );
//drawToPrinter
p.end
}
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
}
To copy to clipboard, switch view to plain text mode
This code is to print to a file, how can I print to PDF file???
Thankx
Bookmarks