Hello,

I'm trying to print images (for example to PDF):
Qt Code:
  1. QString filePath = "deklaracje/10100188";
  2. QDir directory(filePath);
  3.  
  4. QStringList images = directory.entryList(QStringList() << "*.jpg" << "*.JPG",QDir::Files);
  5. QString fileName = "pdf/test.pdf";
  6.  
  7. QPrinter printer2;
  8. printer2.setOutputFormat(QPrinter::PdfFormat);
  9. printer2.setPaperSize(QPrinter::A4);
  10. printer2.setOutputFileName(fileName);
  11. int size, i;
  12. i = 0;
  13. QPainter painter2(&printer2);
  14. int painter2_w, painter2_h;
  15. painter2_w = painter2.device()->width();
  16. painter2_h = painter2.device()->height();
  17. foreach(QString fileName, images) {
  18. QImage img(filePath+"/"+fileName);
  19. if(i==0){
  20. p.begin(&img);
  21. p.setPen(QPen(QColor(0,0,48)));
  22. p.setFont(QFont("Arial", this->fontSize, QFont::Bold));
  23. QRect rect;
  24. rect = img.rect();
  25. rect.setLeft(100);
  26. rect.setTop(200);
  27. p.drawText(rect, Qt::AlignLeft, "xxxxx");
  28. p.end();
  29. }
  30. painter2.drawImage(QPoint(0,0),img.scaled(painter2_w,painter2_h,Qt::KeepAspectRatio));
  31. i++;
  32. if(i<size){
  33. printer2.newPage();
  34. }
  35. }
  36. painter2.end();
To copy to clipboard, switch view to plain text mode 


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.