~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/poppler/qt4/src/poppler-qt4.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* poppler-qt.h: qt interface to poppler
 
2
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 
3
 * Copyright (C) 2005, 2007, Brad Hards <bradh@frogmouth.net>
 
4
 * Copyright (C) 2005-2010, Albert Astals Cid <aacid@kde.org>
 
5
 * Copyright (C) 2005, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de>
 
6
 * Copyright (C) 2006-2010, Pino Toscano <pino@kde.org>
 
7
 * Copyright (C) 2009 Shawn Rutledge <shawn.t.rutledge@gmail.com>
 
8
 * Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
9
 * Copyright (C) 2010 Matthias Fauconneau <matthias.fauconneau@gmail.com>
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2, or (at your option)
 
14
 * any later version.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; if not, write to the Free Software
 
23
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
24
 */
 
25
 
 
26
#ifndef __POPPLER_QT_H__
 
27
#define __POPPLER_QT_H__
 
28
 
 
29
#include "poppler-annotation.h"
 
30
#include "poppler-link.h"
 
31
#include "poppler-optcontent.h"
 
32
#include "poppler-page-transition.h"
 
33
 
 
34
#include <QtCore/QByteArray>
 
35
#include <QtCore/QDateTime>
 
36
#include <QtCore/QSet>
 
37
#include <QtXml/QDomDocument>
 
38
#include "poppler-export.h"
 
39
 
 
40
class EmbFile;
 
41
class Sound;
 
42
class AnnotMovie;
 
43
 
 
44
/**
 
45
   The %Poppler Qt4 binding.
 
46
*/
 
47
namespace Poppler {
 
48
 
 
49
    class Document;
 
50
    class DocumentData;
 
51
 
 
52
    class PageData;
 
53
 
 
54
    class FormField;
 
55
 
 
56
    class TextBoxData;
 
57
 
 
58
    class PDFConverter;
 
59
    class PSConverter;
 
60
 
 
61
    /**
 
62
        Debug/error function.
 
63
 
 
64
        This function type is used for debugging & error output;
 
65
        the first parameter is the actual message, the second is the unaltered
 
66
        closure argument which was passed to the setDebugErrorFunction call.
 
67
 
 
68
        \since 0.16
 
69
    */
 
70
    typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/);
 
71
 
 
72
    /**
 
73
        Set a new debug/error output function.
 
74
 
 
75
        If not set, by default error and debug messages will be sent to the
 
76
        Qt \p qDebug() function.
 
77
 
 
78
        \param debugFunction the new debug function
 
79
        \param closure user data which will be passes as-is to the debug function
 
80
 
 
81
        \since 0.16
 
82
    */
 
83
    POPPLER_QT4_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure);
 
84
 
 
85
    /**
 
86
        Describes the physical location of text on a document page
 
87
       
 
88
        This very simple class describes the physical location of text
 
89
        on the page. It consists of
 
90
        - a QString that contains the text
 
91
        - a QRectF that gives a box that describes where on the page
 
92
        the text is found.
 
93
    */
 
94
    class POPPLER_QT4_EXPORT TextBox {
 
95
    friend class Page;
 
96
    public:
 
97
      /**
 
98
         The default constructor sets the \p text and the rectangle that
 
99
         contains the text. Coordinated for the \p bBox are in points =
 
100
         1/72 of an inch.
 
101
      */
 
102
      TextBox(const QString& text, const QRectF &bBox);
 
103
      /**
 
104
        Destructor.
 
105
      */
 
106
      ~TextBox();
 
107
 
 
108
      /**
 
109
          Returns the text of this text box
 
110
      */
 
111
      QString text() const;
 
112
 
 
113
      /**
 
114
          Returns the position of the text, in point, i.e., 1/72 of
 
115
         an inch
 
116
 
 
117
         \since 0.8
 
118
      */
 
119
      QRectF boundingBox() const;
 
120
 
 
121
      /**
 
122
          Returns the pointer to the next text box, if there is one.
 
123
 
 
124
          Otherwise, it returns a null pointer.
 
125
      */
 
126
      TextBox *nextWord() const;
 
127
 
 
128
      /**
 
129
          Returns the bounding box of the \p i -th characted of the word.
 
130
      */
 
131
      QRectF charBoundingBox(int i) const;
 
132
 
 
133
      /**
 
134
          Returns whether there is a space character after this text box
 
135
      */
 
136
      bool hasSpaceAfter() const;
 
137
 
 
138
    private:
 
139
        Q_DISABLE_COPY(TextBox)
 
140
 
 
141
        TextBoxData *m_data;
 
142
    };
 
143
 
 
144
 
 
145
    class FontInfoData;
 
146
    /**
 
147
       Container class for information about a font within a PDF
 
148
       document
 
149
    */
 
150
    class POPPLER_QT4_EXPORT FontInfo {
 
151
    friend class Document;
 
152
    public:
 
153
        /**
 
154
           The type of font.
 
155
        */
 
156
        enum Type {
 
157
                unknown,
 
158
                Type1,
 
159
                Type1C,
 
160
                Type1COT,
 
161
                Type3,
 
162
                TrueType,
 
163
                TrueTypeOT,
 
164
                CIDType0,
 
165
                CIDType0C,
 
166
                CIDType0COT,
 
167
                CIDTrueType,
 
168
                CIDTrueTypeOT
 
169
        };
 
170
        
 
171
        /// \cond PRIVATE
 
172
        /**
 
173
           Create a new font information container.
 
174
        */
 
175
        FontInfo();
 
176
        
 
177
        /**
 
178
           Create a new font information container.
 
179
        */
 
180
        FontInfo( const FontInfoData &fid );
 
181
        /// \endcond
 
182
        
 
183
        /**
 
184
           Copy constructor.
 
185
        */
 
186
        FontInfo( const FontInfo &fi );
 
187
        
 
188
        /**
 
189
           Destructor.
 
190
        */
 
191
        ~FontInfo();
 
192
 
 
193
        /**
 
194
           The name of the font. Can be QString::null if the font has no name
 
195
        */
 
196
        QString name() const;
 
197
 
 
198
        /**
 
199
           The path of the font file used to represent this font on this system,
 
200
           or a null string is the font is embedded
 
201
        */
 
202
        QString file() const;
 
203
 
 
204
        /**
 
205
           Whether the font is embedded in the file, or not
 
206
 
 
207
           \return true if the font is embedded
 
208
        */
 
209
        bool isEmbedded() const;
 
210
 
 
211
        /**
 
212
           Whether the font provided is only a subset of the full
 
213
           font or not. This only has meaning if the font is embedded.
 
214
 
 
215
           \return true if the font is only a subset
 
216
        */
 
217
        bool isSubset() const;
 
218
 
 
219
        /**
 
220
           The type of font encoding
 
221
 
 
222
           \return a enumerated value corresponding to the font encoding used
 
223
 
 
224
           \sa typeName for a string equivalent
 
225
        */
 
226
        Type type() const;
 
227
 
 
228
        /**
 
229
           The name of the font encoding used
 
230
 
 
231
           \note if you are looking for the name of the font (as opposed to the
 
232
           encoding format used), you probably want name().
 
233
 
 
234
           \sa type for a enumeration version
 
235
        */
 
236
        QString typeName() const;
 
237
 
 
238
        /**
 
239
           Standard assignment operator
 
240
        */
 
241
        FontInfo& operator=( const FontInfo &fi );
 
242
 
 
243
    private:
 
244
        FontInfoData *m_data;
 
245
    };
 
