PDA

View Full Version : QPrintPreview File, printing PDF Files



opra
28th August 2009, 06:52
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?

victor.fernandez
28th August 2009, 09:06
I think you will need to use Poppler.

Kumosan
28th August 2009, 09:23
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.

opra
28th August 2009, 10:19
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. :D

Kumosan
28th August 2009, 10:59
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. :D


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.

opra
28th August 2009, 12:13
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?

Kumosan
28th August 2009, 12:23
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. :-)

daniel3d
20th June 2013, 17:00
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\"");