- 论坛徽章:
- 0
|
- #include <poppler-qt4.h>
- //A PDF document can then be loaded as follows:
- QString filename;
- Poppler::Document* document = Poppler::Document::load(filename);
- if (!document || document->isLocked()) {
- // ... error message ....
- delete document;
- return;
- }
- // Paranoid safety check
- if (document == 0) {
- // ... error message ...
- return;
- }
- // Access page of the PDF file
- Poppler::Page* pdfPage = document->page(pageNumber); // Document starts at page 0
- if (pdfPage == 0) {
- // ... error message ...
- return;
- }
- // Pages can be rendered to QImages with the following commands:
- // Generate a QImage of the rendered page
- QImage image = pdfPage->renderToImage(xres, yres, x, y, width, height);
- if (image.isNull()) {
- // ... error message ...
- return;
- }
- // ... use image ...
- // after the usage, the page must be deleted
- delete pdfPage;
- // Finally, don't forget to destroy the document:
- delete document;
复制代码 |
|