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();
QString filePath = "deklaracje/10100188";
QDir directory(filePath);
QStringList images = directory.entryList(QStringList() << "*.jpg" << "*.JPG",QDir::Files);
QString fileName = "pdf/test.pdf";
QPrinter printer2;
printer2.setOutputFormat(QPrinter::PdfFormat);
printer2.setPaperSize(QPrinter::A4);
printer2.setOutputFileName(fileName);
int size, i;
i = 0;
QPainter painter2(&printer2);
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){
QPainter p;
p.begin(&img);
p.setPen(QPen(QColor(0,0,48)));
p.setFont(QFont("Arial", this->fontSize, QFont::Bold));
QRect rect;
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();
To copy to clipboard, switch view to plain text mode
Bookmarks