246
 
 
247
 
 
248
    class FontIteratorData;
 
249
    /**
 
250
       Iterator for reading the fonts in a document.
 
251
 
 
252
       FontIterator provides a Java-style iterator for reading the fonts in a
 
253
       document.
 
254
 
 
255
       You can use it in the following way:
 
256
       \code
 
257
Poppler::FontIterator* it = doc->newFontIterator();
 
258
while (it->hasNext()) {
 
259
  QList<Poppler::FontInfo> fonts = it->next();
 
260
  // do something with the fonts
 
261
}
 
262
// after doing the job, the iterator must be freed
 
263
delete it;
 
264
       \endcode
 
265
 
 
266
       \since 0.12
 
267
    */
 
268
    class POPPLER_QT4_EXPORT FontIterator {
 
269
    friend class Document;
 
270
    friend class DocumentData;
 
271
    public:
 
272
        /**
 
273
           Destructor.
 
274
        */
 
275
        ~FontIterator();
 
276
 
 
277
        /**
 
278
           Returns the fonts of the current page and then advances the iterator
 
279
           to the next page.
 
280
        */
 
281
        QList<FontInfo> next();
 
282
 
 
283
        /**
 
284
           Checks whether there is at least one more page to iterate, ie returns
 
285
           false when the iterator is beyond the last page.
 
286
        */
 
287
        bool hasNext() const;
 
288
 
 
289
        /**
 
290
           Returns the current page where the iterator is.
 
291
        */
 
292
        int currentPage() const;
 
293
 
 
294
    private:
 
295
        Q_DISABLE_COPY( FontIterator )
 
296
        FontIterator( int, DocumentData *dd );
 
297
 
 
298
        FontIteratorData *d;
 
299
    };
 
300
 
 
301
 
 
302
    class EmbeddedFileData;
 
303
    /**
 
304
       Container class for an embedded file with a PDF document
 
305
    */
 
306
    class POPPLER_QT4_EXPORT EmbeddedFile {
 
307
    public:
 
308
        /// \cond PRIVATE
 
309
        EmbeddedFile(EmbFile *embfile);
 
310
        /// \endcond
 
311
        
 
312
        /**
 
313
           Destructor.
 
314
        */
 
315
        ~EmbeddedFile();
 
316
 
 
317
        /**
 
318
           The name associated with the file
 
319
        */
 
320
        QString name() const;
 
321
 
 
322
        /**
 
323
           The description associated with the file, if any.
 
324
 
 
325
           This will return an empty QString if there is no description element
 
326
        */
 
327
        QString description() const;
 
328
 
 
329
        /**
 
330
           The size of the file.
 
331
        
 
332
           This will return < 0 if there is no size element
 
333
        */
 
334
        int size() const;
 
335
 
 
336
        /**
 
337
           The modification date for the embedded file, if known.
 
338
        */
 
339
        QDateTime modDate() const;
 
340
 
 
341
        /**
 
342
           The creation date for the embedded file, if known.
 
343
        */
 
344
        QDateTime createDate() const;
 
345
        
 
346
        /**
 
347
           The MD5 checksum of the file.
 
348
                
 
349
           This will return an empty QByteArray if there is no checksum element.
 
350
        */
 
351
        QByteArray checksum() const;
 
352
 
 
353
        /**
 
354
           The MIME type of the file, if known.
 
355
        
 
356
           \since 0.8
 
357
        */
 
358
        QString mimeType() const;
 
359
 
 
360
        /**
 
361
           The data as a byte array
 
362
        */
 
363
        QByteArray data();
 
364
 
 
365
        /**
 
366
           Is the embedded file valid?
 
367
           
 
368
           \since 0.12
 
369
        */
 
370
        bool isValid() const;
 
371
 
 
372
        /**
 
373
           A QDataStream for the actual data?
 
374
        */
 
375
        //QDataStream dataStream() const;
 
376
 
 
377
    private:
 
378
        Q_DISABLE_COPY(EmbeddedFile)
 
379
 
 
380
        EmbeddedFileData *m_embeddedFile;
 
381
    };
 
382
 
 
383
 
 
384
    /**
 
385
       \brief A page in a document.
 
386
 
 
387
       The Page class represents a single page within a PDF document.
 
388
 
 
389
       You cannot construct a Page directly, but you have to use the Document
 
390
       functions that return a new Page out of an index or a label.
 
391
    */
 
392
    class POPPLER_QT4_EXPORT Page {
 
393
        friend class Document;
 
394
    public:
 
395
        /**
 
396
           Destructor.
 
397
        */
 
398
        ~Page();
 
399
 
 
400
        /**
 
401
           The type of rotation to apply for an operation
 
402
        */
 
403
        enum Rotation { Rotate0 = 0,   ///< Do not rotate
 
404
                        Rotate90 = 1,  ///< Rotate 90 degrees clockwise
 
405
                        Rotate180 = 2, ///< Rotate 180 degrees
 
406
                        Rotate270 = 3  ///< Rotate 270 degrees clockwise (90 degrees counterclockwise)
 
407
        };
 
408
 
 
409
        /**
 
410
           The kinds of page actions
 
411
        */
 
412
        enum PageAction {
 
413
            Opening,   ///< The action when a page is "opened"
 
414
            Closing    ///< The action when a page is "closed"
 
415
        };
 
416
        
 
417
        /**
 
418
           How the text is going to be returned
 
419
           \since 0.16
 
420
        */
 
421
        enum TextLayout {
 
422
            PhysicalLayout,   ///< The text is layouted to resemble the real page layout
 
423
            RawOrderLayout          ///< The text is returned without any type of processing
 
424
        };
 
425
 
 
426
        /**
 
427
           Additional flags for the renderToPainter method
 
428
           \since 0.16
 
429
        */
 
430
        enum PainterFlag {
 
431
            /**
 
432
               Do not save/restore the caller-owned painter.
 
433
 
 
434
               renderToPainter() by default preserves, using save() + restore(),
 
435
               the state of the painter specified; if this is not needed, this
 
436
               flag can avoid this job
 
437
             */
 
438
            DontSaveAndRestore = 0x00000001
 
439
        };
 
440
        Q_DECLARE_FLAGS( PainterFlags, PainterFlag )
 
441
 
 
442
        /** 
 
443
           Render the page to a QImage using the current
 
444
           \link Document::renderBackend() Document renderer\endlink.
 
445
           
 
446
           If \p x = \p y = \p w = \p h = -1, the method will automatically
 
447
           compute the size of the image from the horizontal and vertical
 
448
           resolutions specified in \p xres and \p yres. Otherwise, the
 
449
           method renders only a part of the page, specified by the
 
450
           parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned
 
451
           QImage then has size (\p w, \p h), independent of the page
 
452
           size.
 
453
 
 
454
           \param x specifies the left x-coordinate of the box, in
 
455
           pixels.
 
456
 
 
457
           \param y specifies the top y-coordinate of the box, in
 
458
           pixels.
 
459
 
 
460
           \param w specifies the width of the box, in pixels.
 
461
 
 
462
           \param h specifies the height of the box, in pixels.
 
463
 
 
464
           \param xres horizontal resolution of the graphics device,
 
465
           in dots per inch
 
466
 
 
467
           \param yres vertical resolution of the graphics device, in
 
468
           dots per inch
 
469
        
 
470
           \param rotate how to rotate the page
 
471
 
 
472
           \warning The parameter (\p x, \p y, \p w, \p h) are not
 
473
           well-tested. Unusual or meaningless parameters may lead to
 
474
           rather unexpected results.
 
475
 
 
476
           \returns a QImage of the page, or a null image on failure.
 
477
 
 
478
           \since 0.6
 
479
        */
 
480
        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;
 
481
 
 
482
        /**
 
483
           Render the page to the specified QPainter using the current
 
484
           \link Document::renderBackend() Document renderer\endlink.
 
485
 
 
486
           If \p x = \p y = \p w = \p h = -1, the method will automatically
 
487
           compute the size of the page area from the horizontal and vertical
 
488
           resolutions specified in \p xres and \p yres. Otherwise, the
 
489
           method renders only a part of the page, specified by the
 
490
           parameters (\p x, \p y, \p w, \p h) in pixel coordinates.
 
491
 
 
492
           \param painter the painter to paint on
 
493
 
 
494
           \param x specifies the left x-coordinate of the box, in
 
495
           pixels.
 
496
 
 
497
           \param y specifies the top y-coordinate of the box, in
 
498
           pixels.
 
499
 
 
500
           \param w specifies the width of the box, in pixels.
 
501
 
 
502
           \param h specifies the height of the box, in pixels.
 
503
 
 
504
           \param xres horizontal resolution of the graphics device,
 
505
           in dots per inch
 
506
 
 
507
           \param yres vertical resolution of the graphics device, in
 
508
           dots per inch
 
509
 
 
510
           \param rotate how to rotate the page
 
511
 
 
512
           \param flags additional painter flags
 
513
 
 
514
           \warning The parameter (\p x, \p y, \p w, \p h) are not
 
515
           well-tested. Unusual or meaningless parameters may lead to
 
516
           rather unexpected results.
 
517
 
 
518
           \returns whether the painting succeeded
 
519
 
 
520
           \note This method is only supported for Arthur
 
521
 
 
522
           \since 0.16
 
523
        */
 
524
        bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1,
 
525
                             Rotation rotate = Rotate0, PainterFlags flags = 0) const;
 
