QPdfDocument 类

QPdfDocument 类加载 PDF 文档并渲染其页面。 更多...

头: #include <QPdfDocument>
Since: Qt 5.10
继承: QObject

该类在 Qt 5.10 引入。

公共类型

enum MetaDataField { Title, Author, Subject, Keywords, Creator, …, ModificationDate }
enum Status { Null, Loading, Ready, Unloading, Error }

公共函数

QPdfDocument (QObject * parent = nullptr)
virtual ~QPdfDocument ()
void close ()
QPdfSelection getAllText (int page )
QPdfSelection getSelection (int page , QPointF start , QPointF end )
QPdfSelection getSelectionAtIndex (int page , int startIndex , int maxLength )
QVariant metaData (QPdfDocument::MetaDataField field ) const
int pageCount () const
QString password () const
QImage render (int page , QSize imageSize , QPdfDocumentRenderOptions renderOptions = QPdfDocumentRenderOptions())
void setPassword (const QString & password )
QPdfDocument::Status status () const

信号

void pageCountChanged (int pageCount )
void passwordChanged ()
void statusChanged (QPdfDocument::Status status )

详细描述

成员类型文档编制

enum QPdfDocument:: MetaDataField

此枚举描述元数据的可用字段。

常量 描述
QPdfDocument::Title 0 文档的标题作为 QString .
QPdfDocument::Author 2 The name of the person who created the document as QString .
QPdfDocument::Subject 1 The subject of the document as QString .
QPdfDocument::Keywords 3 Keywords associated with the document as QString .
QPdfDocument::Creator 5 If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted as QString .
QPdfDocument::Producer 4 If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF as QString .
QPdfDocument::CreationDate 6 The date and time the document was created as QDateTime .
QPdfDocument::ModificationDate 7 The date and time the document was most recently modified as QDateTime .

另请参阅 QPdfDocument::metaData ().

enum QPdfDocument:: Status

此枚举描述文档的当前状态。

常量 描述
QPdfDocument::Null 0 The initial status after the document has been created or after it has been closed.
QPdfDocument::Loading 1 The status after load() has been called and before the document is fully loaded.
QPdfDocument::Ready 2 The status when the document is fully loaded and its data can be accessed.
QPdfDocument::Unloading 3 The status after close () has been called on an open document. At this point the document is still valid and all its data can be accessed.
QPdfDocument::Error 4 加载后的状态,若加载失败。

另请参阅 QPdfDocument::status ().

成员函数文档编制

QPdfDocument:: QPdfDocument ( QObject * parent = nullptr)

构造新文档采用父级对象 parent .

[virtual] QPdfDocument:: ~QPdfDocument ()

销毁文档。

void QPdfDocument:: close ()

关闭文档。

QPdfSelection QPdfDocument:: getAllText ( int page )

返回所有文本及其边界在给定 page .

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

QPdfSelection QPdfDocument:: getSelection ( int page , QPointF start , QPointF end )

Returns information about the text on the given page that can be found between the given start and end points, if any.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

QPdfSelection QPdfDocument:: getSelectionAtIndex ( int page , int startIndex , int maxLength )

Returns information about the text on the given page that can be found beginning at the given startIndex with at most maxLength characters.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

QVariant QPdfDocument:: metaData ( QPdfDocument::MetaDataField field ) const

Returns the meta data of the document for the given field .

int QPdfDocument:: pageCount () const

Returns the amount of pages for the loaded document or 0 若未加载文档。

注意: Getter 函数对于特性 pageCount。

QImage QPdfDocument:: render ( int page , QSize imageSize , QPdfDocumentRenderOptions renderOptions = QPdfDocumentRenderOptions())

渲染 page QImage 的大小 imageSize according to the provided renderOptions .

Returns the rendered page or an empty image in case of an error.

注意:若 imageSize does not match the aspect ratio of the page in the PDF document, the page is rendered scaled, so that it covers the complete imageSize .

QPdfDocument::Status QPdfDocument:: status () const

Returns the current status of the document.

注意: Getter 函数对于特性 status。