Hi ChrisW67
Thanks for your help..
the implementation Code for the Function LoadPDF
{
const QString pdfFile
= PathConvert
(fn
);
const QString tmpFile = PathConvert
(QDir::homePath()+"/sctodaytmps.png");
const QString qttmpFile
= QDir::homePath()+"/sctodaytmps.png";
tmp.setNum(Page);
int ret = -1;
tmp.setNum(Page);
args.append("-sDEVICE=png16m");
args.append("-r72");
args.append("-dGraphicsAlphaBits=4");
args.append("-o");
args.append(tmpFile);
args.append("-dFirstPage="+tmp);
args.append("-dLastPage="+tmp);
args.append(pdfFile);
ret = callGS(args);
////////qDebug() << "### ret " << ret;
if (ret == 0)
{
QPixmap penna
= tmpimage.
scaledToWidth(w
);
tmpimage.detach();
QFile lastaction
(qttmpFile
);
lastaction.remove();
p.begin(&penna);
p.setBrush(Qt::NoBrush);
p.
setPen(QPen(QBrush(Qt
::black),
2,Qt
::SolidLine));
p.drawRect(0, 0, penna.width(), penna.height());
p.end();
return penna;
}
return pm;
}
extern inline QPixmap LoadPDF(QString fn, int Page, int w )
{
QString tmp, cmd1, cmd2;
const QString pdfFile = PathConvert(fn);
const QString tmpFile = PathConvert(QDir::homePath()+"/sctodaytmps.png");
const QString qttmpFile = QDir::homePath()+"/sctodaytmps.png";
QPixmap pm;
tmp.setNum(Page);
int ret = -1;
tmp.setNum(Page);
QStringList args;
args.append("-sDEVICE=png16m");
args.append("-r72");
args.append("-dGraphicsAlphaBits=4");
args.append("-o");
args.append(tmpFile);
args.append("-dFirstPage="+tmp);
args.append("-dLastPage="+tmp);
args.append(pdfFile);
ret = callGS(args);
////////qDebug() << "### ret " << ret;
if (ret == 0)
{
QPixmap tmpimage(qttmpFile);
QPixmap penna = tmpimage.scaledToWidth(w);
tmpimage.detach();
QFile lastaction(qttmpFile);
lastaction.remove();
QPainter p;
p.begin(&penna);
p.setBrush(Qt::NoBrush);
p.setPen(QPen(QBrush(Qt::black),2,Qt::SolidLine));
p.drawRect(0, 0, penna.width(), penna.height());
p.end();
return penna;
}
return pm;
}
To copy to clipboard, switch view to plain text mode
I have tested the way you suggested with this code
pdfFile = LoadPDF( fixurl.absoluteFilePath() ,page,large);
if (pdfFile.isNull())
QMessageBox::warning(0,
"pdfFile.isNull() = True ",
"pdfFile.isNull() = True");
QImage tImage
= pdfFile.
toImage();
if (tImage.isNull())
QMessageBox::warning(0,
"tImage.isNull() = True ",
"tImage.isNull() = True");
pdfFile = LoadPDF( fixurl.absoluteFilePath() ,page,large);
if (pdfFile.isNull())
QMessageBox::warning(0,"pdfFile.isNull() = True ","pdfFile.isNull() = True");
QImage tImage = pdfFile.toImage();
if (tImage.isNull())
QMessageBox::warning(0,"tImage.isNull() = True ","tImage.isNull() = True");
To copy to clipboard, switch view to plain text mode
I'm getting both of the messages .. that mean it's not loading and converting to QPixmap
I think I will miss with the function more tomorrow..
Best Regards
Bookmarks