526
 
 
527
        /**
 
528
           Get the page thumbnail if it exists.
 
529
 
 
530
           \return a QImage of the thumbnail, or a null image
 
531
           if the PDF does not contain one for this page
 
532
 
 
533
           \since 0.12
 
534
        */
 
535
        QImage thumbnail() const;
 
536
 
 
537
        /**
 
538
           Returns the text that is inside a specified rectangle
 
539
 
 
540
           \param rect the rectangle specifying the area of interest,
 
541
           with coordinates given in points, i.e., 1/72th of an inch.
 
542
           If rect is null, all text on the page is given
 
543
        
 
544
           \since 0.16
 
545
        **/
 
546
        QString text(const QRectF &rect, TextLayout textLayout) const;
 
547
 
 
548
        /**
 
549
           Returns the text that is inside a specified rectangle.
 
550
           The text is returned using the physical layout of the page
 
551
 
 
552
           \param rect the rectangle specifying the area of interest,
 
553
           with coordinates given in points, i.e., 1/72th of an inch.
 
554
           If rect is null, all text on the page is given
 
555
        **/
 
556
        QString text(const QRectF &rect) const;
 
557
        
 
558
        /**
 
559
           The starting point for a search
 
560
        */
 
561
        enum SearchDirection { FromTop,        ///< Start sorting at the top of the document
 
562
                               NextResult,     ///< Find the next result, moving "down the page"
 
563
                               PreviousResult  ///< Find the previous result, moving "up the page"
 
564
        };
 
565
 
 
566
        /**
 
567
           The type of search to perform
 
568
        */
 
569
        enum SearchMode { CaseSensitive,   ///< Case differences cause no match in searching
 
570
                          CaseInsensitive  ///< Case differences are ignored in matching
 
571
        };
 
572
        
 
573
        /**
 
574
           Returns true if the specified text was found.
 
575
 
 
576
           \param text the text the search
 
577
           \param rect in all directions is used to return where the text was found, for NextResult and PreviousResult
 
578
                       indicates where to continue searching for
 
579
           \param direction in which direction do the search
 
580
           \param caseSensitive be case sensitive?
 
581
           \param rotate the rotation to apply for the search order
 
582
        **/
 
583
        Q_DECL_DEPRECATED bool search(const QString &text, QRectF &rect, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const;
 
584
        
 
585
        /**
 
586
           Returns true if the specified text was found.
 
587
 
 
588
           \param text the text the search
 
589
           \param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult
 
590
                       indicates where to continue searching for
 
591
           \param direction in which direction do the search
 
592
           \param caseSensitive be case sensitive?
 
593
           \param rotate the rotation to apply for the search order
 
594
           \since 0.14
 
595
        **/
 
596
        bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const;
 
597
 
 
598
        /**
 
599
           Returns a list of text of the page
 
600
 
 
601
           This method returns a QList of TextBoxes that contain all
 
602
           the text of the page, with roughly one text word of text
 
603
           per TextBox item.
 
604
           
 
605
           For text written in western languages (left-to-right and
 
606
           up-to-down), the QList contains the text in the proper
 
607
           order.
 
608
 
 
609
           \note The caller owns the text boxes and they should
 
610
                 be deleted when no longer required.
 
611
 
 
612
           \warning This method is not tested with Asian scripts
 
613
        */
 
614
        QList<TextBox*> textList(Rotation rotate = Rotate0) const;
 
615
 
 
616
        /**
 
617
           \return The dimensions (cropbox) of the page, in points (i.e. 1/72th on an inch)
 
618
        */
 
619
        QSizeF pageSizeF() const;
 
620
 
 
621
        /**
 
622
           \return The dimensions (cropbox) of the page, in points (i.e. 1/72th on an inch)
 
623
        */
 
624
        QSize pageSize() const;
 
625
 
 
626
        /**
 
627
          Returns the transition of this page
 
628
 
 
629
          \returns a pointer to a PageTransition structure that
 
630
          defines how transition to this page shall be performed.
 
631
 
 
632
          \note The PageTransition structure is owned by this page, and will
 
633
          automatically be destroyed when this page class is
 
634
          destroyed.
 
635
        **/
 
636
        PageTransition *transition() const;
 
637
        
 
638
        /**
 
639
          Gets the page action specified, or NULL if there is no action.
 
640
 
 
641
          \since 0.6
 
642
        **/
 
643
        Link *action( PageAction act ) const;
 
644
        
 
645
        /**
 
646
           Types of orientations that are possible
 
647
        */
 
648
        enum Orientation {
 
649
            Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation )
 
650
            Portrait, ///< Normal portrait orientation
 
651
            Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation)
 
652
            UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation)
 
653
        };
 
654
 
 
655
        /**
 
656
           The orientation of the page
 
657
        */
 
658
        Orientation orientation() const;
 
659
        
 
660
        /**
 
661
          The default CTM
 
662
        */
 
663
        void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown);
 
664
        
 
665
        /**
 
666
          Gets the links of the page
 
667
        */
 
668
        QList<Link*> links() const;
 
