Print images dosen't work on server
Hello,
I'm trying to print images (for example to PDF):
Code:
QString filePath
= "deklaracje/10100188";
QDir directory
(filePath
);
printer2.
setOutputFormat(QPrinter::PdfFormat);
printer2.setOutputFileName(fileName);
int size, i;
i = 0;
int painter2_w, painter2_h;
painter2_w = painter2.device()->width();
painter2_h = painter2.device()->height();
foreach
(QString fileName, images
) { QImage img
(filePath
+"/"+fileName
);
if(i==0){
p.begin(&img);
p.
setFont(QFont("Arial", this
->fontSize,
QFont::Bold));
rect = img.rect();
rect.setLeft(100);
rect.setTop(200);
p.drawText(rect, Qt::AlignLeft, "xxxxx");
p.end();
}
painter2.
drawImage(QPoint(0,
0),img.
scaled(painter2_w,painter2_h,Qt
::KeepAspectRatio));
i++;
if(i<size){
printer2.newPage();
}
}
painter2.end();
On my computer it is working good. The PDF is save with images and with the "xxxxx" text (with 146kb size).
When I send compiled software to server the PDFs created empty and with (with 2kb size). Even print on the printer is empty.
Re: Print images dosen't work on server
Are both system similar? I.e. same operating systems, etc?
Are you deploying Qt with the application or do the systems use locally installed Qt libraries?
If the latter, are they the same version?
Are you using the same platform plugin (if the platform has multiple)?
Have you tried QPdfWriter?
Can the images actually be loaded?
e.g. have you checked the image sizes or have you tried loading and saving to a new file?
Cheers,
_
Re: Print images dosen't work on server
Quote:
Can the images actually be loaded?
If the OP's code is what is actually being executed on the server, then he has specified a relative location for the "filePath" directory. If this doesn't exist on his server (or the program's working directory isn't where he thinks it is), then it is likely no JPG files are ever found for processing.
I just love it when people write code with absolutely no error checking and just assume it will work, then can't understand why it doesn't.