Results 1 to 9 of 9

Thread: Printing to PDF

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Printing to PDF

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    Is QPrinter available in Qt 3 ??
    u can check QPrinter::PdfFormat in void QPrinter::setOutputFormat ( OutputFormat format )
    hope this helps

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    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.

  4. #4
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    Quote Originally Posted by munna View Post
    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

  5. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    See if this helps.

  6. #6
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Printing to PDF

    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".

  7. #7
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    Quote Originally Posted by munna View Post
    See if this 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????

    Qt Code:
    1. void printToPrinter()
    2. {
    3. QPrinter printer( QPrinter::HighResolution );
    4. printing = TRUE;
    5. printer.setPageSize ( mappings.pageSize() );
    6. printer.setOrientation( mappings.orientation() );
    7. printer.setOutputFileName ( (const char *)chemGlobals->printerDefaultFilename() );
    8. printer.setOutputToFile ( FALSE );
    9. printer.setFullPage( TRUE );
    10.  
    11. // Run the printer setup dialog, and if the user clicks 'ok' then
    12. // do the actual printing
    13. #if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
    14. if ( printer.setup( this ) )
    15. #else
    16. // if ( QPrintDialog::getPrinterSetup( &printer ) )
    17. QPrintDialog printerDialog( &printer );
    18. printerDialog.setPrinter( &printer, TRUE );
    19. if( printerDialog.exec() )
    20. #endif
    21. p.begin( &printer );
    22. //drawToPrinter
    23. p.end
    24. }
    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

  8. #8
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    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.

  9. #9
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing to PDF

    Quote Originally Posted by Brandybuck View Post
    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

Similar Threads

  1. Pixel Position and Printing text
    By nErnie in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2006, 12:35
  2. Re: Printing in Qt
    By Jimmy2775 in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 23:00
  3. Replies: 0
    Last Post: 28th June 2006, 20:49
  4. Qt Printing on .ps
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2006, 23:22
  5. Printing Copyright Cicle C from QString
    By jakamph in forum Newbie
    Replies: 7
    Last Post: 13th February 2006, 22:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.