669
        
 
670
        /**
 
671
         Returns the annotations of the page
 
672
        */
 
673
        QList<Annotation*> annotations() const;
 
674
 
 
675
        /**
 
676
         Returns the form fields on the page
 
677
 
 
678
         \since 0.6
 
679
        */
 
680
        QList<FormField*> formFields() const;
 
681
 
 
682
        /**
 
683
         Returns the page duration. That is the time, in seconds, that the page
 
684
         should be displayed before the presentation automatically advances to the next page.
 
685
         Returns < 0 if duration is not set.
 
686
 
 
687
         \since 0.6
 
688
        */
 
689
        double duration() const;
 
690
        
 
691
        /**
 
692
           Returns the label of the page, or a null string is the page has no label.
 
693
 
 
694
         \since 0.6
 
695
        **/
 
696
        QString label() const;
 
697
        
 
698
    private:
 
699
        Q_DISABLE_COPY(Page)
 
700
 
 
701
        Page(DocumentData *doc, int index);
 
702
        PageData *m_page;
 
703
    };
 
704
 
 
705
/**
 
706
   \brief PDF document.
 
707
 
 
708
   The Document class represents a PDF document: its pages, and all the global
 
709
   properties, metadata, etc.
 
710
 
 
711
   \section ownership Ownership of the returned objects
 
712
 
 
713
   All the functions that returns class pointers create new object, and the
 
714
   responsability of those is given to the callee.
 
715
 
 
716
   The only exception is \link Poppler::Page::transition() Page::transition()\endlink.
 
717
 
 
718
   \section document-loading Loading
 
719
 
 
720
   To get a Document, you have to load it via the load() & loadFromData()
 
721
   functions.
 
722
 
 
723
   In all the functions that have passwords as arguments, they \b must be Latin1
 
724
   encoded. If you have a password that is a UTF-8 string, you need to use
 
725
   QString::toLatin1() (or similar) to convert the password first.
 
726
   If you have a UTF-8 character array, consider converting it to a QString first
 
727
   (QString::fromUtf8(), or similar) before converting to Latin1 encoding.
 
728
 
 
729
   \section document-rendering Rendering
 
730
 
 
731
   To render pages of a document, you have different Document functions to set
 
732
   various options.
 
733
 
 
734
   \subsection document-rendering-backend Backends
 
735
 
 
736
   %Poppler offers a different backends for rendering the pages. Currently
 
737
   there are two backends (see #RenderBackend), but only the Splash engine works
 
738
   well and has been tested.
 
739
 
 
740
   The available rendering backends can be discovered via availableRenderBackends().
 
741
   The current rendering backend can be changed using setRenderBackend().
 
742
   Please note that setting a backend not listed in the available ones
 
743
   will always result in null QImage's.
 
744
 
 
745
   \section document-cms Color management support
 
746
 
 
747
   %Poppler, if compiled with this support, provides functions to handle color
 
748
   profiles.
 
749
 
 
750
   To know whether the %Poppler version you are using has support for color
 
751
   management, you can query Poppler::isCmsAvailable(). In case it is not
 
752
   avilable, all the color management-related functions will either do nothing
 
753
   or return null.
 
754
*/
 
755
    class POPPLER_QT4_EXPORT Document {
 
756
        friend class Page;
 
757
        friend class DocumentData;
 
758
  
 
759
    public:
 
760
        /**
 
761
           The page mode
 
762
        */
 
763
        enum PageMode {
 
764
            UseNone,     ///< No mode - neither document outline nor thumbnail images are visible
 
765
            UseOutlines, ///< Document outline visible
 
766
            UseThumbs,   ///< Thumbnail images visible
 
767
            FullScreen,  ///< Fullscreen mode (no menubar, windows controls etc)
 
768
            UseOC,       ///< Optional content group panel visible
 
769
            UseAttach    ///< Attachments panel visible
 
770
        };
 
771
  
 
772
        /**
 
773
           The page layout
 
774
        */
 
775
        enum PageLayout {
 
776
            NoLayout,   ///< Layout not specified
 
777
            SinglePage, ///< Display a single page
 
778
            OneColumn,  ///< Display a single column of pages
 
779
            TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left
 
780
            TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right
 
781
            TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left
 
782
            TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right
 
783
        };
 
784
 
 
785
        /**
 
786
           The render backends available
 
787
 
 
788
           \since 0.6
 
789
        */
 
790
        enum RenderBackend {
 
791
            SplashBackend,   ///< Splash backend
 
792
            ArthurBackend   ///< Arthur (Qt4) backend
 
793
        };
 
794
 
 
795
        /**
 
796
           The render hints available
 
797
 
 
798
           \since 0.6
 
799
        */
 
800
        enum RenderHint {
 
801
            Antialiasing = 0x00000001,      ///< Antialiasing for graphics
 
802
            TextAntialiasing = 0x00000002,  ///< Antialiasing for text
 
803
            TextHinting = 0x00000004        ///< Hinting for text \since 0.12.1
 
804
        };
 
805
        Q_DECLARE_FLAGS( RenderHints, RenderHint )
 
806
 
 
807
        /**
 
808
          Set a color display profile for the current document.
 
809
 
 
810
          \param outputProfileA is a \c cmsHPROFILE of the LCMS library.
 
811
 
 
812
           \since 0.12
 
813
        */
 
814
        void setColorDisplayProfile(void *outputProfileA);
 
815
        /**
 
816
          Set a color display profile for the current document.
 
817
 
 
818
          \param name is the name of the display profile to set.
 
819
 
 
820
           \since 0.12
 
821
        */
 
822
        void setColorDisplayProfileName(const QString &name);
 
823
        /**
 
824
          Return the current RGB profile.
 
825
 
 
826
          \return a \c cmsHPROFILE of the LCMS library.
 
827
 
 
828
           \since 0.12
 
829
        */
 
830
        void* colorRgbProfile() const;
 
831
        /**
 
832
          Return the current display profile.
 
833
 
 
834
          \return a \c cmsHPROFILE of the LCMS library.
 
835
 
 
836
           \since 0.12
 
837
        */
 
838
        void *colorDisplayProfile() const;
 
839
 
 
840
        /**
 
841
           Load the document from a file on disk
 
842
 
 
843
           \param filePath the name (and path, if required) of the file to load
 
844
           \param ownerPassword the Latin1-encoded owner password to use in
 
845
           loading the file
 
846
           \param userPassword the Latin1-encoded user ("open") password
 
847
           to use in loading the file
 
848
 
 
849
           \return the loaded document, or NULL on error
 
850
 
 
851
           \note The caller owns the pointer to Document, and this should
 
852
           be deleted when no longer required.
 
853
        
 
854
           \warning The returning document may be locked if a password is required
 
855
           to open the file, and one is not provided (as the userPassword).
 
856
        */
 
857
        static Document *load(const QString & filePath,
 
858
                              const QByteArray &ownerPassword=QByteArray(),
 
859
                              const QByteArray &userPassword=QByteArray());
 
860
        
 
861
        /**
 
862
           Load the document from memory
 
863
 
 
864
           \param fileContents the file contents. They are copied so there is no need 
 
865
                               to keep the byte array around for the full life time of 
 
866
                               the document.
 
867
           \param ownerPassword the Latin1-encoded owner password to use in
 
868
           loading the file
 
869
           \param userPassword the Latin1-encoded user ("open") password
 
870
           to use in loading the file
 
871
 
 
872
           \return the loaded document, or NULL on error
 
873
 
 
874
           \note The caller owns the pointer to Document, and this should
 
875
           be deleted when no longer required.
 
876
        
 
877
           \warning The returning document may be locked if a password is required
 
878
           to open the file, and one is not provided (as the userPassword).
 
879
 
 
880
           \since 0.6
 
881
        */
 
882
        static Document *loadFromData(const QByteArray &fileContents,
 
883
                              const QByteArray &ownerPassword=QByteArray(),
 
884
                              const QByteArray &userPassword=QByteArray());
 
885
  
 
886
        /**
 
887
           Get a specified Page
 
888
     
 
889
           Note that this follows the PDF standard of being zero based - if you
 
890
           want the first page, then you need an index of zero.
 
891
        
 
892
           The caller gets the ownership of the returned object.
 
893
 
 
894
           \param index the page number index
 
895
        */
 
896
        Page *page(int index) const;
 
897
 
 
898
        /**
 
899
           \overload
 
900
 
 
901
 
 
902
           The intent is that you can pass in a label like \c "ix" and
 
903
           get the page with that label (which might be in the table of
 
904
           contents), or pass in \c "1" and get the page that the user
 
905
           expects (which might not be the first page, if there is a
 
906
           title page and a table of contents).
 
907
 
 
908
           \param label the page label
 
909
        */
 
910
        Page *page(const QString &label) const;
 
911
 
 
912
        /**
 
913
           The number of pages in the document
 
914
        */
 
915
        int numPages() const;
 
916
  
 
917
        /**
 
918
           The type of mode that should be used by the application
 
919
           when the document is opened. Note that while this is 
 
920
           called page mode, it is really viewer application mode.
 
921
        */
 
922
        PageMode pageMode() const;
 
923
 
 
924
        /**
 
925
           The layout that pages should be shown in when the document
 
926
           is first opened.  This basically describes how pages are
 
927
           shown relative to each other.
 
928
        */
 
929
        PageLayout pageLayout() const;
 
930
 
 
931
        /**
 
932
           Provide the passwords required to unlock the document
 
933
 
 
934
           \param ownerPassword the Latin1-encoded owner password to use in
 
935
           loading the file
 
936
           \param userPassword the Latin1-encoded user ("open") password
 
937
           to use in loading the file
 
938
        */
 
939
        bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword);
 
