|
Poppler Qt4 0.18.1
|
00001 /* poppler-qt.h: qt interface to poppler 00002 * Copyright (C) 2005, Net Integration Technologies, Inc. 00003 * Copyright (C) 2005, 2007, Brad Hards <bradh@frogmouth.net> 00004 * Copyright (C) 2005-2011, Albert Astals Cid <aacid@kde.org> 00005 * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> 00006 * Copyright (C) 2006-2011, Pino Toscano <pino@kde.org> 00007 * Copyright (C) 2009 Shawn Rutledge <shawn.t.rutledge@gmail.com> 00008 * Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> 00009 * Copyright (C) 2010 Matthias Fauconneau <matthias.fauconneau@gmail.com> 00010 * Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2, or (at your option) 00015 * any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU General Public License 00023 * along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 00025 */ 00026 00027 #ifndef __POPPLER_QT_H__ 00028 #define __POPPLER_QT_H__ 00029 00030 #include "poppler-annotation.h" 00031 #include "poppler-link.h" 00032 #include "poppler-optcontent.h" 00033 #include "poppler-page-transition.h" 00034 00035 #include <QtCore/QByteArray> 00036 #include <QtCore/QDateTime> 00037 #include <QtCore/QSet> 00038 #include <QtXml/QDomDocument> 00039 #include "poppler-export.h" 00040 00041 class EmbFile; 00042 class Sound; 00043 class AnnotMovie; 00044 00048 namespace Poppler { 00049 00050 class Document; 00051 class DocumentData; 00052 00053 class PageData; 00054 00055 class FormField; 00056 00057 class TextBoxData; 00058 00059 class PDFConverter; 00060 class PSConverter; 00061 00071 typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/); 00072 00084 POPPLER_QT4_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure); 00085 00095 class POPPLER_QT4_EXPORT TextBox { 00096 friend class Page; 00097 public: 00103 TextBox(const QString& text, const QRectF &bBox); 00107 ~TextBox(); 00108 00112 QString text() const; 00113 00120 QRectF boundingBox() const; 00121 00127 TextBox *nextWord() const; 00128 00132 QRectF charBoundingBox(int i) const; 00133 00137 bool hasSpaceAfter() const; 00138 00139 private: 00140 Q_DISABLE_COPY(TextBox) 00141 00142 TextBoxData *m_data; 00143 }; 00144 00145 00146 class FontInfoData; 00151 class POPPLER_QT4_EXPORT FontInfo { 00152 friend class Document; 00153 public: 00157 enum Type { 00158 unknown, 00159 Type1, 00160 Type1C, 00161 Type1COT, 00162 Type3, 00163 TrueType, 00164 TrueTypeOT, 00165 CIDType0, 00166 CIDType0C, 00167 CIDType0COT, 00168 CIDTrueType, 00169 CIDTrueTypeOT 00170 }; 00171 00173 00176 FontInfo(); 00177 00181 FontInfo( const FontInfoData &fid ); 00183 00187 FontInfo( const FontInfo &fi ); 00188 00192 ~FontInfo(); 00193 00197 QString name() const; 00198 00203 QString file() const; 00204 00210 bool isEmbedded() const; 00211 00218 bool isSubset() const; 00219 00227 Type type() const; 00228 00237 QString typeName() const; 00238 00242 FontInfo& operator=( const FontInfo &fi ); 00243 00244 private: 00245 FontInfoData *m_data; 00246 }; 00247 00248 00249 class FontIteratorData; 00269 class POPPLER_QT4_EXPORT FontIterator { 00270 friend class Document; 00271 friend class DocumentData; 00272 public: 00276 ~FontIterator(); 00277 00282 QList<FontInfo> next(); 00283 00288 bool hasNext() const; 00289 00293 int currentPage() const; 00294 00295 private: 00296 Q_DISABLE_COPY( FontIterator ) 00297 FontIterator( int, DocumentData *dd ); 00298 00299 FontIteratorData *d; 00300 }; 00301 00302 00303 class EmbeddedFileData; 00307 class POPPLER_QT4_EXPORT EmbeddedFile { 00308 friend class DocumentData; 00309 friend class Page; 00310 public: 00312 EmbeddedFile(EmbFile *embfile); 00314 00318 ~EmbeddedFile(); 00319 00323 QString name() const; 00324 00330 QString description() const; 00331 00337 int size() const; 00338 00342 QDateTime modDate() const; 00343 00347 QDateTime createDate() const; 00348 00354 QByteArray checksum() const; 00355 00361 QString mimeType() const; 00362 00366 QByteArray data(); 00367 00373 bool isValid() const; 00374 00378 //QDataStream dataStream() const; 00379 00380 private: 00381 Q_DISABLE_COPY(EmbeddedFile) 00382 EmbeddedFile(EmbeddedFileData &dd); 00383 00384 EmbeddedFileData *m_embeddedFile; 00385 }; 00386 00387 00396 class POPPLER_QT4_EXPORT Page { 00397 friend class Document; 00398 public: 00402 ~Page(); 00403 00407 enum Rotation { Rotate0 = 0, 00408 Rotate90 = 1, 00409 Rotate180 = 2, 00410 Rotate270 = 3 00411 }; 00412 00416 enum PageAction { 00417 Opening, 00418 Closing 00419 }; 00420 00425 enum TextLayout { 00426 PhysicalLayout, 00427 RawOrderLayout 00428 }; 00429 00434 enum PainterFlag { 00442 DontSaveAndRestore = 0x00000001 00443 }; 00444 Q_DECLARE_FLAGS( PainterFlags, PainterFlag ) 00445 00446 00484 QImage renderToImage(double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0) const; 00485 00528 bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, 00529 Rotation rotate = Rotate0, PainterFlags flags = 0) const; 00530 00539 QImage thumbnail() const; 00540 00550 QString text(const QRectF &rect, TextLayout textLayout) const; 00551 00560 QString text(const QRectF &rect) const; 00561 00565 enum SearchDirection { FromTop, 00566 NextResult, 00567 PreviousResult 00568 }; 00569 00573 enum SearchMode { CaseSensitive, 00574 CaseInsensitive 00575 }; 00576 00587 Q_DECL_DEPRECATED bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; 00588 00600 bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; 00601 00618 QList<TextBox*> textList(Rotation rotate = Rotate0) const; 00619 00623 QSizeF pageSizeF() const; 00624 00628 QSize pageSize() const; 00629 00640 PageTransition *transition() const; 00641 00647 Link *action( PageAction act ) const; 00648 00652 enum Orientation { 00653 Landscape, 00654 Portrait, 00655 Seascape, 00656 UpsideDown 00657 }; 00658 00662 Orientation orientation() const; 00663 00667 void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); 00668 00672 QList<Link*> links() const; 00673 00677 QList<Annotation*> annotations() const; 00678 00685 QList<FormField*> formFields() const; 00686 00694 double duration() const; 00695 00701 QString label() const; 00702 00703 private: 00704 Q_DISABLE_COPY(Page) 00705 00706 Page(DocumentData *doc, int index); 00707 PageData *m_page; 00708 }; 00709 00760 class POPPLER_QT4_EXPORT Document { 00761 friend class Page; 00762 friend class DocumentData; 00763 00764 public: 00768 enum PageMode { 00769 UseNone, 00770 UseOutlines, 00771 UseThumbs, 00772 FullScreen, 00773 UseOC, 00774 UseAttach 00775 }; 00776 00780 enum PageLayout { 00781 NoLayout, 00782 SinglePage, 00783 OneColumn, 00784 TwoColumnLeft, 00785 TwoColumnRight, 00786 TwoPageLeft, 00787 TwoPageRight 00788 }; 00789 00795 enum RenderBackend { 00796 SplashBackend, 00797 ArthurBackend 00798 }; 00799 00805 enum RenderHint { 00806 Antialiasing = 0x00000001, 00807 TextAntialiasing = 0x00000002, 00808 TextHinting = 0x00000004, 00809 TextSlightHinting = 0x00000008 00810 }; 00811 Q_DECLARE_FLAGS( RenderHints, RenderHint ) 00812 00813 00820 void setColorDisplayProfile(void *outputProfileA); 00828 void setColorDisplayProfileName(const QString &name); 00836 void* colorRgbProfile() const; 00844 void *colorDisplayProfile() const; 00845 00863 static Document *load(const QString & filePath, 00864 const QByteArray &ownerPassword=QByteArray(), 00865 const QByteArray &userPassword=QByteArray()); 00866 00888 static Document *loadFromData(const QByteArray &fileContents, 00889 const QByteArray &ownerPassword=QByteArray(), 00890 const QByteArray &userPassword=QByteArray()); 00891 00902 Page *page(int index) const; 00903 00916 Page *page(const QString &label) const; 00917 00921 int numPages() const; 00922 00928 PageMode pageMode() const; 00929 00935 PageLayout pageLayout() const; 00936 00945 bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); 00946 00950 bool isLocked() const; 00951 00967 QDateTime date( const QString & data ) const; 00968 00985 QString info( const QString & data ) const; 00986 00990 QStringList infoKeys() const; 00991 00995 bool isEncrypted() const; 00996 01003 bool isLinearized() const; 01004 01009 bool okToPrint() const; 01010 01015 bool okToPrintHighRes() const; 01016 01024 bool okToChange() const; 01025 01030 bool okToCopy() const; 01031 01037 bool okToAddNotes() const; 01038 01046 bool okToFillForm() const; 01047 01053 bool okToCreateFormFields() const; 01054 01060 bool okToExtractForAccessibility() const; 01061 01069 bool okToAssemble() const; 01070 01078 Q_DECL_DEPRECATED double pdfVersion() const; 01079 01091 void getPdfVersion(int *major, int *minor) const; 01092 01104 QList<FontInfo> fonts() const; 01105 01124 Q_DECL_DEPRECATED bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const; 01125 01141 FontIterator* newFontIterator( int startPage = 0 ) const; 01142 01148 QByteArray fontData(const FontInfo &font) const; 01149 01156 QList<EmbeddedFile*> embeddedFiles() const; 01157 01161 bool hasEmbeddedFiles() const; 01162 01186 QDomDocument *toc() const; 01187 01196 LinkDestination *linkDestination( const QString &name ); 01197 01203 void setPaperColor(const QColor &color); 01209 QColor paperColor() const; 01210 01218 void setRenderBackend( RenderBackend backend ); 01226 RenderBackend renderBackend() const; 01227 01233 static QSet<RenderBackend> availableRenderBackends(); 01234 01244 void setRenderHint( RenderHint hint, bool on = true ); 01250 RenderHints renderHints() const; 01251 01259 PSConverter *psConverter() const; 01260 01268 PDFConverter *pdfConverter() const; 01269 01275 QString metadata() const; 01276 01289 bool hasOptionalContent() const; 01290 01298 OptContentModel *optionalContentModel(); 01299 01308 QStringList scripts() const; 01309 01322 bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; 01323 01327 ~Document(); 01328 01329 private: 01330 Q_DISABLE_COPY(Document) 01331 01332 DocumentData *m_doc; 01333 01334 Document(DocumentData *dataA); 01335 }; 01336 01337 class BaseConverterPrivate; 01338 class PSConverterPrivate; 01339 class PDFConverterPrivate; 01347 class POPPLER_QT4_EXPORT BaseConverter 01348 { 01349 friend class Document; 01350 public: 01354 virtual ~BaseConverter(); 01355 01357 void setOutputFileName(const QString &outputFileName); 01358 01364 void setOutputDevice(QIODevice *device); 01365 01371 virtual bool convert() = 0; 01372 01373 enum Error 01374 { 01375 NoError, 01376 FileLockedError, 01377 OpenOutputError, 01378 NotSupportedInputFileError 01379 }; 01380 01385 Error lastError() const; 01386 01387 protected: 01389 BaseConverter(BaseConverterPrivate &dd); 01390 Q_DECLARE_PRIVATE(BaseConverter) 01391 BaseConverterPrivate *d_ptr; 01393 01394 private: 01395 Q_DISABLE_COPY(BaseConverter) 01396 }; 01397 01414 class POPPLER_QT4_EXPORT PSConverter : public BaseConverter 01415 { 01416 friend class Document; 01417 public: 01423 enum PSOption { 01424 Printing = 0x00000001, 01425 StrictMargins = 0x00000002, 01426 ForceRasterization = 0x00000004 01427 }; 01428 Q_DECLARE_FLAGS( PSOptions, PSOption ) 01429 01430 01433 ~PSConverter(); 01434 01436 void setPageList(const QList<int> &pageList); 01437 01441 void setTitle(const QString &title); 01442 01446 void setHDPI(double hDPI); 01447 01451 void setVDPI(double vDPI); 01452 01456 void setRotate(int rotate); 01457 01461 void setPaperWidth(int paperWidth); 01462 01466 void setPaperHeight(int paperHeight); 01467 01471 void setRightMargin(int marginRight); 01472 01476 void setBottomMargin(int marginBottom); 01477 01481 void setLeftMargin(int marginLeft); 01482 01486 void setTopMargin(int marginTop); 01487 01495 void setStrictMargins(bool strictMargins); 01496 01498 void setForceRasterize(bool forceRasterize); 01499 01505 void setPSOptions(PSOptions options); 01506 01514 PSOptions psOptions() const; 01515 01523 void setPageConvertedCallback(void (* callback)(int page, void *payload), void *payload); 01524 01525 bool convert(); 01526 01527 private: 01528 Q_DECLARE_PRIVATE(PSConverter) 01529 Q_DISABLE_COPY(PSConverter) 01530 01531 PSConverter(DocumentData *document); 01532 }; 01533 01539 class POPPLER_QT4_EXPORT PDFConverter : public BaseConverter 01540 { 01541 friend class Document; 01542 public: 01546 enum PDFOption { 01547 WithChanges = 0x00000001 01548 }; 01549 Q_DECLARE_FLAGS( PDFOptions, PDFOption ) 01550 01551 01554 virtual ~PDFConverter(); 01555 01559 void setPDFOptions(PDFOptions options); 01563 PDFOptions pdfOptions() const; 01564 01565 bool convert(); 01566 01567 private: 01568 Q_DECLARE_PRIVATE(PDFConverter) 01569 Q_DISABLE_COPY(PDFConverter) 01570 01571 PDFConverter(DocumentData *document); 01572 }; 01573 01577 POPPLER_QT4_EXPORT QDateTime convertDate( char *dateString ); 01578 01584 POPPLER_QT4_EXPORT bool isCmsAvailable(); 01585 01586 class SoundData; 01596 class POPPLER_QT4_EXPORT SoundObject { 01597 public: 01601 enum SoundType { 01602 External, 01603 Embedded 01604 }; 01605 01609 enum SoundEncoding { 01610 Raw, 01611 Signed, 01612 muLaw, 01613 ALaw 01614 }; 01615 01617 SoundObject(Sound *popplersound); 01619 01620 ~SoundObject(); 01621 01625 SoundType soundType() const; 01626 01630 QString url() const; 01631 01635 QByteArray data() const; 01636 01640 double samplingRate() const; 01641 01645 int channels() const; 01646 01650 int bitsPerSample() const; 01651 01655 SoundEncoding soundEncoding() const; 01656 01657 private: 01658 Q_DISABLE_COPY(SoundObject) 01659 01660 SoundData *m_soundData; 01661 }; 01662 01663 class MovieData; 01669 class POPPLER_QT4_EXPORT MovieObject { 01670 friend class Page; 01671 public: 01675 enum PlayMode { 01676 PlayOnce, 01677 PlayOpen, 01678 PlayRepeat, 01679 PlayPalindrome 01680 }; 01681 01682 ~MovieObject(); 01683 01687 QString url() const; 01688 01692 QSize size() const; 01693 01697 int rotation() const; 01698 01702 bool showControls() const; 01703 01707 PlayMode playMode() const; 01708 01709 private: 01711 MovieObject( AnnotMovie *ann ); 01713 01714 Q_DISABLE_COPY(MovieObject) 01715 01716 MovieData *m_movieData; 01717 }; 01718 01719 } 01720 01721 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags) 01722 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints) 01723 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions) 01724 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions) 01725 01726 #endif
1.7.4