Results 1 to 2 of 2

Thread: Print PDF file without using QPrintDialog

  1. #1
    Join Date
    May 2012
    Location
    Arequipa, Perú
    Posts
    1
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Print PDF file without using QPrintDialog

    Hi! ^^ I'm trying to print a PDF file without using QPrintDialog, I tried something like this:

    Qt Code:
    1. QPrinter printer;
    2. printer.setPrinterName("<printer's name>");
    3.  
    4. QTextDocument document;
    5. document.setHtml("<h2>something</h2>");
    6.  
    7. document.print(&printer);
    To copy to clipboard, switch view to plain text mode 

    This works fine with a HTML file but I need to use a PDF file. I was looking for a way to wrap a PDF in a QDocument class or something similar but I haven't been successful

    Thanks for your help!!!!!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Print PDF file without using QPrintDialog

    There is functionality in Qt for rendering to create a PDF file (via QPrinter). This has no direct relationship to QPrintDialog.

    There is no functionality in Qt for rendering an existing PDF document to a printer. You need a third-party library to do this. For GPL programs Poppler is a popular choice, and of course, you can pay Glyph and Cog, Adobe or another commercial group to use their wares.

  3. The following user says thank you to ChrisW67 for this useful post:

    bryan.gv (27th May 2012)

Similar Threads

  1. How to print pdf file?
    By surwassu in forum Newbie
    Replies: 2
    Last Post: 6th June 2011, 09:43
  2. Replies: 3
    Last Post: 20th April 2010, 17:49
  3. print to pdf a doc file
    By rmagro in forum Qt Programming
    Replies: 4
    Last Post: 31st January 2009, 13:39
  4. How to print only the file name of a path
    By franco.amato in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2008, 22:28
  5. How to Print a doc file (or binary file) to printer
    By rmagro in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2008, 16:46

Tags for this Thread

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.