940
 
 
941
        /**
 
942
           Determine if the document is locked
 
943
        */
 
944
        bool isLocked() const;
 
945
 
 
946
        /**
 
947
           The date associated with the document
 
948
 
 
949
           You would use this method with something like:
 
950
           \code
 
951
QDateTime created = m_doc->date("CreationDate");
 
952
QDateTime modified = m_doc->date("ModDate");
 
953
           \endcode
 
954
 
 
955
           The available dates are:
 
956
           - CreationDate: the date of creation of the document
 
957
           - ModDate: the date of the last change in the document
 
958
 
 
959
           \param data the type of date that is required
 
960
        */
 
961
        QDateTime date( const QString & data ) const;
 
962
 
 
963
        /**
 
964
           Get specified information associated with the document
 
965
 
 
966
           You would use this method with something like:
 
967
           \code
 
968
QString title = m_doc->info("Title");
 
969
QString subject = m_doc->info("Subject");
 
970
           \endcode
 
971
 
 
972
           In addition to \c Title and \c Subject, other information that may
 
973
           be available include \c Author, \c Keywords, \c Creator and \c Producer.
 
974
 
 
975
           \param data the information that is required
 
976
 
 
977
           \sa infoKeys() to get a list of the available keys
 
978
        */
 
979
        QString info( const QString & data ) const;
 
980
 
 
981
        /**
 
982
           Obtain a list of the available string information keys.
 
983
        */
 
984
        QStringList infoKeys() const;
 
985
 
 
986
        /**
 
987
           Test if the document is encrypted
 
988
        */
 
989
        bool isEncrypted() const;
 
990
 
 
991
        /**
 
992
           Test if the document is linearised
 
993
 
 
994
           In some cases, this is called "fast web view", since it
 
995
           is mostly an optimisation for viewing over the Web.
 
996
        */
 
997
        bool isLinearized() const;
 
998
 
 
999
        /**
 
1000
           Test if the permissions on the document allow it to be
 
1001
           printed
 
1002
        */
 
1003
        bool okToPrint() const;
 
1004
 
 
1005
        /**
 
1006
           Test if the permissions on the document allow it to be
 
1007
           printed at high resolution
 
1008
        */
 
1009
        bool okToPrintHighRes() const;
 
1010
 
 
1011
        /**
 
1012
           Test if the permissions on the document allow it to be
 
1013
           changed.
 
1014
 
 
1015
           \note depending on the type of change, it may be more
 
1016
           appropriate to check other properties as well.
 
1017
        */
 
1018
        bool okToChange() const;
 
1019
 
 
1020
        /**
 
1021
           Test if the permissions on the document allow the
 
1022
           contents to be copied / extracted
 
1023
        */
 
1024
        bool okToCopy() const;
 
1025
 
 
1026
        /**
 
1027
           Test if the permissions on the document allow annotations
 
1028
           to be added or modified, and interactive form fields (including
 
1029
           signature fields) to be completed.
 
1030
        */
 
1031
        bool okToAddNotes() const;
 
1032
 
 
1033
        /**
 
1034
           Test if the permissions on the document allow interactive
 
1035
           form fields (including signature fields) to be completed.
 
1036
 
 
1037
           \note this can be true even if okToAddNotes() is false - this
 
1038
           means that only form completion is permitted.
 
1039
        */
 
1040
        bool okToFillForm() const;
 
1041
 
 
1042
        /**
 
1043
           Test if the permissions on the document allow interactive
 
1044
           form fields (including signature fields) to be set, created and
 
1045
           modified
 
1046
        */
 
1047
        bool okToCreateFormFields() const;
 
1048
 
 
1049
        /**
 
1050
           Test if the permissions on the document allow content extraction
 
1051
           (text and perhaps other content) for accessibility usage (eg for
 
1052
           a screen reader)
 
1053
        */
 
1054
        bool okToExtractForAccessibility() const;
 
1055
 
 
1056
        /**
 
1057
           Test if the permissions on the document allow it to be
 
1058
           "assembled" - insertion, rotation and deletion of pages;
 
1059
           or creation of bookmarks and thumbnail images.
 
1060
 
 
1061
           \note this can be true even if okToChange() is false
 
1062
        */
 
1063
        bool okToAssemble() const;
 
1064
 
 
1065
        /**
 
1066
           The version of the PDF specification that the document
 
1067
           conforms to
 
1068
 
 
1069
           \deprecated use getPdfVersion and avoid float point
 
1070
           comparisons/handling
 
1071
        */
 
1072
        Q_DECL_DEPRECATED double pdfVersion() const;
 
1073
 
 
1074
        /**
 
1075
           The version of the PDF specification that the document
 
1076
           conforms to
 
1077
 
 
1078
           \param major an optional pointer to a variable where store the
 
1079
           "major" number of the version
 
1080
           \param minor an optional pointer to a variable where store the
 
1081
           "minor" number of the version
 
1082
 
 
1083
           \since 0.12
 
1084
        */
 
