Results 1 to 3 of 3

Thread: How to print pdf file?

  1. #1
    Join Date
    May 2011
    Posts
    19
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to print pdf file?

    Hi ,
    I want to print pdf file using QPrintDialog .
    I have a file menu in which two actions are pen & print
    alongwith i have a text editor to display contents of file to be printed
    open action will open document eg.text,pdf,html ..& set text editor value to contents of file..& then I am using following code to print
    <code>

    QTextDocument *document = editor->document();//line 1
    //editor is QTextedit object used to show contents of file ...
    QPrinter printer;
    QPrintDialog *dlg = new QPrintDialog(&printer, this);
    if (dlg->exec() != QDialog::Accepted)
    return;

    document->print(&printer);




    <\code>

    line 1 is working fine for text document
    for pdf doc it shows some junk things ,according to me it is not properly converting pdf to textedit...
    In this case is there any way??
    otherwise any api which accepts file location for printing so that i can directly give file location & use print function.

    Thanking you.
    Regards,
    Sumit

  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: How to print pdf file?

    QTextDocument is for editing text documents. A PDF file is not a text document. If you want to render a PDF file to a printer then you will need to use a third-party library (e.g. Poppler) to read the PDF file and produce something you can print. The answer hasn't really changed since the first time you asked: https://www.qtcentre.org/showthread.php?t=42061

    BTW: They should be [code][/code] tags

  3. #3
    Join Date
    May 2011
    Posts
    19
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to print pdf file?

    [QUOTE The answer hasn't really changed since the first time you asked: https://www.qtcentre.org/showthread.php?t=42061

    [/QUOTE]



    hi ChrisW67,
    The thread http://www.qtcentre.org/showthread.php?t=42061 is another its not same.
    It was about postscript conversion ,here my point is how should messaged my printer to accept pdf file like
    document() function will return QTextdocument pointer to hold text data,like wise is there any function to
    hold pdf data that can be directly send via print() function.


    You have suggested me third party library poppler can u give any links or forum toknow more about poppler
    easily?

    thanks.

Similar Threads

  1. print to pdf a doc file
    By rmagro in forum Qt Programming
    Replies: 4
    Last Post: 31st January 2009, 12:39
  2. How to print only the file name of a path
    By franco.amato in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2008, 21:28
  3. How to Print a doc file (or binary file) to printer
    By rmagro in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2008, 15:46
  4. how to print an html file?
    By patcito in forum Qt Programming
    Replies: 5
    Last Post: 31st August 2008, 16:50
  5. Print a QDialog in a PDF file
    By jjay in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2008, 11:29

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.