示例#1
0
int main(int argc, char **argv)
{
    Q_UNUSED(argc)
    Q_UNUSED(argv)

    // open document
    QString file = "C:\\Users\\diorahman\\Downloads\\Hoteles_cerca.pdf";
    MuPDF::Document *document = MuPDF::loadDocument(file);
    if (NULL == document) {
        qDebug() << "no doc";
        return -1;
    }

    // load page
    MuPDF::Page *page = document->page(0);
    if (NULL == page) {
        delete document;
        return -1;
    }

    qDebug() << "loaded";

    // test Page::size()
    qDebug() << page->size();

    // test Page::renderImage()
    QImage image = page->renderImage();
    if (!image.save("a.png")) {
        return 1;
    }

    delete page;
    delete document;
    return 0;
}
示例#2
0
int main(int argc, char **argv)
{
	// open document
	QString file = argv[1];
	if (file.isEmpty()) {
		return 1;
	}
	MuPDF::Document *document = MuPDF::loadDocument(file);
	if (NULL == document) {
		return -1;
	}

	// load page
	MuPDF::Page *page = document->page(0);
	if (NULL == page) {
		delete document;
		return -1;
	}
	page->setTransform(1.0f, 1.0f, 90.0f);

	// test Page::size()
	qDebug() << page->size();

	// test Page::renderImage()
	{
		// image should be deleted before document is deleted
		QImage image = page->renderImage();
		if (!image.save("a.png")) {
			return 1;
		}
	}

	delete page;
	delete document;
	return 0;
}
示例#3
0
文件: main.cpp 项目: srazi/mupdf-qt
int main(int argc, char **argv)
{
	QApplication app(argc, argv);

	// open document
	QString file = QFileDialog::getOpenFileName(NULL,
			"Select PDF file", ".", "PDF (*.pdf)");
	if (file.isEmpty()) {
		return 0;
	}
	MuPDF::Document *document = MuPDF::loadDocument(file);
	if (NULL == document) {
		return 0;
	}

	// authenticate
	bool authed = false;
	if (document->needsPassword()) {
		bool ok = true;
		QString password;
		while (!authed && ok) {
			password = QInputDialog::getText(NULL,
					"Please input password", "Password",
					QLineEdit::Password, "", &ok);
			if (ok) {
				authed = document->authPassword(password);
			}
		}
	} else {
		authed = true;
	}

	// print info
	if (authed) {
		qDebug() << "PDF version:" << document->pdfVersion();
		qDebug() << "Page count:" << document->numPages();
		qDebug() << "Title:" << document->title();
		qDebug() << "Subject:" << document->subject();
		qDebug() << "Author:" << document->author();
		qDebug() << "Keywords:" << document->keywords();
		qDebug() << "Creator:" << document->creator();
		qDebug() << "Producer:" << document->producer();
		qDebug() << "CreationDate:" << document->creationDate()
			.toString(Qt::SystemLocaleLongDate);
		qDebug() << "ModDate:" << document->modDate()
			.toString(Qt::SystemLocaleLongDate);
	} else {
		qDebug() << "not loaded";
	}

	delete document;
	return 0;
}