python-poppler-qt5-0.24.2/0000755000175000001440000000000012474036060016137 5ustar wilbertusers00000000000000python-poppler-qt5-0.24.2/INSTALL0000644000175000001440000000320012472120505017157 0ustar wilbertusers00000000000000Installation: ============= python-poppler-qt5 installs a single Python module named 'popplerqt5'. The setup script uses distutils. Use the following commands to build and install the module: python setup.py build python setup.py install To install in /usr instead of /usr/local: python setup.py install --prefix /usr Troubleshooting: ================ The setup script uses pkg-config to determine the version of the installed poppler-qt5 library. Methods or classes that are not in the installed poppler- qt5 library will then also be disabled in the Python binding. If your system does not provide pkg-config, you can manually specify the poppler version to use with the --poppler-version option, e.g.: python setup.py build_ext --poppler-version=0.14.0 Note that for these options to work you need the 'build_ext' command rather than the 'build' command. You may then also need the --include-dirs and --library-dirs options to the build_ext command if the correct poppler-qt5 header files and libraries can't be found. See the output of python setup.py --help build_ext for more options. If you have a Debian-based system such as Ubuntu, and you get the error message "ImportError: No module named popplerqt5", try: python setup.py install --install-layout=deb See the distutils documentation for more install options. Dependencies: ============= - sip 4.9.1 or newer - poppler-qt5 0.12.0 or newer (poppler-qt5 is part of poppler) - Qt5 - PyQt5 - Python (tested with 2.6) To build the popplerqt5 module, header files of Qt5 and poppler-qt5 and sip files of PyQt5 are needed (sometimes packaged separately in corresponding -dev packages). python-poppler-qt5-0.24.2/poppler-annotation.sip0000644000175000001440000006275012472562563022531 0ustar wilbertusers00000000000000namespace Poppler { class AnnotationUtils { %Docstring Helper class for (recursive) Annotation retrieval/storage. %End %TypeHeaderCode #include #include %End public: %If(QTXML_AVAILABLE) static Poppler::Annotation * createAnnotation( const QDomElement & annElement ); %Docstring Restore an ``Annotation`` (with revisions if needed) from the DOM element ``annElement``. Returns the complete Annotation or None if element is invalid. %End static void storeAnnotation( const Poppler::Annotation * ann, QDomElement & annElement, QDomDocument & document ); static QDomElement findChildElement( const QDomNode & parentNode, const QString & name ); %End }; // class AnnotationUtils class Annotation { %Docstring Annotation class holding properties shared by all annotations. %End %TypeHeaderCode #include #include %End public: enum SubType { AText = 1, ALine = 2, AGeom = 3, AHighlight = 4, AStamp = 5, AInk = 6, ALink = 7, ACaret = 8, AFileAttachment = 9, ASound = 10, AMovie = 11, %If(POPPLER_V0_20_0 -) AScreen = 12, %End %If(POPPLER_V0_22_0 -) AWidget = 13, %End A_BASE = 0 }; enum Flag { Hidden = 1, FixedSize = 2, FixedRotation = 4, DenyPrint = 8, DenyWrite = 16, DenyDelete = 32, ToggleHidingOnMouse = 64, External = 128 }; enum LineStyle { Solid = 1, Dashed = 2, Beveled = 4, Inset = 8, Underline = 16 }; enum LineEffect { NoEffect = 1, Cloudy = 2 }; enum RevScope { %If(POPPLER_V0_20_0 -) Root = 0, %End Reply = 1, Group = 2, Delete = 4 }; enum RevType { None = 1, Marked = 2, Unmarked = 4, Accepted = 8, Rejected = 16, Cancelled = 32, Completed = 64 }; QString author() const; void setAuthor( const QString &author ); QString contents() const; void setContents( const QString &contents ); QString uniqueName() const; void setUniqueName( const QString &uniqueName ); QDateTime modificationDate() const; void setModificationDate( const QDateTime &date ); QDateTime creationDate() const; void setCreationDate( const QDateTime &date ); int flags() const; void setFlags( int flags ); QRectF boundary() const; void setBoundary( const QRectF &boundary ); %If(POPPLER_V0_20_0 -) class Style { public: Style(); Style( const Poppler::Annotation::Style &other ); //Style& operator=( const Style &other ); ~Style(); // appearance properties QColor color() const; // black void setColor(const QColor &color); double opacity() const; // 1.0 void setOpacity(double opacity); // pen properties double width() const; // 1.0 void setWidth(double width); Poppler::Annotation::LineStyle lineStyle() const; // LineStyle::Solid void setLineStyle(Poppler::Annotation::LineStyle style); double xCorners() const; // 0.0 void setXCorners(double radius); double yCorners() const; // 0.0 void setYCorners(double radius); const QVector& dashArray() const; // [ 3 ] void setDashArray(const QVector &array); // pen effects Poppler::Annotation::LineEffect lineEffect() const; // LineEffect::NoEffect void setLineEffect(Poppler::Annotation::LineEffect effect); double effectIntensity() const; // 1.0 void setEffectIntensity(double intens); }; Poppler::Annotation::Style style() const; void setStyle( const Poppler::Annotation::Style& style ); %End %If(POPPLER_V0_20_0 -) class Popup { %Docstring Container class for Annotation pop-up window information %End public: Popup(); Popup( const Poppler::Annotation::Popup &other ); //Popup& operator=( const Popup &other ); ~Popup(); // window state (Hidden, FixedRotation, Deny* flags allowed) int flags() const; // -1 (never initialized) -> 0 (if inited and shown) void setFlags( int flags ); // geometric properties QRectF geometry() const; // no default void setGeometry( const QRectF &geom ); // window contens/override properties QString title() const; // '' text in the titlebar (overrides author) void setTitle( const QString &title ); QString summary() const; // '' short description (displayed if not empty) void setSummary( const QString &summary ); QString text() const; // '' text for the window (overrides annot->contents) void setText( const QString &text ); }; Poppler::Annotation::Popup popup() const; void setPopup( const Poppler::Annotation::Popup& popup ); %Docstring Warning: Currently does nothing %End %End %If(POPPLER_V0_20_0 -) RevScope revisionScope() const; // Root RevType revisionType() const; // None %End %If(POPPLER_V0_20_0 -) /** * Returns the revisions of this annotation * * \note The caller owns the returned annotations and they should * be deleted when no longer required. * * \since 0.20 */ QList revisions() const; %End /** * The type of the annotation. */ virtual SubType subType() const = 0; /** * Destructor. */ virtual ~Annotation(); %If(POPPLER_V0_22_0 -) /** * Describes the flags from an annotations 'AA' dictionary. * * This flag is used by the additionalAction() method for ScreenAnnotation * and WidgetAnnotation. * * \since 0.22 */ enum AdditionalActionType { CursorEnteringAction, ///< Performed when the cursor enters the annotation's active area CursorLeavingAction, ///< Performed when the cursor exists the annotation's active area MousePressedAction, ///< Performed when the mouse button is pressed inside the annotation's active area MouseReleasedAction, ///< Performed when the mouse button is released inside the annotation's active area FocusInAction, ///< Performed when the annotation receives the input focus FocusOutAction, ///< Performed when the annotation loses the input focus PageOpeningAction, ///< Performed when the page containing the annotation is opened PageClosingAction, ///< Performed when the page containing the annotation is closed PageVisibleAction, ///< Performed when the page containing the annotation becomes visible PageInvisibleAction ///< Performed when the page containing the annotation becomes invisible }; %End protected: %If(QTXML_AVAILABLE) void storeBaseAnnotationProperties( QDomNode & parentNode, QDomDocument & document ) const; %End private: Annotation(const Poppler::Annotation&); %If(QTXML_AVAILABLE) virtual void store( QDomNode & parentNode, QDomDocument & document ) const; %End %ConvertToSubClassCode switch (sipCpp->subType()) { case Poppler::Annotation::AText: sipType = sipType_Poppler_TextAnnotation; break; case Poppler::Annotation::ALine: sipType = sipType_Poppler_LineAnnotation; break; case Poppler::Annotation::AGeom: sipType = sipType_Poppler_GeomAnnotation; break; case Poppler::Annotation::AHighlight: sipType = sipType_Poppler_HighlightAnnotation; break; case Poppler::Annotation::AStamp: sipType = sipType_Poppler_StampAnnotation; break; case Poppler::Annotation::AInk: sipType = sipType_Poppler_InkAnnotation; break; case Poppler::Annotation::ALink: sipType = sipType_Poppler_LinkAnnotation; break; case Poppler::Annotation::ACaret: sipType = sipType_Poppler_CaretAnnotation; break; case Poppler::Annotation::AFileAttachment: sipType = sipType_Poppler_FileAttachmentAnnotation; break; case Poppler::Annotation::ASound: sipType = sipType_Poppler_SoundAnnotation; break; case Poppler::Annotation::AMovie: sipType = sipType_Poppler_MovieAnnotation; break; case Poppler::Annotation::AScreen: sipType = sipType_Poppler_ScreenAnnotation; break; case Poppler::Annotation::AWidget: sipType = sipType_Poppler_WidgetAnnotation; break; default: sipType = sipType_Poppler_Annotation; } %End }; // class Annotation class TextAnnotation : Poppler::Annotation { %Docstring Annotation containing text. A text annotation is an object showing some text directly on the page, or linked to the contents using an icon shown on a page. %End %TypeHeaderCode #include #include %End public: // local enums enum TextType { Linked, InPlace }; enum InplaceIntent { Unknown, Callout, TypeWriter }; TextAnnotation( TextType type ); virtual ~TextAnnotation(); virtual SubType subType() const; /** The type of text annotation represented by this object */ TextType textType() const; /** The name of the icon for this text annotation. Standard names for text annotation icons are: - Comment - Help - Insert - Key - NewParagraph - Note (this is the default icon to use) - Paragraph */ QString textIcon() const; /** Set the name of the icon to use for this text annotation. \sa textIcon for the list of standard names */ void setTextIcon( const QString &icon ); QFont textFont() const; void setTextFont( const QFont &font ); int inplaceAlign() const; void setInplaceAlign( int align ); QPointF calloutPoint( int id ) const; %If(POPPLER_V0_20_0 -) QVector calloutPoints() const; void setCalloutPoints( const QVector &points ); %End InplaceIntent inplaceIntent() const; void setInplaceIntent( InplaceIntent intent ); private: %If(QTXML_AVAILABLE) TextAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End void setTextType( TextType type ); }; // class TextAnnotation class LineAnnotation : Poppler::Annotation { %Docstring Polygon/polyline annotation. This annotation represents a polygon (or polyline) to be drawn on a page. %End %TypeHeaderCode #include #include %End public: // local enums %If(POPPLER_V0_20_0 -) enum LineType { StraightLine, Polyline }; %End enum TermStyle { Square, Circle, Diamond, OpenArrow, ClosedArrow, None, Butt, ROpenArrow, RClosedArrow, Slash }; enum LineIntent { Unknown, Arrow, Dimension, PolygonCloud }; %If(POPPLER_V0_20_0 -) LineAnnotation( LineType type ); %End virtual ~LineAnnotation(); virtual SubType subType() const; %If(POPPLER_V0_20_0 -) LineType lineType() const; %End QLinkedList linePoints() const; void setLinePoints( const QLinkedList &points ); TermStyle lineStartStyle() const; void setLineStartStyle( TermStyle style ); TermStyle lineEndStyle() const; void setLineEndStyle( TermStyle style ); bool isLineClosed() const; void setLineClosed( bool closed ); QColor lineInnerColor() const; void setLineInnerColor( const QColor &color ); double lineLeadingForwardPoint() const; void setLineLeadingForwardPoint( double point ); double lineLeadingBackPoint() const; void setLineLeadingBackPoint( double point ); bool lineShowCaption() const; void setLineShowCaption( bool show ); LineIntent lineIntent() const; void setLineIntent( LineIntent intent ); private: %If(QTXML_AVAILABLE) LineAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End void setLineType( LineType type ); }; // class LineAnnotation class GeomAnnotation : Poppler::Annotation { %Docstring Geometric annotation. The geometric annotation represents a geometric figure, like a rectangle or an ellipse. %End %TypeHeaderCode #include #include %End public: GeomAnnotation(); virtual ~GeomAnnotation(); virtual SubType subType() const; // common enums enum GeomType { InscribedSquare, InscribedCircle }; GeomType geomType() const; void setGeomType( GeomType style ); QColor geomInnerColor() const; void setGeomInnerColor( const QColor &color ); private: %If(QTXML_AVAILABLE) GeomAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class GeomAnnotation class HighlightAnnotation : Poppler::Annotation { %Docstring Text highlight annotation. The higlight annotation represents some areas of text being "highlighted". %End %TypeHeaderCode #include #include %End public: HighlightAnnotation(); virtual ~HighlightAnnotation(); virtual SubType subType() const; /** The type of highlight */ enum HighlightType { Highlight, Squiggly, Underline, StrikeOut, }; /** Structure corresponding to a QuadPoints array. This matches a quadrilateral that describes the area around a word (or set of words) that are to be highlighted. */ struct Quad { QPointF * points { %GetCode sipPy = PyList_New(4); PyObject* obj; for (SIP_SSIZE_T i = 0; i < 4; ++i) { QPointF *point = new QPointF(sipCpp->points[i]); obj = sipConvertFromNewType(point, sipType_QPointF, NULL); PyList_SET_ITEM(sipPy, i, obj); } %End %SetCode SIP_SSIZE_T len; if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) != 4) sipErr = 1; else { for (SIP_SSIZE_T i = 0; i < 4; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); bool ok = (itm && sipCanConvertToType(itm, sipType_QPointF, SIP_NOT_NONE)); Py_XDECREF(itm); if (!ok) { sipErr = 1; break; } } } if (sipErr == 1) PyErr_SetString(PyExc_ValueError, "Quad.points must be a sequence of exactly 4 QPointF() instances"); else { int iserr = 0; for (SIP_SSIZE_T i = 0; i < 4; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); QPointF *point = reinterpret_cast(sipConvertToType(itm, sipType_QPointF, 0, 0, 0, &iserr)); sipCpp->points[i] = *point; Py_DECREF(itm); } } %End }; bool capStart; bool capEnd; double feather; }; /** The type (style) of highlighting to use for this area or these areas. */ HighlightType highlightType() const; /** Set the type of highlighting to use for the given area or areas. */ void setHighlightType( HighlightType type ); /** The list of areas to highlight. */ QList< Poppler::HighlightAnnotation::Quad > highlightQuads() const; /** Set the areas to highlight. */ void setHighlightQuads( const QList< Poppler::HighlightAnnotation::Quad > &quads ); private: %If(QTXML_AVAILABLE) HighlightAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class HighlightAnnotation class StampAnnotation : Poppler::Annotation { %Docstring Stamp annotation. A simple annotation drawing a stamp on a page. %End %TypeHeaderCode #include #include %End public: StampAnnotation(); virtual ~StampAnnotation(); virtual SubType subType() const; /** The name of the icon for this stamp annotation. Standard names for stamp annotation icons are: - Approved - AsIs - Confidential - Departmental - Draft (this is the default icon type) - Experimental - Expired - Final - ForComment - ForPublicRelease - NotApproved - NotForPublicRelease - Sold - TopSecret */ QString stampIconName() const; /** Set the icon type for this stamp annotation. \sa stampIconName for the list of standard icon names */ void setStampIconName( const QString &name ); private: %If(QTXML_AVAILABLE) StampAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class StampAnnotation class InkAnnotation : Poppler::Annotation { %Docstring Ink Annotation. Annotation representing an ink path on a page. %End %TypeHeaderCode #include #include %End public: InkAnnotation(); virtual ~InkAnnotation(); virtual SubType subType() const; QList< QLinkedList > inkPaths() const; void setInkPaths( const QList< QLinkedList > &paths ); private: %If(QTXML_AVAILABLE) InkAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class InkAnnotation class LinkAnnotation : Poppler::Annotation { %Docstring Link Annotation. Annotation representing a link on a page. %End %TypeHeaderCode #include #include %End public: virtual ~LinkAnnotation(); virtual SubType subType() const; // local enums enum HighlightMode { None, Invert, Outline, Push }; %If(POPPLER_V0_20_0 -) Poppler::Link* linkDestination() const; void setLinkDestination( Poppler::Link *link ); %End HighlightMode linkHighlightMode() const; void setLinkHighlightMode( HighlightMode mode ); QPointF linkRegionPoint( int id ) const; void setLinkRegionPoint( int id, const QPointF &point ); private: LinkAnnotation(); %If(QTXML_AVAILABLE) LinkAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class LinkAnnotation class CaretAnnotation : Poppler::Annotation { %Docstring Caret annotation. The caret annotation represents a symbol to indicate the presence of text. %End %TypeHeaderCode #include #include %End public: CaretAnnotation(); virtual ~CaretAnnotation(); virtual SubType subType() const; /** * The symbols for the caret annotation. */ enum CaretSymbol { None, P }; CaretSymbol caretSymbol() const; void setCaretSymbol( CaretSymbol symbol ); private: %If(QTXML_AVAILABLE) CaretAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class CaretAnnotation class FileAttachmentAnnotation : Poppler::Annotation { %Docstring File attachment annotation. The file attachment annotation represents a file embedded in the document. %End %TypeHeaderCode #include #include %End public: virtual ~FileAttachmentAnnotation(); virtual SubType subType() const; /** * Returns the name of the icon of this annotation. */ QString fileIconName() const; /** * Sets a new name for the icon of this annotation. */ void setFileIconName( const QString &icon ); /** * Returns the EmbeddedFile of this annotation. */ Poppler::EmbeddedFile* embeddedFile() const; /** * Sets a new EmbeddedFile for this annotation. * * \note FileAttachmentAnnotation takes ownership of the object */ void setEmbeddedFile( Poppler::EmbeddedFile *ef ); private: FileAttachmentAnnotation(); %If(QTXML_AVAILABLE) FileAttachmentAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class FileAttachmentAnnotation class SoundAnnotation : Poppler::Annotation { %Docstring Sound annotation. The sound annotation represents a sound to be played when activated. %End %TypeHeaderCode #include #include %End public: virtual ~SoundAnnotation(); virtual SubType subType() const; /** * Returns the name of the icon of this annotation. */ QString soundIconName() const; /** * Sets a new name for the icon of this annotation. */ void setSoundIconName( const QString &icon ); /** * Returns the SoundObject of this annotation. */ Poppler::SoundObject* sound() const; /** * Sets a new SoundObject for this annotation. * * \note SoundAnnotation takes ownership of the object */ void setSound( Poppler::SoundObject *ef ); private: SoundAnnotation(); %If(QTXML_AVAILABLE) SoundAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class SoundAnnotation class MovieAnnotation : Poppler::Annotation { %Docstring Movie annotation. The movie annotation represents a movie to be played when activated. %End %TypeHeaderCode #include #include %End public: virtual ~MovieAnnotation(); virtual SubType subType() const; /** * Returns the MovieObject of this annotation. */ Poppler::MovieObject* movie() const; /** * Sets a new MovieObject for this annotation. * * \note MovieAnnotation takes ownership of the object */ void setMovie( Poppler::MovieObject *movie ); /** * Returns the title of the movie of this annotation. */ QString movieTitle() const; /** * Sets a new title for the movie of this annotation. */ void setMovieTitle( const QString &title ); private: MovieAnnotation(); %If(QTXML_AVAILABLE) MovieAnnotation( const QDomNode &node ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; %End }; // class MovieAnnotation class ScreenAnnotation : Poppler::Annotation { %Docstring Screen annotation. The screen annotation represents a screen to be played when activated. %End %TypeHeaderCode #include #include %End public: virtual ~ScreenAnnotation(); virtual SubType subType() const; /** * Returns the LinkRendition of this annotation. */ Poppler::LinkRendition* action() const; /** * Sets a new LinkRendition for this annotation. * * \note ScreenAnnotation takes ownership of the object */ void setAction( Poppler::LinkRendition *action ); /** * Returns the title of the screen of this annotation. */ QString screenTitle() const; /** * Sets a new title for the screen of this annotation. */ void setScreenTitle( const QString &title ); /** * Returns the additional action of the given @p type fo the annotation or * @c 0 if no action has been defined. * * \since 0.22 */ %If(POPPLER_V0_22_0 -) Poppler::Link* additionalAction( AdditionalActionType type ) const; %End private: ScreenAnnotation(); %If(QTXML_AVAILABLE) virtual void store( QDomNode &parentNode, QDomDocument &document ) const; // stub %End }; // class ScreenAnnotation class WidgetAnnotation : Poppler::Annotation { %Docstring Widget annotation. The widget annotation represents a widget (form field) on a page. Note: this class is just provided for consistency of the annotation API, use the FormField classes to get all the form-related information. %End %TypeHeaderCode #include #include %End public: virtual ~WidgetAnnotation(); virtual SubType subType() const; /** * Returns the additional action of the given @p type fo the annotation or * @c 0 if no action has been defined. * * \since 0.22 */ %If(POPPLER_V0_22_0 -) Poppler::Link* additionalAction( AdditionalActionType type ) const; %End private: WidgetAnnotation(); %If(QTXML_AVAILABLE) virtual void store( QDomNode &parentNode, QDomDocument &document ) const; // stub %End }; // class WidgetAnnotation }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/poppler-page-transition.sip0000644000175000001440000000172112472120505023434 0ustar wilbertusers00000000000000namespace Poppler { class PageTransition { %TypeHeaderCode #include #include %End public: enum Type { Replace = 0, Split, Blinds, Box, Wipe, Dissolve, Glitter, Fly, Push, Cover, Uncover, Fade, }; enum Alignment { Horizontal = 0, Vertical, }; enum Direction { Inward = 0, Outward, }; // PageTransition(const PageTransitionParams ¶ms); PageTransition(const Poppler::PageTransition &pt); ~PageTransition(); Type type() const; int duration() const; Alignment alignment() const; Direction direction() const; int angle() const; double scale() const; bool isRectangular() const; }; // class PageTransition }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/LICENSE0000644000175000001440000000146412472120505017145 0ustar wilbertusers00000000000000This binding is licensed under the GNU LGPL. Copyright (c) 2009-2010 Wilbert Berendsen (www.wilbertberendsen.nl) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA python-poppler-qt5-0.24.2/setup.cfg0000644000175000001440000000003112472120505017746 0ustar wilbertusers00000000000000[sdist] force-manifest=1 python-poppler-qt5-0.24.2/MANIFEST.in0000644000175000001440000000017712472120505017676 0ustar wilbertusers00000000000000include README.rst INSTALL LICENSE TODO ChangeLog include MANIFEST.in setup.cfg include *.py include *.sip exclude version.sip python-poppler-qt5-0.24.2/poppler-text-box.sip0000644000175000001440000000066212472120505022105 0ustar wilbertusers00000000000000namespace Poppler { class TextBox { %TypeHeaderCode #include %End public: TextBox(const QString& text, const QRectF &bBox); ~TextBox(); QString text() const; QRectF boundingBox() const; Poppler::TextBox *nextWord() const; QRectF charBoundingBox(int i) const; bool hasSpaceAfter() const; private: TextBox(const Poppler::TextBox&); }; // class TextBox }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-qt5.sip0000644000175000001440000000232512472545664021063 0ustar wilbertusers00000000000000%Module(name=popplerqt5, version=0) /* * Bindings for Poppler-Qt5 to Python * Maintained by Wilbert Berendsen */ %Import QtCore/QtCoremod.sip %Import QtGui/QtGuimod.sip %Feature QTXML_AVAILABLE %Timeline { POPPLER_V0_20_0 POPPLER_V0_22_0 POPPLER_V0_24_0 POPPLER_V0_24_5 POPPLER_V0_28_0 } %ModuleHeaderCode #include %End %Include version.sip // auto-generated by the setup.py script %Include types.sip %Include poppler-annotation.sip %Include poppler-convert.sip %Include poppler-document.sip %Include poppler-embedded-file.sip %Include poppler-font-info.sip %Include poppler-font-iterator.sip %Include poppler-form.sip %Include poppler-link.sip %Include poppler-link-destination.sip %Include poppler-movie-object.sip %Include poppler-opt-content-model.sip %Include poppler-page.sip %Include poppler-page-transition.sip %Include poppler-sound-object.sip %Include poppler-text-box.sip namespace Poppler { // Functions in Poppler bool isCmsAvailable(); QDateTime convertDate (char *dateString); %If(POPPLER_V0_22_0 -) bool isOverprintPreviewAvailable(); %End }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/poppler-font-info.sip0000644000175000001440000000123712472120505022231 0ustar wilbertusers00000000000000namespace Poppler { class FontInfo { %TypeHeaderCode #include %End public: enum Type { unknown, Type1, Type1C, Type1COT, Type3, TrueType, TrueTypeOT, CIDType0, CIDType0C, CIDType0COT, CIDTrueType, CIDTrueTypeOT, }; FontInfo(); // FontInfo( const FontInfoData &fid ); FontInfo( const Poppler::FontInfo &fi ); ~FontInfo(); QString name() const; QString file() const; bool isEmbedded() const; bool isSubset() const; Type type() const; QString typeName() const; }; // class FontInfo }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-form.sip0000644000175000001440000000617412472120505021302 0ustar wilbertusers00000000000000namespace Poppler { class FormField { %TypeHeaderCode #include #include %End public: enum FormType { FormButton, FormText, FormChoice, FormSignature, }; virtual ~FormField(); virtual FormType type() const = 0; QRectF rect() const; int id() const; QString name() const; QString uiName() const; bool isReadOnly() const; bool isVisible() const; Poppler::Link* activationAction() const; private: FormField(const Poppler::FormField&); %ConvertToSubClassCode switch (sipCpp->type()) { case Poppler::FormField::FormButton: sipType = sipType_Poppler_FormFieldButton; break; case Poppler::FormField::FormText: sipType = sipType_Poppler_FormFieldText; break; case Poppler::FormField::FormChoice: sipType = sipType_Poppler_FormFieldChoice; break; default: sipType = sipType_Poppler_FormField; } %End }; // class FormField class FormFieldButton : Poppler::FormField { %TypeHeaderCode #include #include %End public: enum ButtonType { Push, CheckBox, Radio, }; // FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w); virtual ~FormFieldButton(); virtual FormType type() const; ButtonType buttonType() const; QString caption() const; bool state() const; void setState( bool state ); QList siblings() const; private: FormFieldButton(const Poppler::FormFieldButton&); }; // class FormFieldButton class FormFieldText : Poppler::FormField { %TypeHeaderCode #include #include %End public: enum TextType { Normal, Multiline, FileSelect, }; // FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w); virtual ~FormFieldText(); virtual FormType type() const; TextType textType() const; QString text() const; void setText( const QString& text ); bool isPassword() const; bool isRichText() const; int maximumLength() const; Qt::Alignment textAlignment() const; bool canBeSpellChecked() const; private: FormFieldText(const Poppler::FormFieldText&); }; // class FormFieldText class FormFieldChoice : Poppler::FormField { %TypeHeaderCode #include #include %End public: enum ChoiceType { ComboBox, ListBox, }; // FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w); virtual ~FormFieldChoice(); virtual FormType type() const; ChoiceType choiceType() const; QStringList choices() const; bool isEditable() const; bool multiSelect() const; QList currentChoices() const; void setCurrentChoices( const QList &choice ); Qt::Alignment textAlignment() const; bool canBeSpellChecked() const; private: FormFieldChoice(const Poppler::FormFieldChoice&); }; }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/poppler-embedded-file.sip0000644000175000001440000000102312472120505022771 0ustar wilbertusers00000000000000namespace Poppler { class EmbeddedFile { %TypeHeaderCode #include %End public: // EmbeddedFile(EmbFile *embfile); ~EmbeddedFile(); QString name() const; QString description() const; int size() const; QDateTime modDate() const; QDateTime createDate() const; QByteArray checksum() const; QString mimeType() const; QByteArray data(); bool isValid() const; private: EmbeddedFile(const Poppler::EmbeddedFile&); }; // class EmbeddedFile }; // namespace Poppler python-poppler-qt5-0.24.2/README.rst0000644000175000001440000000455612473017273017644 0ustar wilbertusers00000000000000================== python-poppler-qt5 ================== A Python binding for libpoppler-qt5 that aims for completeness and for being actively maintained. Created and currently maintained by Wilbert Berendsen . Homepage: https://pypi.python.org/pypi/python-poppler-qt5/ Usage:: import popplerqt5 d = popplerqt5.Poppler.Document.load('file.pdf') Documentation ------------- The Python API closely follows the Poppler Qt5 C++ interface library API, documented at http://people.freedesktop.org/~aacid/docs/qt5/ . Note: Releases of PyQt5 < 5.4 currently do not support the QtXml module, all methods that use the QDomDocument, QDomElement and QDomNode types are disabled. This concerns the ``Document::toc()`` method and some constructors and the ``store()`` methods in the ``Annotation`` subclasses. So, using PyQt5 >= 5.4 is recommended. Whereever the C++ API requires ``QList``, ``QSet`` or ``QLinkedList``, any Python sequence can be used. API calls that return ``QList``, ``QSet`` or ``QLinkedList`` all return Python lists. There are a few other differences: ``Poppler::Document::getPdfVersion(int *major, int *minor)`` can simply be called as ``d.getPdfVersion()``, (where ``d`` is a ``Poppler::Document`` instance); it will return a tuple of two integers (major, minor). ``Poppler::Document`` has ``__len__`` and ``__getitem__`` methods, corresponding to ``numPages()`` and ``page(int num)``. ``Poppler::FontIterator`` (returned by ``Poppler::Document::newFontIterator``) is also a Python iterable (e.g. has ``__iter__()`` and ``__next__()`` methods). So although you can use:: it = document.newFontIterator() while it.hasNext(): fonts = it.next() # list of FontInfo objects ... you can also use the more Pythonic:: for fonts in document.newFontIterator(): ... In addition to the Poppler namespace, there are two toplevel module functions: ``popplerqt5.version()`` returns the version of the ``python-poppler-qt5`` package as a tuple of ints, e.g. ``(0, 18, 2)``. ``popplerqt5.poppler_version()`` returns the version of the linked Poppler-Qt5 library as a tuple of ints, e.g. ``(0, 24, 5)``. This is determined at build time. If at build time the Poppler-Qt5 version could not be determined and was not specified, an empty tuple might be returned. python-poppler-qt5-0.24.2/poppler-document.sip0000644000175000001440000001006512473016770022160 0ustar wilbertusers00000000000000namespace Poppler { class Document { %TypeHeaderCode #include %End public: %If(POPPLER_V0_22_0 -) enum FormType { NoForm, AcroForm, XfaForm, }; %End enum PageMode { UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttach, }; enum PageLayout { NoLayout, SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight, }; enum RenderBackend { SplashBackend, ArthurBackend, }; enum RenderHint { Antialiasing = 0x00000001, TextAntialiasing = 0x00000002, TextHinting = 0x00000004, TextSlightHinting = 0x00000008, %If(POPPLER_V0_22_0 -) OverprintPreview = 0x00000010, %End %If(POPPLER_V0_24_0 -) ThinLineSolid = 0x00000020, ThinLineShape = 0x00000040, %End }; typedef QFlags RenderHints; void setColorDisplayProfile(void *outputProfileA); void setColorDisplayProfileName(const QString &name); void* colorRgbProfile() const; void* colorDisplayProfile() const; static Poppler::Document *load(const QString & filePath, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()) /Factory, ReleaseGIL/; static Poppler::Document *loadFromData(const QByteArray &fileContents, const QByteArray &ownerPassword=QByteArray(), const QByteArray &userPassword=QByteArray()) /Factory, ReleaseGIL/; Poppler::Page *page(int index) const /Factory/; Poppler::Page *__getitem__(int index) const /Factory/; %MethodCode SIP_SSIZE_T i = sipConvertFromSequenceIndex(a0, sipCpp->numPages()); if (i < 0) sipIsErr = 1; else sipRes = sipCpp->page((int)i); %End Poppler::Page *page(const QString &label) const /Factory/; int numPages() const /__len__/; int __bool__() const; %MethodCode sipRes = 1; %End PageMode pageMode() const; PageLayout pageLayout() const; bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); bool isLocked() const; QDateTime date( const QString & data ) const; QString info( const QString & data ) const; QStringList infoKeys() const; bool isEncrypted() const; bool isLinearized() const; bool okToPrint() const; bool okToPrintHighRes() const; bool okToChange() const; bool okToCopy() const; bool okToAddNotes() const; bool okToFillForm() const; bool okToCreateFormFields() const; bool okToExtractForAccessibility() const; bool okToAssemble() const; bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; void getPdfVersion(int *major, int *minor) const; QList fonts() const /ReleaseGIL/; %If(POPPLER_V0_22_0 -) FormType formType() const; %End Poppler::FontIterator* newFontIterator( int startPage = 0 ) const /Factory/; QByteArray fontData(const Poppler::FontInfo &font) const; QList embeddedFiles() const; bool hasEmbeddedFiles() const; %If(QTXML_AVAILABLE) QDomDocument *toc() const; %End Poppler::LinkDestination *linkDestination( const QString &name ) /Factory, ReleaseGIL/; void setPaperColor(const QColor &color); QColor paperColor() const; void setRenderBackend( RenderBackend backend ); RenderBackend renderBackend() const; static QSet availableRenderBackends(); void setRenderHint( RenderHint hint, bool on = true ); RenderHints renderHints() const; Poppler::PSConverter *psConverter() const /Factory/; Poppler::PDFConverter *pdfConverter() const /Factory/; QString metadata() const; bool hasOptionalContent() const; Poppler::OptContentModel *optionalContentModel() /Factory/; QStringList scripts() const; private: Document(); Document(const Poppler::Document &); }; // class Document }; // namespace Poppler python-poppler-qt5-0.24.2/setup.py0000644000175000001440000003134112474036016017654 0ustar wilbertusers00000000000000#! python project = dict( name = 'python-poppler-qt5', version = '0.24.2', description = 'A Python binding to Poppler-Qt5', long_description = ( 'A Python binding to Poppler-Qt5 that aims for ' 'completeness and for being actively maintained. ' 'Using this module you can access the contents of PDF files ' 'inside PyQt5 applications.' ), maintainer = 'Wilbert Berendsen', maintainer_email = 'wbsoft@xs4all.nl', url = 'https://github.com/wbsoft/python-poppler-qt5', license = 'LGPL', classifiers = [ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Programming Language :: Python :: 3', 'Topic :: Multimedia :: Graphics :: Viewers', ], cmdclass={} ) import os import re import shlex import subprocess import sys import platform try: from setuptools import setup, Extension except ImportError: from distutils.core import setup, Extension import sipdistutils ### this circumvents a bug in sip < 4.14.2, where the file() builtin is used ### instead of open() try: import builtins try: builtins.file except AttributeError: builtins.file = open except ImportError: pass ### end def check_qtxml(): """Return True if PyQt5.QtXml can be imported. in some early releases of PyQt5, QtXml was missing because it was thought QtXml was deprecated. """ import PyQt5 try: import PyQt5.QtXml except ImportError: return False return True def pkg_config(package, attrs=None, include_only=False): """parse the output of pkg-config for a package. returns the given or a new dictionary with one or more of these keys 'include_dirs', 'library_dirs', 'libraries'. Every key is a list of paths, so that it can be used with distutils Extension objects. """ if attrs is None: attrs = {} cmd = ['pkg-config'] if include_only: cmd += ['--cflags-only-I'] else: cmd += ['--cflags', '--libs'] cmd.append(package) try: output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] except OSError: return attrs flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} # for python3 turn bytes back to string if sys.version_info[0] > 2: output = output.decode('utf-8') for flag in shlex.split(output): option, path = flag[:2], flag[2:] if option in flag_map: l = attrs.setdefault(flag_map[option], []) if path not in l: l.append(path) return attrs def pkg_config_version(package): """Returns the version of the given package as a tuple of ints.""" cmd = ['pkg-config', '--modversion', package] try: output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] # for python3 turn bytes back to string if sys.version_info[0] > 2: output = output.decode('utf-8') return tuple(map(int, re.findall(r'\d+', output))) except OSError: sys.stderr.write("Can't determine version of %s\n" % package) ext_args = {} pkg_config('poppler-qt5', ext_args) if 'libraries' not in ext_args: ext_args['libraries'] = ['poppler-qt5'] # hack to provide our options to sip on its invocation: build_ext_base = sipdistutils.build_ext class build_ext(build_ext_base): description = "Builds the popplerqt5 module." user_options = build_ext_base.user_options + [ ('poppler-version=', None, "version of the poppler library"), ('qmake-bin=', None, "Path to qmake binary"), ('qt-include-dir=', None, "Path to Qt headers"), ('pyqt-sip-dir=', None, "Path to PyQt's SIP files"), ('pyqt-sip-flags=', None, "SIP flags used to generate PyQt bindings") ] def initialize_options (self): build_ext_base.initialize_options(self) self.poppler_version = None self.qmake_bin = 'qmake' self.qt_include_dir = None self.pyqt_sip_dir = None self.pyqt_sip_flags = None def finalize_options (self): build_ext_base.finalize_options(self) if not self.qt_include_dir: self.qt_include_dir = self.__find_qt_include_dir() if not self.pyqt_sip_dir: self.pyqt_sip_dir = self.__find_pyqt_sip_dir() if not self.pyqt_sip_flags: self.pyqt_sip_flags = self.__find_pyqt_sip_flags() if not self.qt_include_dir: raise SystemExit('Could not find Qt5 headers. ' 'Please specify via --qt-include-dir=') if not self.pyqt_sip_dir: raise SystemExit('Could not find PyQt SIP files. ' 'Please specify containing directory via ' '--pyqt-sip-dir=') if not self.pyqt_sip_flags: raise SystemExit('Could not find PyQt SIP flags. ' 'Please specify via --pyqt-sip-flags=') self.include_dirs += (self.qt_include_dir, os.path.join(self.qt_include_dir, 'QtCore'), os.path.join(self.qt_include_dir, 'QtGui'), os.path.join(self.qt_include_dir, 'QtXml')) if self.poppler_version is not None: self.poppler_version = tuple(map(int, re.findall(r'\d+', self.poppler_version))) def __find_qt_include_dir(self): if self.pyqtconfig: return self.pyqtconfig.qt_inc_dir try: qt_version = subprocess.check_output([self.qmake_bin, '-query', 'QT_VERSION']) qt_version = qt_version.strip().decode("ascii") except (OSError, subprocess.CalledProcessError) as e: raise SystemExit('Failed to determine Qt version (%s).' % e) if not qt_version.startswith("5."): raise SystemExit('Unsupported Qt version (%s). ' 'Try specifying the path to qmake manually via ' '--qmake-bin=' % qt_version) try: result = subprocess.check_output([self.qmake_bin, '-query', 'QT_INSTALL_HEADERS']) return result.strip().decode(sys.getfilesystemencoding()) except (OSError, subprocess.CalledProcessError) as e: raise SystemExit('Failed to determine location of Qt headers (%s).' % e) def __find_pyqt_sip_dir(self): if self.pyqtconfig: return self.pyqtconfig.pyqt_sip_dir import sipconfig return os.path.join(sipconfig.Configuration().default_sip_dir, 'PyQt5') def __find_pyqt_sip_flags(self): if self.pyqtconfig: return self.pyqtconfig.pyqt_sip_flags from PyQt5 import QtCore return QtCore.PYQT_CONFIGURATION.get('sip_flags', '') @property def pyqtconfig(self): if not hasattr(self, '_pyqtconfig'): try: from PyQt5 import pyqtconfig self._pyqtconfig = pyqtconfig.Configuration() except ImportError: self._pyqtconfig = None return self._pyqtconfig def write_version_sip(self, poppler_qt5_version, python_poppler_qt5_version): """Write a version.sip file. The file contains code to make version information accessible from the popplerqt5 Python module. """ with open('version.sip', 'w') as f: f.write(version_sip_template.format( vlen = 'i' * len(python_poppler_qt5_version), vargs = ', '.join(map(format, python_poppler_qt5_version)), pvlen = 'i' * len(poppler_qt5_version), pvargs = ', '.join(map(format, poppler_qt5_version)))) def _sip_compile(self, sip_bin, source, sbf): # First check manually specified poppler version ver = self.poppler_version or pkg_config_version('poppler-qt5') or () # our own version: version = tuple(map(int, re.findall(r'\d+', project['version']))) # make those accessible from the popplerqt5 module: self.write_version_sip(ver, version) # Disable features if older poppler-qt5 version is found. # See the defined tags in %Timeline{} in poppler-qt5.sip. if not ver or ver <= (0, 20, 0): tag = 'POPPLER_V0_20_0' elif ver < (0, 22, 0): tag = 'POPPLER_V0_20_0' elif ver < (0, 24, 0): tag = 'POPPLER_V0_22_0' elif ver < (0, 24, 5): tag = 'POPPLER_V0_24_0' elif ver < (0, 28, 0): tag = 'POPPLER_V0_24_5' else: tag = 'POPPLER_V0_28_0' cmd = [sip_bin] if hasattr(self, 'sip_opts'): cmd += self.sip_opts if hasattr(self, '_sip_sipfiles_dir'): cmd += ['-I', self._sip_sipfiles_dir()] if tag: cmd += ['-t', tag] if not check_qtxml(): cmd += ["-x", "QTXML_AVAILABLE"] # mark QtXml not supported cmd += [ "-c", self.build_temp, "-b", sbf, "-I", self.pyqt_sip_dir] # find the PyQt5 stuff cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5 cmd.append(source) self.spawn(cmd) if platform.system() == 'Windows': # Enforce libraries to link against on Windows ext_args['libraries'] = ['poppler-qt5', 'QtCore4', 'QtGui4', 'QtXml4'] class bdist_support(): def __find_poppler_dll(self): paths = os.environ['PATH'].split(";") poppler_dll = None for path in paths: dll_path_candidate = os.path.join(path, "poppler-qt5.dll") if os.path.exists(dll_path_candidate): return dll_path_candidate return None def _copy_poppler_dll(self): poppler_dll = self.__find_poppler_dll() if poppler_dll is None: self.warn("Could not find poppler-qt5.dll in any of the folders listed in the PATH environment variable.") return False self.mkpath(self.bdist_dir) self.copy_file(poppler_dll, os.path.join(self.bdist_dir, "python-poppler4.dll")) return True import distutils.command.bdist_msi class bdist_msi(distutils.command.bdist_msi.bdist_msi, bdist_support): def run(self): if not self._copy_poppler_dll(): return distutils.command.bdist_msi.bdist_msi.run(self) project['cmdclass']['bdist_msi'] = bdist_msi import distutils.command.bdist_wininst class bdist_wininst(distutils.command.bdist_wininst.bdist_wininst, bdist_support): def run(self): if not self._copy_poppler_dll(): return distutils.command.bdist_wininst.bdist_wininst.run(self) project['cmdclass']['bdist_wininst'] = bdist_wininst import distutils.command.bdist_dumb class bdist_dumb(distutils.command.bdist_dumb.bdist_dumb, bdist_support): def run(self): if not self._copy_poppler_dll(): return distutils.command.bdist_dumb.bdist_dumb.run(self) project['cmdclass']['bdist_dumb'] = bdist_dumb try: # Attempt to patch bdist_egg if the setuptools/distribute extension is installed import setuptools.command.bdist_egg class bdist_egg(setuptools.command.bdist_egg.bdist_egg, bdist_support): def run(self): if not self._copy_poppler_dll(): return setuptools.command.bdist_egg.bdist_egg.run(self) project['cmdclass']['bdist_egg'] = bdist_egg except ImportError: pass version_sip_template = r"""// Generated by setup.py -- Do not edit PyObject *version(); %Docstring The version of the popplerqt5 python module. %End PyObject *poppler_version(); %Docstring The version of the Poppler library. %End %ModuleCode PyObject *version() {{ return Py_BuildValue("({vlen})", {vargs}); }}; PyObject *poppler_version() {{ return Py_BuildValue("({pvlen})", {pvargs}); }}; %End """ ### use full README.rst as long description with open('README.rst', 'rb') as f: project["long_description"] = f.read().decode('utf-8') project['cmdclass']['build_ext'] = build_ext setup( ext_modules = [Extension("popplerqt5", ["poppler-qt5.sip"], **ext_args)], **project ) python-poppler-qt5-0.24.2/poppler-page.sip0000644000175000001440000000436412472655235021267 0ustar wilbertusers00000000000000namespace Poppler { class Page { %TypeHeaderCode #include %End public: ~Page(); enum Rotation { Rotate0 = 0, Rotate90 = 1, Rotate180 = 2, Rotate270 = 3, }; enum PageAction { Opening, Closing, }; enum TextLayout { PhysicalLayout, RawOrderLayout, }; enum PainterFlag { DontSaveAndRestore = 0x00000001, }; typedef QFlags PainterFlags; 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 /ReleaseGIL/; bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0, PainterFlags flags = 0) const /ReleaseGIL/; QImage thumbnail() const; QString text(const QRectF &rect, TextLayout textLayout) const; QString text(const QRectF &rect) const; enum SearchDirection { FromTop, NextResult, PreviousResult, }; enum SearchMode { CaseSensitive, CaseInsensitive, }; %If(POPPLER_V0_22_0 -) QList search(const QString &text, SearchMode caseSensitive, Rotation rotate = Rotate0) const /ReleaseGIL/; %End bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const /ReleaseGIL/; QList textList(Rotation rotate = Rotate0) const; QSizeF pageSizeF() const; QSize pageSize() const; Poppler::PageTransition *transition() const; Poppler::Link *action( PageAction act ) const; enum Orientation { Landscape, Portrait, Seascape, UpsideDown, }; Orientation orientation() const; void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); QList links() const; QList annotations() const; QList formFields() const; double duration() const; QString label() const; private: Page(); Page( const Poppler::Page & ); }; // class Page }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-link.sip0000644000175000001440000001634312473010667021303 0ustar wilbertusers00000000000000struct Ref; class MediaRendition; namespace Poppler { class Link { %TypeHeaderCode #include #include %End public: Link( const QRectF &linkArea ); enum LinkType { None, Goto, Execute, Browse, Action, Sound, Movie, Rendition, JavaScript, }; virtual LinkType linkType() const; virtual ~Link(); QRectF linkArea() const; private: Link(const Poppler::Link&); %ConvertToSubClassCode switch (sipCpp->linkType()) { case Poppler::Link::Goto: sipType = sipType_Poppler_LinkGoto; break; case Poppler::Link::Execute: sipType = sipType_Poppler_LinkExecute; break; case Poppler::Link::Browse: sipType = sipType_Poppler_LinkBrowse; break; case Poppler::Link::Action: sipType = sipType_Poppler_LinkAction; break; case Poppler::Link::Sound: sipType = sipType_Poppler_LinkSound; break; case Poppler::Link::Movie: sipType = sipType_Poppler_LinkMovie; break; case Poppler::Link::Rendition: sipType = sipType_Poppler_LinkRendition; break; case Poppler::Link::JavaScript: sipType = sipType_Poppler_LinkJavaScript; break; default: sipType = sipType_Poppler_Link; } %End }; // class Link class LinkGoto : Poppler::Link { %TypeHeaderCode #include #include %End public: LinkGoto( const QRectF &linkArea, QString extFileName, const Poppler::LinkDestination & destination ); ~LinkGoto(); bool isExternal() const; QString fileName() const; Poppler::LinkDestination destination() const; LinkType linkType() const; private: LinkGoto(const Poppler::LinkGoto&); }; // class LinkGoto class LinkExecute : Poppler::Link { %TypeHeaderCode #include #include %End public: QString fileName() const; QString parameters() const; LinkExecute( const QRectF &linkArea, const QString & file, const QString & params ); ~LinkExecute(); LinkType linkType() const; private: LinkExecute(const Poppler::LinkExecute&); }; // class LinkExecute class LinkBrowse : Poppler::Link { %TypeHeaderCode #include #include %End public: QString url() const; LinkBrowse( const QRectF &linkArea, const QString &url ); ~LinkBrowse(); LinkType linkType() const; private: LinkBrowse(const Poppler::LinkBrowse&); }; // class LinkBrowse class LinkAction : Poppler::Link { %TypeHeaderCode #include #include %End public: enum ActionType { PageFirst = 1, PagePrev = 2, PageNext = 3, PageLast = 4, HistoryBack = 5, HistoryForward = 6, Quit = 7, Presentation = 8, EndPresentation = 9, Find = 10, GoToPage = 11, Close = 12, }; ActionType actionType() const; LinkAction( const QRectF &linkArea, ActionType actionType ); ~LinkAction(); LinkType linkType() const; private: LinkAction(const Poppler::LinkAction&); }; // class LinkAction class LinkSound : Poppler::Link { %TypeHeaderCode #include #include %End public: LinkSound( const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, Poppler::SoundObject *sound ); virtual ~LinkSound(); LinkType linkType() const; double volume() const; bool synchronous() const; bool repeat() const; bool mix() const; Poppler::SoundObject *sound() const; private: LinkSound(const Poppler::LinkSound&); }; // class LinkSound %If(POPPLER_V0_22_0 -) class LinkRendition : Poppler::Link { %TypeHeaderCode #include #include %End public: /** * Describes the possible rendition actions. * * \since 0.22 */ enum RenditionAction { NoRendition, PlayRendition, StopRendition, PauseRendition, ResumeRendition }; /** * Create a new rendition link. * * \param linkArea the active area of the link * \param rendition the media rendition object. Ownership is taken * \param operation the numeric operation (action) (@see ::LinkRendition::RenditionOperation) * \param script the java script code * \param annotationReference the object reference of the screen annotation associated with this rendition action * \since 0.22 */ LinkRendition( const QRectF &linkArea, MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference ); /** * Destructor. */ virtual ~LinkRendition(); LinkType linkType() const; /** * Returns the media rendition object if the redition provides one, @c 0 otherwise */ //MediaRendition *rendition() const; /** * Returns the action that should be executed if a rendition object is provided. * * \since 0.22 */ RenditionAction action() const; /** * The JS code that shall be executed or an empty string. * * \since 0.22 */ QString script() const; /** * Returns whether the given @p annotation is the referenced screen annotation for this rendition @p link. * * \since 0.22 */ bool isReferencedAnnotation( const Poppler::ScreenAnnotation *annotation ) const; }; // class LinkRendition %End class LinkJavaScript : Poppler::Link { %TypeHeaderCode #include #include %End public: LinkJavaScript( const QRectF &linkArea, const QString &js ); virtual ~LinkJavaScript(); LinkType linkType() const; QString script() const; private: LinkJavaScript(const Poppler::LinkJavaScript&); }; // class LinkJavaScript class LinkMovie : Poppler::Link { %Docstring Movie: a movie to be played. %End %TypeHeaderCode #include #include %End public: /** * Describes the operation to be performed on the movie. */ enum Operation { Play, Stop, Pause, Resume }; /** * Create a new Movie link. * * \param linkArea the active area of the link * \param operation the operation to be performed on the movie * \param annotationTitle the title of the movie annotation identifying the movie to be played * \param annotationReference the object reference of the movie annotation identifying the movie to be played * * Note: This constructor is supposed to be used by Poppler::Page only. */ LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference ); /** * Destructor. */ ~LinkMovie(); LinkType linkType() const; /** * Returns the operation to be performed on the movie. */ Operation operation() const; /** * Returns whether the given @p annotation is the referenced movie annotation for this movie @p link. */ bool isReferencedAnnotation( const Poppler::MovieAnnotation *annotation ) const; }; // class LinkMovie }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/PKG-INFO0000644000175000001440000000714312474036060017241 0ustar wilbertusers00000000000000Metadata-Version: 1.1 Name: python-poppler-qt5 Version: 0.24.2 Summary: A Python binding to Poppler-Qt5 Home-page: https://github.com/wbsoft/python-poppler-qt5 Author: Wilbert Berendsen Author-email: wbsoft@xs4all.nl License: LGPL Description: ================== python-poppler-qt5 ================== A Python binding for libpoppler-qt5 that aims for completeness and for being actively maintained. Created and currently maintained by Wilbert Berendsen . Homepage: https://pypi.python.org/pypi/python-poppler-qt5/ Usage:: import popplerqt5 d = popplerqt5.Poppler.Document.load('file.pdf') Documentation ------------- The Python API closely follows the Poppler Qt5 C++ interface library API, documented at http://people.freedesktop.org/~aacid/docs/qt5/ . Note: Releases of PyQt5 < 5.4 currently do not support the QtXml module, all methods that use the QDomDocument, QDomElement and QDomNode types are disabled. This concerns the ``Document::toc()`` method and some constructors and the ``store()`` methods in the ``Annotation`` subclasses. So, using PyQt5 >= 5.4 is recommended. Whereever the C++ API requires ``QList``, ``QSet`` or ``QLinkedList``, any Python sequence can be used. API calls that return ``QList``, ``QSet`` or ``QLinkedList`` all return Python lists. There are a few other differences: ``Poppler::Document::getPdfVersion(int *major, int *minor)`` can simply be called as ``d.getPdfVersion()``, (where ``d`` is a ``Poppler::Document`` instance); it will return a tuple of two integers (major, minor). ``Poppler::Document`` has ``__len__`` and ``__getitem__`` methods, corresponding to ``numPages()`` and ``page(int num)``. ``Poppler::FontIterator`` (returned by ``Poppler::Document::newFontIterator``) is also a Python iterable (e.g. has ``__iter__()`` and ``__next__()`` methods). So although you can use:: it = document.newFontIterator() while it.hasNext(): fonts = it.next() # list of FontInfo objects ... you can also use the more Pythonic:: for fonts in document.newFontIterator(): ... In addition to the Poppler namespace, there are two toplevel module functions: ``popplerqt5.version()`` returns the version of the ``python-poppler-qt5`` package as a tuple of ints, e.g. ``(0, 18, 2)``. ``popplerqt5.poppler_version()`` returns the version of the linked Poppler-Qt5 library as a tuple of ints, e.g. ``(0, 24, 5)``. This is determined at build time. If at build time the Poppler-Qt5 version could not be determined and was not specified, an empty tuple might be returned. Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: POSIX Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Multimedia :: Graphics :: Viewers python-poppler-qt5-0.24.2/poppler-convert.sip0000644000175000001440000000404312472555222022020 0ustar wilbertusers00000000000000namespace Poppler { class BaseConverter { %TypeHeaderCode #include %End public: virtual ~BaseConverter(); void setOutputFileName(const QString &outputFileName); void setOutputDevice(QIODevice *device); virtual bool convert() = 0; enum Error { NoError, FileLockedError, OpenOutputError, NotSupportedInputFileError, }; Error lastError() const; private: BaseConverter(const Poppler::BaseConverter&); }; // class BaseConverter class PSConverter : Poppler::BaseConverter { %TypeHeaderCode #include %End public: enum PSOption { Printing = 0x00000001, StrictMargins = 0x00000002, ForceRasterization = 0x00000004, }; typedef QFlags PSOptions; ~PSConverter(); void setPageList(const QList &pageList); void setTitle(const QString &title); void setHDPI(double hDPI); void setVDPI(double vDPI); void setRotate(int rotate); void setPaperWidth(int paperWidth); void setPaperHeight(int paperHeight); void setRightMargin(int marginRight); void setBottomMargin(int marginBottom); void setLeftMargin(int marginLeft); void setTopMargin(int marginTop); void setStrictMargins(bool strictMargins); void setForceRasterize(bool forceRasterize); void setPSOptions(PSOptions options); PSOptions psOptions() const; bool convert(); private: PSConverter(const Poppler::PSConverter&); }; // class PSConverter class PDFConverter : Poppler::BaseConverter { %TypeHeaderCode #include %End public: enum PDFOption { WithChanges = 0x00000001, }; typedef QFlags PDFOptions; virtual ~PDFConverter(); void setPDFOptions(PDFOptions options); PDFOptions pdfOptions() const; bool convert(); private: PDFConverter(const Poppler::PDFConverter&); }; // class PDFConverter }; // namespace Poppler /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/TODO0000644000175000001440000000067012472206520016630 0ustar wilbertusers00000000000000TODO: - make demo.py working with PyQt5 DONE: - Poppler::Document::newFontIterator() is usable as Python iterable - Poppler::HighlightAnnotation::Quad.points has been fixed - support Poppler::InkAnnotation::inkPaths() and setInkPaths() - cast returned lists of objects like Document::links() to their respective types - convert to and from QLinkedList - test Python versions other than 2.6: 3.2.3 works - add some examples: demo.py added python-poppler-qt5-0.24.2/poppler-sound-object.sip0000644000175000001440000000120212472120505022716 0ustar wilbertusers00000000000000namespace Poppler { class SoundObject { %TypeHeaderCode #include %End public: enum SoundType { External, Embedded, }; enum SoundEncoding { Raw, Signed, muLaw, ALaw, }; // SoundObject(Sound *popplersound); ~SoundObject(); SoundType soundType() const; QString url() const; QByteArray data() const; double samplingRate() const; int channels() const; int bitsPerSample() const; SoundEncoding soundEncoding() const; private: SoundObject(const Poppler::SoundObject&); }; // class SoundObject }; // namespace Poppler python-poppler-qt5-0.24.2/demo.py0000644000175000001440000000177712472120505017445 0ustar wilbertusers00000000000000import sys from PyQt5 import QtGui import popplerqt5 usage = """ Demo to load a PDF and display the first page. Usage: python demo.py file.pdf """ def pdf_view(filename): """Return a Scrollarea showing the first page of the specified PDF file.""" label = QtGui.QLabel() doc = popplerqt5.Poppler.Document.load(filename) doc.setRenderHint(popplerqt5.Poppler.Document.Antialiasing) doc.setRenderHint(popplerqt5.Poppler.Document.TextAntialiasing) page = doc.page(0) image = page.renderToImage() label.setPixmap(QtGui.QPixmap.fromImage(image)) area = QtGui.QScrollArea() area.setWidget(label) area.setWindowTitle(filename) return area def main(): app = QtGui.QApplication(sys.argv) argv = QtGui.QApplication.arguments() if len(argv) < 2: sys.stderr.write(usage) sys.exit(2) filename = argv[-1] view = pdf_view(filename) view.show() sys.exit(app.exec_()) if __name__ == "__main__": main() python-poppler-qt5-0.24.2/types.sip0000644000175000001440000001221612472120505020016 0ustar wilbertusers00000000000000/* * Various conversions that are not made by PyQt5 default. */ /** * Convert QSet * from any Python sequence and to a Python list. */ %MappedType QSet { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. QSet set = *sipCpp; int i = 0; foreach (Poppler::Document::RenderBackend value, set) { PyObject *obj = PyLong_FromLong ((long) value); if (obj == NULL || PyList_SET_ITEM (l, i, obj) < 0) { Py_DECREF(l); if (obj) Py_DECREF(obj); return NULL; } Py_DECREF(obj); i++; } return l; %End %ConvertToTypeCode // Check the type if that is all that is required. if (sipIsErr == NULL) { if (!PySequence_Check(sipPy)) return 0; return 1; } QSet *qs = new QSet; for (int i = 0; i < PySequence_Size(sipPy); ++i) { Poppler::Document::RenderBackend t = (Poppler::Document::RenderBackend)PyLong_AsLong(PySequence_ITEM (sipPy, i)); *qs << t; } *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; /** * Convert QLinkedList from any sequence and to a Python list. */ template %MappedType QLinkedList { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. TYPE item; QLinkedList::iterator i; int index = 0; for (i = sipCpp->begin(); i != sipCpp->end(); ++i) { TYPE *t = new TYPE(*i); PyObject *tobj; if ((tobj = sipConvertFromNewType(t, sipType_TYPE, sipTransferObj)) == NULL) { Py_DECREF(l); delete t; return NULL; } PyList_SET_ITEM(l, index, tobj); ++index; } return l; %End %ConvertToTypeCode SIP_SSIZE_T len; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) < 0) return 0; for (SIP_SSIZE_T i = 0; i < len; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); bool ok = (itm && sipCanConvertToType(itm, sipType_TYPE, SIP_NOT_NONE)); Py_XDECREF(itm); if (!ok) return 0; } return 1; } QLinkedList *qll = new QLinkedList; len = PySequence_Size(sipPy); for (SIP_SSIZE_T i = 0; i < len; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); int state; TYPE *t = reinterpret_cast(sipConvertToType(itm, sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { sipReleaseType(t, sipType_TYPE, state); delete qll; return 0; } qll->append(*t); sipReleaseType(t, sipType_TYPE, state); } *sipCppPtr = qll; return sipGetState(sipTransferObj); %End }; /** * Convert QList> */ template %MappedType QList< QLinkedList > { %TypeHeaderCode #include #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; const sipMappedType* qlinkedlist_type = sipFindMappedType("QLinkedList"); // Set the list elements. for (int i = 0; i < sipCpp->size(); ++i) { QLinkedList* t = new QLinkedList(sipCpp->at(i)); PyObject *tobj; if ((tobj = sipConvertFromMappedType(t, qlinkedlist_type, sipTransferObj)) == NULL) { Py_DECREF(l); delete t; return NULL; } PyList_SET_ITEM(l, i, tobj); } return l; %End %ConvertToTypeCode const sipMappedType* qlinkedlist_type = sipFindMappedType("QLinkedList"); // Check the type if that is all that is required. if (sipIsErr == NULL) { if (!PySequence_Check(sipPy)) return 0; for (int i = 0; i < PySequence_Size(sipPy); ++i) if (!sipCanConvertToMappedType(PySequence_ITEM(sipPy, i), qlinkedlist_type, SIP_NOT_NONE)) return 0; return 1; } QList< QLinkedList > *ql = new QList< QLinkedList >; for (int i = 0; i < PySequence_Size(sipPy); ++i) { int state; QLinkedList * t = reinterpret_cast< QLinkedList * >(sipConvertToMappedType(PySequence_ITEM(sipPy, i), qlinkedlist_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr)); if (*sipIsErr) { sipReleaseInstance(t, sipClass_TYPE, state); delete ql; return 0; } ql->append(*t); sipReleaseInstance(t, sipClass_TYPE, state); } *sipCppPtr = ql; return sipGetState(sipTransferObj); %End }; /* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */ python-poppler-qt5-0.24.2/poppler-opt-content-model.sip0000644000175000001440000000161312472120505023700 0ustar wilbertusers00000000000000namespace Poppler { class OptContentModel : QAbstractItemModel { %TypeHeaderCode #include #include %End public: virtual ~OptContentModel(); QModelIndex index(int row, int column, const QModelIndex &parent) const; QModelIndex parent(const QModelIndex &child) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); Qt::ItemFlags flags ( const QModelIndex & index ) const; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; private: OptContentModel(const Poppler::OptContentModel&); }; // class OptContentModel }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-font-iterator.sip0000644000175000001440000000133712472120505023130 0ustar wilbertusers00000000000000namespace Poppler { class FontIterator { %TypeHeaderCode #include %End public: ~FontIterator(); QList next(); bool hasNext() const; int currentPage() const; Poppler::FontIterator * __iter__(); %MethodCode sipRes = sipCpp; %End SIP_PYOBJECT __next__(); %MethodCode if (sipCpp->hasNext()) { QList next = sipCpp->next(); sipRes = sipConvertFromType(&next, sipFindType("QList"), Py_None); } else { PyErr_SetNone(PyExc_StopIteration); } %End private: FontIterator(const Poppler::FontIterator&); // FontIterator( int, DocumentData *dd ); }; // class FontIterator }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-movie-object.sip0000644000175000001440000000072512472120505022716 0ustar wilbertusers00000000000000namespace Poppler { class MovieObject { %TypeHeaderCode #include %End public: enum PlayMode { PlayOnce, PlayOpen, PlayRepeat, PlayPalindrome, }; ~MovieObject(); QString url() const; QSize size() const; int rotation() const; bool showControls() const; PlayMode playMode() const; private: MovieObject(const Poppler::MovieObject&); }; // class MovieObject }; // namespace Poppler python-poppler-qt5-0.24.2/poppler-link-destination.sip0000644000175000001440000000212212472565511023612 0ustar wilbertusers00000000000000namespace Poppler { class LinkDestination { %Docstring A destination. The LinkDestination class represent a "destination" (in terms of visual viewport to be displayed) for ``Poppler.LinkGoto`` links, and items in the table of contents (TOC) of a document. Coordinates are in 0..1 range. %End %TypeHeaderCode #include #include %End public: enum Kind { destXYZ = 1, destFit = 2, destFitH = 3, destFitV = 4, destFitR = 5, destFitB = 6, destFitBH = 7, destFitBV = 8, }; LinkDestination(const QString &description); LinkDestination(const Poppler::LinkDestination &other); ~LinkDestination(); Kind kind() const; int pageNumber() const; double left() const; double bottom() const; double right() const; double top() const; double zoom() const; bool isChangeLeft() const; bool isChangeTop() const; bool isChangeZoom() const; QString toString() const; QString destinationName() const; }; // class LinkDestination }; // namespace Poppler python-poppler-qt5-0.24.2/ChangeLog0000644000175000001440000000032412472205111017701 0ustar wilbertusers00000000000000Version 0.28.0 -- * Initial release, converted from the python-poppler-qt4 code. * Disabled the methods that use QDomNode, QDomDocument and QDomElement types, those are unfortunately not supported by PyQt5.