1085
        void getPdfVersion(int *major, int *minor) const;
 
1086
  
 
1087
        /**
 
1088
           The fonts within the PDF document.
 
1089
 
 
1090
           This is a shorthand for getting all the fonts at once.
 
1091
 
 
1092
           \note this can take a very long time to run with a large
 
1093
           document. You may wish to use a FontIterator if you have more
 
1094
           than say 20 pages
 
1095
 
 
1096
           \see newFontIterator()
 
1097
        */
 
1098
        QList<FontInfo> fonts() const;
 
1099
 
 
1100
        /**
 
1101
           Scans for fonts within the PDF document.
 
1102
 
 
1103
           \param numPages the number of pages to scan
 
1104
           \param fontList pointer to the list where the font information
 
1105
           should be placed
 
1106
 
 
1107
           \note with this method you can scan for fonts only \em once for each
 
1108
           document; once the end is reached, no more scanning with this method
 
1109
           can be done
 
1110
 
 
1111
           \return false if the end of the document has been reached
 
1112
 
 
1113
           \deprecated this function is quite limited in its job (see note),
 
1114
           better use fonts() or newFontIterator()
 
1115
 
 
1116
           \see fonts(), newFontIterator()
 
1117
        */
 
1118
        Q_DECL_DEPRECATED bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const;
 
1119
 
 
1120
        /**
 
1121
           Creates a new FontIterator object for font scanning.
 
1122
 
 
1123
           The new iterator can be used for reading the font information of the
 
1124
           document, reading page by page.
 
1125
 
 
1126
           The caller is responsible for the returned object, ie it should freed
 
1127
           it when no more useful.
 
1128
 
 
1129
           \param startPage the initial page from which start reading fonts
 
1130
 
 
1131
           \see fonts()
 
1132
 
 
1133
           \since 0.12
 
1134
        */
 
1135
        FontIterator* newFontIterator( int startPage = 0 ) const;
 
1136
 
 
1137
        /**
 
1138
           The font data if the font is an embedded one.
 
1139
 
 
1140
           \since 0.10
 
1141
        */
 
1142
        QByteArray fontData(const FontInfo &font) const;
 
1143
 
 
1144
        /**
 
1145
           The documents embedded within the PDF document.
 
1146
 
 
1147
           \note there are two types of embedded document - this call
 
1148
           only accesses documents that are embedded at the document level.
 
1149
        */
 
1150
        QList<EmbeddedFile*> embeddedFiles() const;
 
1151
 
 
1152
        /**
 
1153
           Whether there are any documents embedded in this PDF document.
 
1154
        */
 
1155
        bool hasEmbeddedFiles() const;
 
1156
        
 
1157
        /**
 
1158
          Gets the table of contents (TOC) of the Document.
 
1159
        
 
1160
          The caller is responsable for the returned object.
 
1161
        
 
1162
          In the tree the tag name is the 'screen' name of the entry. A tag can have
 
1163
          attributes. Here follows the list of tag attributes with meaning:
 
1164
          - Destination: A string description of the referred destination
 
1165
          - DestinationName: A 'named reference' to the viewport
 
1166
          - ExternalFileName: A link to a external filename
 
1167
          - Open: A bool value that tells whether the subbranch of the item is open or not
 
1168
        
 
1169
          Resolving the final destination for each item can be done in the following way:
 
1170
          - first, checking for 'Destination': if not empty, then a LinkDestination
 
1171
            can be constructed straight with it
 
1172
          - as second step, if the 'DestinationName' is not empty, then the destination
 
1173
            can be resolved using linkDestination()
 
1174
        
 
1175
          Note also that if 'ExternalFileName' is not emtpy, then the destination refers
 
1176
          to that document (and not to the current one).
 
1177
        
 
1178
          \returns the TOC, or NULL if the Document does not have one
 
1179
        */
 
1180
        QDomDocument *toc() const;
 
1181
        
 
1182
        /**
 
1183
           Tries to resolve the named destination \p name.
 
1184
        
 
1185
           \note this operation starts a search through the whole document
 
1186
        
 
1187
           \returns a new LinkDestination object if the named destination was
 
1188
           actually found, or NULL otherwise
 
1189
        */
 
1190
        LinkDestination *linkDestination( const QString &name );
 
1191
        
 
1192
        /**
 
1193
          Sets the paper color
 
1194
 
 
1195
          \param color the new paper color
 
1196
         */
 
1197
        void setPaperColor(const QColor &color);
 
1198
        /**
 
1199
          The paper color
 
1200
 
 
1201
          The default color is white.
 
1202
         */
 
1203
        QColor paperColor() const;
 
1204
 
 
1205
        /**
 
1206
         Sets the backend used to render the pages.
 
1207
 
 
1208
         \param backend the new rendering backend
 
1209
 
 
1210
         \since 0.6
 
1211
         */
 
1212
        void setRenderBackend( RenderBackend backend );
 
1213
        /**
 
1214
          The currently set render backend
 
1215
 
 
1216
          The default backend is \ref SplashBackend
 
1217
 
 
1218
          \since 0.6
 
1219
         */
 
1220
        RenderBackend renderBackend() const;
 
1221
 
 
1222
        /**
 
1223
          The available rendering backends.
 
1224
 
 
1225
          \since 0.6
 
1226
         */
 
1227
        static QSet<RenderBackend> availableRenderBackends();
 
1228
 
 
1229
        /**
 
1230
         Sets the render \p hint .
 
1231
 
 
1232
         \note some hints may not be supported by some rendering backends.
 
1233
 
 
1234
         \param on whether the flag should be added or removed.
 
1235
 
 
1236
         \since 0.6
 
1237
         */
 
1238
        void setRenderHint( RenderHint hint, bool on = true );
 
1239
        /**
 
1240
          The currently set render hints.
 
1241
 
 
1242
          \since 0.6
 
1243
         */
 
1244
        RenderHints renderHints() const;
 
1245
        
 
1246
        /**
 
1247
          Gets a new PS converter for this document.
 
1248
 
 
1249
          The caller gets the ownership of the returned converter.
 
1250
 
 
1251
          \since 0.6
 
1252
         */
 
1253
        PSConverter *psConverter() const;
 
1254
        
 
1255
        /**
 
1256
          Gets a new PDF converter for this document.
 
1257
 
 
1258
          The caller gets the ownership of the returned converter.
 
1259
 
 
1260
          \since 0.8
 
1261
         */
 
1262
        PDFConverter *pdfConverter() const;
 
1263
        
 
1264
        /**
 
1265
          Gets the metadata stream contents
 
1266
 
 
1267
          \since 0.6
 
1268
        */
 
1269
        QString metadata() const;
 
1270
 
 
1271
        /**
 
1272
           Test whether this document has "optional content".
 
1273
 
 
1274
           Optional content is used to optionally turn on (display)
 
1275
           and turn off (not display) some elements of the document.
 
1276
           The most common use of this is for layers in design
 
1277
           applications, but it can be used for a range of things,
 
1278
           such as not including some content in printing, and
 
1279
           displaying content in the appropriate language.
 
1280
 
 
1281
           \since 0.8
 
1282
        */
 
1283
        bool hasOptionalContent() const;
 
1284
 
 
1285
        /**
 
1286
           Itemviews model for optional content.
 
1287
 
 
1288
           The model is owned by the document.
 
1289
 
 
1290
           \since 0.8
 
1291
        */
 
