Results 1 to 8 of 8

Thread: QPrintPreview File, printing PDF Files

  1. #1
    Join Date
    Oct 2008
    Location
    Switzerland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPrintPreview File, printing PDF Files

    Hi

    Is it possible to specify the Filename before calling QPrintPreviewExec?- like in System PrintPreview?

    I want to print some *.pdf file but its difficult because I cant read them in TextEdit .

    Or has somebody suggestion how to print pdf files (send file direct to printer) without printpreview and using Poppler?

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrintPreview File, printing PDF Files

    I think you will need to use Poppler.

  3. #3
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: QPrintPreview File, printing PDF Files

    Quote Originally Posted by victor.fernandez View Post
    I think you will need to use Poppler.
    No, you don't. Poppler would only be necessary if some sort of preview is required. If you want to send a pdf directly to a printer, you can do so via a normal QPrinter. BUT, and this is the problem, your print system must be able to handle pdf files. Under Linux with CUPS and some distribution magic I can lpr pdf files directly to the printer and probably ghostscript is implicitly used to automatically convert the pdf file into something my printer understands. If and how this works under other systems....no idea.

  4. The following user says thank you to Kumosan for this useful post:

    opra (28th August 2009)

  5. #4
    Join Date
    Oct 2008
    Location
    Switzerland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPrintPreview File, printing PDF Files

    Quote Originally Posted by Kumosan View Post
    No, you don't. Poppler would only be necessary if some sort of preview is required. If you want to send a pdf directly to a printer, you can do so via a normal QPrinter. BUT, and this is the problem, your print system must be able to handle pdf files. Under Linux with CUPS and some distribution magic I can lpr pdf files directly to the printer and probably ghostscript is implicitly used to automatically convert the pdf file into something my printer understands. If and how this works under other systems....no idea.
    Yes, I don't need to use Popller because I don't want to display File.

    Explain me please how to print file with QPrinter without to open it in QTextEdit.
    By the way, I'm developing under Windows, but the System will be used under Linux.

  6. #5
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: QPrintPreview File, printing PDF Files

    Quote Originally Posted by opra View Post
    Yes, I don't need to use Popller because I don't want to display File.

    Explain me please how to print file with QPrinter without to open it in QTextEdit.
    By the way, I'm developing under Windows, but the System will be used under Linux.

    Oh, really looks like I was in error. Thought it would be possible to feed the printer raw data. But looks like you cannot print what you cannot paint. Maybe you could use the more ugly way to use QProcess to feed your pdf directly to lpr.

  7. #6
    Join Date
    Oct 2008
    Location
    Switzerland
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: QPrintPreview File, printing PDF Files

    Quote Originally Posted by Kumosan View Post
    Oh, really looks like I was in error. Thought it would be possible to feed the printer raw data. But looks like you cannot print what you cannot paint. Maybe you could use the more ugly way to use QProcess to feed your pdf directly to lpr.
    Thats right, i should be able to paint data and than print with QPrinter (Poppler-way).

    But, there must be another solution.
    for example:

    QProcess pro;
    QStringList arg;

    arg<<file.fileName();
    pro.execute("explorer", arg).

    Works fine, with explorer can i view the pdf file. Logically, there must be a programm wich i can call //Win or Linux.

    But wich one?

  8. #7
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: QPrintPreview File, printing PDF Files

    Quote Originally Posted by opra View Post
    But wich one?
    No idea what to use on Windows, but you said that your program will run on Linux. Most Linux distributions uses CUPS. So I suppose that 'lpr' should work.

    Try:

    QProcess pro;
    QStringList arg;

    arg<<file.fileName();
    pro.execute("lpr", arg).

    No guarantees. :-)

  9. #8
    Join Date
    Jun 2013
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QPrintPreview File, printing PDF Files

    Hi i was having the same problem if you using windows and have adobe reader use this.

    QProcess process;
    process.start(" \"C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe\" /t C:/path/to/your.pdf \"The name of the printer\"");

Similar Threads

  1. Printing txt file vs Printing pdf file
    By rmagro in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2012, 15:45
  2. Extracting files from a zip file
    By Althor in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 10:39
  3. Generating .pro files from vcproj file or CMake file
    By ramazangirgin in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2009, 09:37
  4. Replies: 5
    Last Post: 22nd September 2006, 08:04
  5. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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
  •  
Qt is a trademark of The Qt Company.