{
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;
}
{
const QString GhostScriptPath
= getGSDefaultExeName
();
QDir::setCurrent(_GSCACHE_
);
QString cmd1
= GhostScriptPath
+ " ";
cmd1 += args.join(" ");
int fax = -1;
#if defined Q_WS_MAC
fax = system(cmd1.toLocal8Bit());
QDir::setCurrent(startnow
);
return fax;
#endif
process
->setReadChannelMode
(QProcess::MergedChannels);
process
->start
( GhostScriptPath , args ,
QIODevice::ReadOnly );
if (!process->waitForFinished()) {
fax = -1;
} else {
QString ghostcomment
= process
->readAll
().
trimmed();
//////qDebug() << "ghostcomment-> " << ghostcomment;
fax = 0;
}
QDir::setCurrent(startnow
);
return fax;
}
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;
}
extern inline int callGS( const QStringList args )
{
const QString startnow = QDir::currentPath();
const QString GhostScriptPath = getGSDefaultExeName();
QDir::setCurrent(_GSCACHE_);
QString cmd1 = GhostScriptPath + " ";
cmd1 += args.join(" ");
int fax = -1;
#if defined Q_WS_MAC
fax = system(cmd1.toLocal8Bit());
QDir::setCurrent(startnow);
return fax;
#endif
QProcess *process = new QProcess(NULL);
process->setReadChannelMode(QProcess::MergedChannels);
process->start( GhostScriptPath , args , QIODevice::ReadOnly );
if (!process->waitForFinished()) {
fax = -1;
} else {
QString ghostcomment = process->readAll().trimmed();
//////qDebug() << "ghostcomment-> " << ghostcomment;
fax = 0;
}
QDir::setCurrent(startnow);
return fax;
}
To copy to clipboard, switch view to plain text mode
Bookmarks