1292
        OptContentModel *optionalContentModel();
 
1293
 
 
1294
        /**
 
1295
           Document-level JavaScript scripts.
 
1296
 
 
1297
           Returns the list of document level JavaScript scripts to be always
 
1298
           executed before any other script.
 
1299
 
 
1300
           \since 0.10
 
1301
        */
 
1302
        QStringList scripts() const;
 
1303
 
 
1304
        /**
 
1305
           The PDF identifiers.
 
1306
 
 
1307
           \param permanentId an optional pointer to a variable where store the
 
1308
           permanent ID of the document
 
1309
           \param updateId an optional pointer to a variable where store the
 
1310
           update ID of the document
 
1311
 
 
1312
           \return whether the document has the IDs
 
1313
 
 
1314
           \since 0.16
 
1315
        */
 
1316
        bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const;
 
1317
 
 
1318
        /**
 
1319
           Destructor.
 
1320
        */
 
1321
        ~Document();
 
1322
  
 
1323
    private:
 
1324
        Q_DISABLE_COPY(Document)
 
1325
 
 
1326
        DocumentData *m_doc;
 
1327
        
 
1328
        Document(DocumentData *dataA);
 
1329
    };
 
1330
    
 
1331
    class BaseConverterPrivate;
 
1332
    class PSConverterPrivate;
 
1333
    class PDFConverterPrivate;
 
1334
    /**
 
1335
       \brief Base converter.
 
1336
 
 
1337
       This is the base class for the converters.
 
1338
 
 
1339
       \since 0.8
 
1340
    */
 
1341
    class POPPLER_QT4_EXPORT BaseConverter
 
1342
    {
 
1343
        friend class Document;
 
1344
        public:
 
1345
            /**
 
1346
              Destructor.
 
1347
            */
 
1348
            virtual ~BaseConverter();
 
1349
 
 
1350
            /** Sets the output file name. You must set this or the output device. */
 
1351
            void setOutputFileName(const QString &outputFileName);
 
1352
 
 
1353
            /**
 
1354
             * Sets the output device. You must set this or the output file name.
 
1355
             *
 
1356
             * \since 0.8
 
1357
             */
 
1358
            void setOutputDevice(QIODevice *device);
 
1359
 
 
1360
            /**
 
1361
              Does the conversion.
 
1362
 
 
1363
              \return whether the conversion succeeded
 
1364
            */
 
1365
            virtual bool convert() = 0;
 
1366
            
 
1367
            enum Error
 
1368
            {
 
1369
                NoError,
 
1370
                FileLockedError,
 
1371
                OpenOutputError,
 
1372
                NotSupportedInputFileError
 
1373
            };
 
1374
            
 
1375
            /**
 
1376
              Returns the last error
 
1377
              \since 0.12.1
 
1378
            */
 
1379
            Error lastError() const;
 
1380
 
 
1381
        protected:
 
1382
            /// \cond PRIVATE
 
1383
            BaseConverter(BaseConverterPrivate &dd);
 
1384
            Q_DECLARE_PRIVATE(BaseConverter)
 
1385
            BaseConverterPrivate *d_ptr;
 
1386
            /// \endcond
 
1387
 
 
1388
        private:
 
1389
            Q_DISABLE_COPY(BaseConverter)
 
1390
    };
 
1391
 
 
1392
    /**
 
1393
       Converts a PDF to PS
 
1394
 
 
1395
       Sizes have to be in Points (1/72 inch)
 
1396
 
 
1397
       If you are using QPrinter you can get paper size by doing:
 
1398
       \code
 
1399
QPrinter dummy(QPrinter::PrinterResolution);
 
1400
dummy.setFullPage(true);
 
1401
dummy.setPageSize(myPageSize);
 
1402
width = dummy.width();
 
1403
height = dummy.height();
 
1404
       \endcode
 
1405
 
 
1406
       \since 0.6
 
1407
    */
 
1408
    class POPPLER_QT4_EXPORT PSConverter : public BaseConverter
 
1409
    {
 
1410
        friend class Document;
 
1411
        public:
 
1412
            /**
 
1413
              Options for the PS export.
 
1414
 
 
1415
              \since 0.10
 
1416
             */
 
1417
            enum PSOption {
 
1418
                Printing = 0x00000001,              ///< The PS is generated for priting purpouses
 
1419
                StrictMargins = 0x00000002,
 
1420
                ForceRasterization = 0x00000004
 
1421
            };
 
1422
            Q_DECLARE_FLAGS( PSOptions, PSOption )
 
1423
 
 
1424
            /**
 
1425
              Destructor.
 
1426
            */
 
1427
            ~PSConverter();
 
1428
 
 
1429
            /** Sets the list of pages to print. Mandatory. */
 
1430
            void setPageList(const QList<int> &pageList);
 
1431
 
 
1432
            /**
 
1433
              Sets the title of the PS Document. Optional
 
1434
            */
 
1435
            void setTitle(const QString &title);
 
1436
 
 
1437
            /**
 
1438
              Sets the horizontal DPI. Defaults to 72.0
 
1439
            */
 
1440
            void setHDPI(double hDPI);
 
1441
 
 
1442
            /**
 
1443
              Sets the vertical DPI. Defaults to 72.0
 
1444
            */
 
1445
            void setVDPI(double vDPI);
 
1446
 
 
1447
            /**
 
1448
              Sets the rotate. Defaults to not rotated
 
1449
            */
 
1450
            void setRotate(int rotate);
 
1451
 
 
1452
            /**
 
1453
              Sets the output paper width. Has to be set.
 
1454
            */
 
1455
            void setPaperWidth(int paperWidth);
 
1456
 
 
1457
            /**
 
1458
              Sets the output paper height. Has to be set.
 
1459
            */
 
1460
            void setPaperHeight(int paperHeight);
 
1461
 
 
1462
            /**
 
1463
              Sets the output right margin. Defaults to 0
 
1464
            */
 
1465
            void setRightMargin(int marginRight);
 
1466
 
 
1467
            /**
 
1468
              Sets the output bottom margin. Defaults to 0
 
1469
            */
 
1470
            void setBottomMargin(int marginBottom);
 
1471
 
 
1472
            /**
 
1473
              Sets the output left margin. Defaults to 0
 
1474
            */
 
1475
            void setLeftMargin(int marginLeft);
 
1476
 
 
1477
            /**
 
1478
              Sets the output top margin. Defaults to 0
 
1479
            */
 
1480
            void setTopMargin(int marginTop);
 
1481
 
 
1482
            /**
 
1483
              Defines if margins have to be strictly followed (even if that
 
1484
              means changing aspect ratio), or if the margins can be adapted
 
1485
              to keep aspect ratio.
 
1486
 
 
1487
              Defaults to false.
 
1488
            */
 
1489
            void setStrictMargins(bool strictMargins);
 
1490
 
 
1491
            /** Defines if the page will be rasterized to an image before printing. Defaults to false */
 
1492
            void setForceRasterize(bool forceRasterize);
 
1493
 
 
1494
            /**
 
1495
              Sets the options for the PS export.
 
1496
 
 
1497
              \since 0.10
 
1498
             */
 
1499
            void setPSOptions(PSOptions options);
 
1500
 
 
1501
            /**
 
1502
              The currently set options for the PS export.
 
1503
 
 
1504
              The default flags are: Printing.
 
1505
 
 
1506
              \since 0.10
 
1507
             */
 
1508
            PSOptions psOptions() const;
 
1509
 
 
1510
            /**
 
1511
              Sets a function that will be called each time a page is converted.
 
1512
 
 
1513
              The payload belongs to the caller.
 
1514
 
 
1515
              \since 0.16
 
1516
             */
 
1517
            void setPageConvertedCallback(void (* callback)(int page, void *payload), void *payload);
 
1518
 
 
1519
            bool convert();
 
1520
 
 
1521
        private:
 
1522
            Q_DECLARE_PRIVATE(PSConverter)
 
1523
            Q_DISABLE_COPY(PSConverter)
 
1524
 
 
1525
            PSConverter(DocumentData *document);
 
1526
    };
 
