00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __POPPLER_QT_H__
00025 #define __POPPLER_QT_H__
00026
00027 #include "poppler-annotation.h"
00028 #include "poppler-link.h"
00029 #include "poppler-optcontent.h"
00030 #include "poppler-page-transition.h"
00031
00032 #include <QtCore/QByteArray>
00033 #include <QtCore/QDateTime>
00034 #include <QtCore/QSet>
00035 #include <QtXml/QDomDocument>
00036 #include "poppler-export.h"
00037
00038 class EmbFile;
00039 class Sound;
00040 class AnnotMovie;
00041
00045 namespace Poppler {
00046
00047 class Document;
00048 class DocumentData;
00049
00050 class PageData;
00051
00052 class FormField;
00053
00054 class TextBoxData;
00055
00056 class PDFConverter;
00057 class PSConverter;
00058
00068 class POPPLER_QT4_EXPORT TextBox {
00069 friend class Page;
00070 public:
00076 TextBox(const QString& text, const QRectF &bBox);
00080 ~TextBox();
00081
00085 QString text() const;
00086
00093 QRectF boundingBox() const;
00094
00100 TextBox *nextWord() const;
00101
00105 QRectF charBoundingBox(int i) const;
00106
00110 bool hasSpaceAfter() const;
00111
00112 private:
00113 Q_DISABLE_COPY(TextBox)
00114
00115 TextBoxData *m_data;
00116 };
00117
00118
00119 class FontInfoData;
00124 class POPPLER_QT4_EXPORT FontInfo {
00125 friend class Document;
00126 public:
00130 enum Type {
00131 unknown,
00132 Type1,
00133 Type1C,
00134 Type1COT,
00135 Type3,
00136 TrueType,
00137 TrueTypeOT,
00138 CIDType0,
00139 CIDType0C,
00140 CIDType0COT,
00141 CIDTrueType,
00142 CIDTrueTypeOT
00143 };
00144
00146
00149 FontInfo();
00150
00154 FontInfo( const FontInfoData &fid );
00156
00160 FontInfo( const FontInfo &fi );
00161
00165 ~FontInfo();
00166
00170 QString name() const;
00171
00176 QString file() const;
00177
00183 bool isEmbedded() const;
00184
00191 bool isSubset() const;
00192
00200 Type type() const;
00201
00210 QString typeName() const;
00211
00215 FontInfo& operator=( const FontInfo &fi );
00216
00217 private:
00218 FontInfoData *m_data;
00219 };
00220
00221
00222 class FontIteratorData;
00242 class POPPLER_QT4_EXPORT FontIterator {
00243 friend class Document;
00244 friend class DocumentData;
00245 public:
00249 ~FontIterator();
00250
00255 QList<FontInfo> next();
00256
00261 bool hasNext() const;
00262
00266 int currentPage() const;
00267
00268 private:
00269 Q_DISABLE_COPY( FontIterator )
00270 FontIterator( int, DocumentData *dd );
00271
00272 FontIteratorData *d;
00273 };
00274
00275
00276 class EmbeddedFileData;
00280 class POPPLER_QT4_EXPORT EmbeddedFile {
00281 public:
00283 EmbeddedFile(EmbFile *embfile);
00285
00289 ~EmbeddedFile();
00290
00294 QString name() const;
00295
00301 QString description() const;
00302
00308 int size() const;
00309
00313 QDateTime modDate() const;
00314
00318 QDateTime createDate() const;
00319
00325 QByteArray checksum() const;
00326
00332 QString mimeType() const;
00333
00337 QByteArray data();
00338
00344 bool isValid() const;
00345
00349
00350
00351 private:
00352 Q_DISABLE_COPY(EmbeddedFile)
00353
00354 EmbeddedFileData *m_embeddedFile;
00355 };
00356
00357
00366 class POPPLER_QT4_EXPORT Page {
00367 friend class Document;
00368 public:
00372 ~Page();
00373
00377 enum Rotation { Rotate0 = 0,
00378 Rotate90 = 1,
00379 Rotate180 = 2,
00380 Rotate270 = 3
00381 };
00382
00386 enum PageAction {
00387 Opening,
00388 Closing
00389 };
00390
00429 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;
00430
00439 QImage thumbnail() const;
00440
00448 QString text(const QRectF &rect) const;
00449
00453 enum SearchDirection { FromTop,
00454 NextResult,
00455 PreviousResult
00456 };
00457
00461 enum SearchMode { CaseSensitive,
00462 CaseInsensitive
00463 };
00464
00475 bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const;
00476
00477
00494 QList<TextBox*> textList(Rotation rotate = Rotate0) const;
00495
00499 QSizeF pageSizeF() const;
00500
00504 QSize pageSize() const;
00505
00516 PageTransition *transition() const;
00517
00523 Link *action( PageAction act ) const;
00524
00528 enum Orientation {
00529 Landscape,
00530 Portrait,
00531 Seascape,
00532 UpsideDown
00533 };
00534
00538 Orientation orientation() const;
00539
00543 void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown);
00544
00548 QList<Link*> links() const;
00549
00553 QList<Annotation*> annotations() const;
00554
00560 QList<FormField*> formFields() const;
00561
00569 double duration() const;
00570
00576 QString label() const;
00577
00578 private:
00579 Q_DISABLE_COPY(Page)
00580
00581 Page(DocumentData *doc, int index);
00582 PageData *m_page;
00583 };
00584
00635 class POPPLER_QT4_EXPORT Document {
00636 friend class Page;
00637 friend class DocumentData;
00638
00639 public:
00643 enum PageMode {
00644 UseNone,
00645 UseOutlines,
00646 UseThumbs,
00647 FullScreen,
00648 UseOC,
00649 UseAttach
00650 };
00651
00655 enum PageLayout {
00656 NoLayout,
00657 SinglePage,
00658 OneColumn,
00659 TwoColumnLeft,
00660 TwoColumnRight,
00661 TwoPageLeft,
00662 TwoPageRight
00663 };
00664
00670 enum RenderBackend {
00671 SplashBackend,
00672 ArthurBackend
00673 };
00674
00680 enum RenderHint {
00681 Antialiasing = 0x00000001,
00682 TextAntialiasing = 0x00000002,
00683 TextHinting = 0x00000004
00684 };
00685 Q_DECLARE_FLAGS( RenderHints, RenderHint )
00686
00687
00694 void setColorDisplayProfile(void *outputProfileA);
00702 void setColorDisplayProfileName(const QString &name);
00710 void* colorRgbProfile() const;
00718 void *colorDisplayProfile() const;
00719
00737 static Document *load(const QString & filePath,
00738 const QByteArray &ownerPassword=QByteArray(),
00739 const QByteArray &userPassword=QByteArray());
00740
00762 static Document *loadFromData(const QByteArray &fileContents,
00763 const QByteArray &ownerPassword=QByteArray(),
00764 const QByteArray &userPassword=QByteArray());
00765
00774 Page *page(int index) const;
00775
00788 Page *page(const QString &label) const;
00789
00793 int numPages() const;
00794
00800 PageMode pageMode() const;
00801
00807 PageLayout pageLayout() const;
00808
00817 bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword);
00818
00822 bool isLocked() const;
00823
00839 QDateTime date( const QString & data ) const;
00840
00857 QString info( const QString & data ) const;
00858
00862 QStringList infoKeys() const;
00863
00867 bool isEncrypted() const;
00868
00875 bool isLinearized() const;
00876
00881 bool okToPrint() const;
00882
00887 bool okToPrintHighRes() const;
00888
00896 bool okToChange() const;
00897
00902 bool okToCopy() const;
00903
00909 bool okToAddNotes() const;
00910
00918 bool okToFillForm() const;
00919
00925 bool okToCreateFormFields() const;
00926
00932 bool okToExtractForAccessibility() const;
00933
00941 bool okToAssemble() const;
00942
00950 Q_DECL_DEPRECATED double pdfVersion() const;
00951
00963 void getPdfVersion(int *major, int *minor) const;
00964
00976 QList<FontInfo> fonts() const;
00977
00996 Q_DECL_DEPRECATED bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const;
00997
01013 FontIterator* newFontIterator( int startPage = 0 ) const;
01014
01020 QByteArray fontData(const FontInfo &font) const;
01021
01028 QList<EmbeddedFile*> embeddedFiles() const;
01029
01033 bool hasEmbeddedFiles() const;
01034
01058 QDomDocument *toc() const;
01059
01068 LinkDestination *linkDestination( const QString &name );
01069
01075 void setPaperColor(const QColor &color);
01081 QColor paperColor() const;
01082
01090 void setRenderBackend( RenderBackend backend );
01098 RenderBackend renderBackend() const;
01099
01105 static QSet<RenderBackend> availableRenderBackends();
01106
01116 void setRenderHint( RenderHint hint, bool on = true );
01122 RenderHints renderHints() const;
01123
01131 PSConverter *psConverter() const;
01132
01140 PDFConverter *pdfConverter() const;
01141
01147 QString metadata() const;
01148
01161 bool hasOptionalContent() const;
01162
01170 OptContentModel *optionalContentModel();
01171
01180 QStringList scripts() const;
01181
01185 ~Document();
01186
01187 private:
01188 Q_DISABLE_COPY(Document)
01189
01190 DocumentData *m_doc;
01191
01192 Document(DocumentData *dataA);
01193 };
01194
01195 class BaseConverterPrivate;
01196 class PSConverterPrivate;
01197 class PDFConverterPrivate;
01205 class POPPLER_QT4_EXPORT BaseConverter
01206 {
01207 friend class Document;
01208 public:
01212 virtual ~BaseConverter();
01213
01215 void setOutputFileName(const QString &outputFileName);
01216
01222 void setOutputDevice(QIODevice *device);
01223
01229 virtual bool convert() = 0;
01230
01231 enum Error
01232 {
01233 NoError,
01234 FileLockedError,
01235 OpenOutputError,
01236 NotSupportedInputFileError
01237 };
01238
01243 Error lastError() const;
01244
01245 protected:
01247 BaseConverter(BaseConverterPrivate &dd);
01248 Q_DECLARE_PRIVATE(BaseConverter)
01249 BaseConverterPrivate *d_ptr;
01251
01252 private:
01253 Q_DISABLE_COPY(BaseConverter)
01254 };
01255
01272 class POPPLER_QT4_EXPORT PSConverter : public BaseConverter
01273 {
01274 friend class Document;
01275 public:
01281 enum PSOption {
01282 Printing = 0x00000001,
01283 StrictMargins = 0x00000002,
01284 ForceRasterization = 0x00000004
01285 };
01286 Q_DECLARE_FLAGS( PSOptions, PSOption )
01287
01288
01291 ~PSConverter();
01292
01294 void setPageList(const QList<int> &pageList);
01295
01299 void setTitle(const QString &title);
01300
01304 void setHDPI(double hDPI);
01305
01309 void setVDPI(double vDPI);
01310
01314 void setRotate(int rotate);
01315
01319 void setPaperWidth(int paperWidth);
01320
01324 void setPaperHeight(int paperHeight);
01325
01329 void setRightMargin(int marginRight);
01330
01334 void setBottomMargin(int marginBottom);
01335
01339 void setLeftMargin(int marginLeft);
01340
01344 void setTopMargin(int marginTop);
01345
01353 void setStrictMargins(bool strictMargins);
01354
01356 void setForceRasterize(bool forceRasterize);
01357
01363 void setPSOptions(PSOptions options);
01371 PSOptions psOptions() const;
01372
01373 bool convert();
01374
01375 private:
01376 Q_DECLARE_PRIVATE(PSConverter)
01377 Q_DISABLE_COPY(PSConverter)
01378
01379 PSConverter(DocumentData *document);
01380 };
01381
01387 class POPPLER_QT4_EXPORT PDFConverter : public BaseConverter
01388 {
01389 friend class Document;
01390 public:
01394 enum PDFOption {
01395 WithChanges = 0x00000001
01396 };
01397 Q_DECLARE_FLAGS( PDFOptions, PDFOption )
01398
01399
01402 virtual ~PDFConverter();
01403
01407 void setPDFOptions(PDFOptions options);
01411 PDFOptions pdfOptions() const;
01412
01413 bool convert();
01414
01415 private:
01416 Q_DECLARE_PRIVATE(PDFConverter)
01417 Q_DISABLE_COPY(PDFConverter)
01418
01419 PDFConverter(DocumentData *document);
01420 };
01421
01425 POPPLER_QT4_EXPORT QDateTime convertDate( char *dateString );
01426
01432 POPPLER_QT4_EXPORT bool isCmsAvailable();
01433
01434 class SoundData;
01444 class POPPLER_QT4_EXPORT SoundObject {
01445 public:
01449 enum SoundType {
01450 External,
01451 Embedded
01452 };
01453
01457 enum SoundEncoding {
01458 Raw,
01459 Signed,
01460 muLaw,
01461 ALaw
01462 };
01463
01465 SoundObject(Sound *popplersound);
01467
01468 ~SoundObject();
01469
01473 SoundType soundType() const;
01474
01478 QString url() const;
01479
01483 QByteArray data() const;
01484
01488 double samplingRate() const;
01489
01493 int channels() const;
01494
01498 int bitsPerSample() const;
01499
01503 SoundEncoding soundEncoding() const;
01504
01505 private:
01506 Q_DISABLE_COPY(SoundObject)
01507
01508 SoundData *m_soundData;
01509 };
01510
01511 class MovieData;
01517 class POPPLER_QT4_EXPORT MovieObject {
01518 friend class Page;
01519 public:
01523 enum PlayMode {
01524 PlayOnce,
01525 PlayOpen,
01526 PlayRepeat,
01527 PlayPalindrome
01528 };
01529
01530 ~MovieObject();
01531
01535 QString url() const;
01536
01540 QSize size() const;
01541
01545 int rotation() const;
01546
01550 bool showControls() const;
01551
01555 PlayMode playMode() const;
01556
01557 private:
01559 MovieObject( AnnotMovie *ann );
01561
01562 Q_DISABLE_COPY(MovieObject)
01563
01564 MovieData *m_movieData;
01565 };
01566
01567 }
01568
01569 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints)
01570 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions)
01571 Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions)
01572
01573 #endif