[Add] rotate, export with nup, 2 side offset and page remove.
This commit is contained in:
parent
7af6a60e5c
commit
a4b88ab1ff
@ -9,4 +9,6 @@
|
|||||||
-I /usr/include/gtk-3.0/
|
-I /usr/include/gtk-3.0/
|
||||||
-I /usr/include/qt4/
|
-I /usr/include/qt4/
|
||||||
-I /usr/include/x86_64-linux-gnu/qt5/
|
-I /usr/include/x86_64-linux-gnu/qt5/
|
||||||
|
-I /usr/include/x86_64-linux-gnu/qt5/QtWidgets/
|
||||||
|
-I /usr/local/Qt-5.3.2/lib/
|
||||||
-I lib/lua/
|
-I lib/lua/
|
||||||
|
@ -54,8 +54,21 @@ bool PDFJam::removePage(int fileIndex, int numPages, int deletedPageIndex) {
|
|||||||
pushCommand(cmd);
|
pushCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFJam::movePage(int fromFileIndex, int fromPageIndex, int toFileIndex, int toPageIndex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFJam::savePageAsImage(Poppler::Page pp, QString dst, double dpi = 72) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Export file number 'fileIndex' to destination. */
|
/* Export file number 'fileIndex' to destination. */
|
||||||
void PDFJam::exportFile(int fileIndex, int numPages, QString dst) {
|
/* Supported n-up, orientation, offset options. */
|
||||||
|
void PDFJam::exportFile(int fileIndex, int numPages, QString dst,
|
||||||
|
QSize nup = QSize(1,1), bool isLandscape = false, bool hasTwoSideOffset = false,
|
||||||
|
int leftOffset = 0, int rightOffset = 0) {
|
||||||
|
|
||||||
QString cmd = "pdfjam ";
|
QString cmd = "pdfjam ";
|
||||||
QString tmp = "/tmp/hpdf/%1/%2.pdf '-' ";
|
QString tmp = "/tmp/hpdf/%1/%2.pdf '-' ";
|
||||||
|
|
||||||
@ -63,22 +76,43 @@ void PDFJam::exportFile(int fileIndex, int numPages, QString dst) {
|
|||||||
cmd += tmp.arg(QString::number(fileIndex)).arg(QString::number(i));
|
cmd += tmp.arg(QString::number(fileIndex)).arg(QString::number(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString orientation = isLandscape?" --landscape ": " --no-landscape ";
|
||||||
|
cmd = orientation;
|
||||||
|
if((nup.width() == 1) || (nup.height() != 1)) {
|
||||||
|
QString nupTmp = " --nup '%1x%1' --frame true ";
|
||||||
|
cmd += nupTmp.arg(QString::number(nup.width())).arg(QString::number(nup.height()));
|
||||||
|
}
|
||||||
|
|
||||||
QString outTmp = " --outfile %1 ";
|
QString outTmp = " --outfile %1 ";
|
||||||
cmd += outTmp.arg(dst);
|
cmd += outTmp.arg(dst);
|
||||||
pushCommand(cmd);
|
pushCommand(cmd);
|
||||||
|
/* Offset comes next. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFJam::loadFile(QString fileName, int fileIndex, int numPages) {
|
void PDFJam::loadFile(QString fileName, int fileIndex, Poppler::Document* pd) {
|
||||||
|
int numPages = pd->numPages();
|
||||||
QString path = "/tmp/hpdf/%1/";
|
QString path = "/tmp/hpdf/%1/";
|
||||||
path = path.arg(QString::number(fileIndex));
|
path = path.arg(QString::number(fileIndex));
|
||||||
makeFolder(path);
|
makeFolder(path);
|
||||||
|
|
||||||
QString tmp = "pdfjam %1 %2 -- outfile %3%4.pdf";
|
QString tmp = "pdfjam %1 %2 --outfile %3%4.pdf %5";
|
||||||
QString cmd = "";
|
QString cmd = "";
|
||||||
for(int i = 0; i <= numPages; i++) {
|
for(int i = 0; i <= numPages; i++) {
|
||||||
cmd += tmp.arg(fileName).arg(QString::number(i+1)).arg(path).arg(QString::number(i)) + ";";
|
QString orientation = " --no-landscape ";
|
||||||
|
QSizeF pageSize = pd->page(i)->pageSizeF();
|
||||||
|
if(pageSize.width() > pageSize.height()) {
|
||||||
|
orientation = " --landscape ";
|
||||||
|
}
|
||||||
|
cmd += tmp.arg(fileName).arg(QString::number(i+1)).arg(path)
|
||||||
|
.arg(QString::number(i)).arg(orientation) + " ; ";
|
||||||
}
|
}
|
||||||
pushCommand(cmd);
|
pushCommand(cmd);
|
||||||
|
|
||||||
|
/* Test the backend functions. */
|
||||||
|
/*removePage(0, numPages, 5);
|
||||||
|
rotatePage(0, 5, 270);
|
||||||
|
exportFile(0, numPages-1, "/home/allanis/conco.pdf", QSize(2, 2), true, true, 1, 0);*/
|
||||||
|
/* End test. */
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PDFJam::nextCommand(void) {
|
QString PDFJam::nextCommand(void) {
|
||||||
@ -98,10 +132,10 @@ void PDFJam::run(void) {
|
|||||||
while(!isQueueEmpty()) {
|
while(!isQueueEmpty()) {
|
||||||
QString cmd = nextCommand();
|
QString cmd = nextCommand();
|
||||||
int value = system(cmd.toStdString().c_str());
|
int value = system(cmd.toStdString().c_str());
|
||||||
/*if(value != 0)
|
if(value != 0)
|
||||||
qDebug() << "ERROR: Failed to execute " << cmd;
|
qDebug() << "ERROR: Failed to execute " << cmd;
|
||||||
else
|
else
|
||||||
qDebug() << "SUCCESS: executed " << cmd;*/
|
qDebug() << "SUCCESS: executed " << cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,11 @@ public:
|
|||||||
PDFJam(void);
|
PDFJam(void);
|
||||||
|
|
||||||
void pushCommand(QString);
|
void pushCommand(QString);
|
||||||
void loadFile(QString fileName, int, int);
|
void loadFile(QString fileName, int, Poppler::Document*);
|
||||||
void exportFile(int, int, QString);
|
void exportFile(int, int, QString, QSize, bool, bool, int, int);
|
||||||
|
void savePageAsImage(Poppler::Page pp, QString dst, double);
|
||||||
|
void movePage(int fromFileIndex, int fromPageIndex, int toFileIndex, int toPageIndex);
|
||||||
|
|
||||||
bool removePage(int, int, int);
|
bool removePage(int, int, int);
|
||||||
bool rotatePage(int, int, int);
|
bool rotatePage(int, int, int);
|
||||||
void makeFolder(QString);
|
void makeFolder(QString);
|
||||||
|
@ -41,7 +41,7 @@ void PDFTableWidget::loadFile(QString fileName) {
|
|||||||
PDFFileWidget* fileWidget = new PDFFileWidget();
|
PDFFileWidget* fileWidget = new PDFFileWidget();
|
||||||
fileWidget->setAncestor(this);
|
fileWidget->setAncestor(this);
|
||||||
fileWidget->setDocument(doc, fileName);
|
fileWidget->setDocument(doc, fileName);
|
||||||
pdfJam.loadFile(fileName, files.size()-1, doc->numPages());
|
pdfJam.loadFile(fileName, files.size()-1, doc);
|
||||||
|
|
||||||
fileWidgets.append(fileWidget);
|
fileWidgets.append(fileWidget);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user