1527
 
 
1528
    /**
 
1529
       Converts a PDF to PDF (thus saves a copy of the document).
 
1530
 
 
1531
       \since 0.8
 
1532
    */
 
1533
    class POPPLER_QT4_EXPORT PDFConverter : public BaseConverter
 
1534
    {
 
1535
        friend class Document;
 
1536
        public:
 
1537
            /**
 
1538
              Options for the PDF export.
 
1539
             */
 
1540
            enum PDFOption {
 
1541
                WithChanges = 0x00000001        ///< The changes done to the document are saved as well
 
1542
            };
 
1543
            Q_DECLARE_FLAGS( PDFOptions, PDFOption )
 
1544
 
 
1545
            /**
 
1546
              Destructor.
 
1547
            */
 
1548
            virtual ~PDFConverter();
 
1549
 
 
1550
            /**
 
1551
              Sets the options for the PDF export.
 
1552
             */
 
1553
            void setPDFOptions(PDFOptions options);
 
1554
            /**
 
1555
              The currently set options for the PDF export.
 
1556
             */
 
1557
            PDFOptions pdfOptions() const;
 
1558
 
 
1559
            bool convert();
 
1560
 
 
1561
        private:
 
1562
            Q_DECLARE_PRIVATE(PDFConverter)
 
1563
            Q_DISABLE_COPY(PDFConverter)
 
1564
 
 
1565
            PDFConverter(DocumentData *document);
 
1566
    };
 
1567
 
 
1568
    /**
 
1569
       Conversion from PDF date string format to QDateTime
 
1570
    */
 
1571
    POPPLER_QT4_EXPORT QDateTime convertDate( char *dateString );
 
1572
 
 
1573
    /**
 
1574
       Whether the color management functions are available.
 
1575
 
 
1576
       \since 0.12
 
1577
    */
 
1578
    POPPLER_QT4_EXPORT bool isCmsAvailable();
 
1579
 
 
1580
    class SoundData;
 
1581
    /**
 
1582
       Container class for a sound file in a PDF document.
 
1583
 
 
1584
        A sound can be either External (in that case should be loaded the file
 
1585
       whose url is represented by url() ), or Embedded, and the player has to
 
1586
       play the data contained in data().
 
1587
 
 
1588
       \since 0.6
 
1589
    */
 
1590
    class POPPLER_QT4_EXPORT SoundObject {
 
1591
    public:
 
1592
        /**
 
1593
           The type of sound
 
1594
        */
 
1595
        enum SoundType {
 
1596
            External,     ///< The real sound file is external
 
1597
            Embedded      ///< The sound is contained in the data
 
1598
        };
 
1599
 
 
1600
        /**
 
1601
           The encoding format used for the sound
 
1602
        */
 
1603
        enum SoundEncoding {
 
1604
            Raw,          ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ]
 
1605
            Signed,       ///< Twos-complement values
 
1606
            muLaw,        ///< mu-law-encoded samples
 
1607
            ALaw          ///< A-law-encoded samples
 
1608
        };
 
1609
 
 
1610
        /// \cond PRIVATE
 
1611
        SoundObject(Sound *popplersound);
 
1612
        /// \endcond
 
1613
        
 
1614
        ~SoundObject();
 
1615
 
 
1616
        /**
 
1617
           Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)?
 
1618
        */
 
1619
        SoundType soundType() const;
 
1620
 
 
1621
        /**
 
1622
           The URL of the sound file to be played, in case of SoundObject::External
 
1623
        */
 
1624
        QString url() const;
 
1625
 
 
1626
        /**
 
1627
           The data of the sound, in case of SoundObject::Embedded
 
1628
        */
 
1629
        QByteArray data() const;
 
1630
 
 
1631
        /**
 
1632
           The sampling rate of the sound
 
1633
        */
 
1634
        double samplingRate() const;
 
1635
 
 
1636
        /**
 
1637
           The number of sound channels to use to play the sound
 
1638
        */
 
1639
        int channels() const;
 
1640
 
 
1641
        /**
 
1642
           The number of bits per sample value per channel
 
1643
        */
 
1644
        int bitsPerSample() const;
 
1645
 
 
1646
        /**
 
1647
           The encoding used for the sound
 
1648
        */
 
1649
        SoundEncoding soundEncoding() const;
 
1650
 
 
1651
    private:
 
1652
        Q_DISABLE_COPY(SoundObject)
 
1653
 
 
1654
        SoundData *m_soundData;
 
1655
    };
 
1656
 
 
1657
    class MovieData;
 
1658
    /**
 
1659
       Container class for a movie object in a PDF document.
 
1660
 
 
1661
       \since 0.10
 
1662
    */
 
1663
    class POPPLER_QT4_EXPORT MovieObject {
 
1664
    friend class Page;
 
1665
    public:
 
1666
        /**
 
1667
           The play mode for playing the movie
 
1668
        */
 
1669
        enum PlayMode {
 
1670
            PlayOnce,         ///< Play the movie once, closing the movie controls at the end
 
1671
            PlayOpen,         ///< Like PlayOnce, but leaving the controls open
 
1672
            PlayRepeat,       ///< Play continuously until stopped
 
1673
            PlayPalindrome    ///< Play forward, then backward, then again foward and so on until stopped
 
1674
        };
 
1675
 
 
1676
        ~MovieObject();
 
1677
 
 
1678
        /**
 
1679
           The URL of the movie to be played
 
1680
        */
 
1681
        QString url() const;
 
1682
 
 
1683
        /**
 
1684
           The size of the movie
 
1685
        */
 
1686
        QSize size() const;
 
1687
 
 
1688
        /**
 
1689
           The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie,
 
1690
        */
 
1691
        int rotation() const;
 
1692
 
 
1693
        /**
 
1694
           Whether show a bar with movie controls
 
1695
        */
 
1696
        bool showControls() const;
 
1697
 
 
1698
        /**
 
1699
           How to play the movie
 
1700
        */
 
1701
        PlayMode playMode() const;
 
1702
 
 
1703
    private:
 
1704
        /// \cond PRIVATE
 
1705
        MovieObject( AnnotMovie *ann );
 
1706
        /// \endcond
 
1707
        
 
1708
        Q_DISABLE_COPY(MovieObject)
 
1709
 
 
1710
        MovieData *m_movieData;
 
1711
    };
 
1712
 
 
1713
}
 
1714
 
 
1715
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags)
 
1716
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints)
 
1717
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions)
 
1718
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions)
 
1719
 
 
1720
#endif