QPdfDocument Class

QPdfDocument 클래스는 PDF 문서를 로드하고 페이지를 렌더링합니다. 더 보기...

Header: #include <QPdfDocument>
Inherits: QObject

공용 유형

enum class Error { None, Unknown, DataNotYetAvailable, FileNotFound, InvalidFileFormat, …, UnsupportedSecurityScheme }
enum class MetaDataField { Title, Author, Subject, Keywords, Creator, …, ModificationDate }
enum class PageModelRole { Label, PointSize }
enum class Status { Null, Loading, Ready, Unloading, Error }

속성

공공 기능

QPdfDocument(QObject *parent)
virtual ~QPdfDocument() override
void close()
QPdfDocument::Error error() const
QPdfSelection getAllText(int page)
QPdfSelection getSelection(int page, QPointF start, QPointF end)
QPdfSelection getSelectionAtIndex(int page, int startIndex, int maxLength)
void load(QIODevice *device)
QPdfDocument::Error load(const QString &fileName)
QVariant metaData(QPdfDocument::MetaDataField field) const
int pageCount() const
(since 6.6) int pageIndexForLabel(const QString &label)
QString pageLabel(int page)
QAbstractListModel *pageModel()
QSizeF pagePointSize(int page) 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 pageModelChanged()
void passwordChanged()
void statusChanged(QPdfDocument::Status status)

상세 설명

멤버 유형 문서

enum class QPdfDocument::Error

이 열거형은 문서에서 마지막 작업을 시도하는 동안 발생한 오류를 설명합니다.

Constant설명
QPdfDocument::Error::None0오류가 발생하지 않았습니다.
QPdfDocument::Error::Unknown1알 수 없는 오류 유형입니다.
QPdfDocument::Error::DataNotYetAvailable2문서가 아직 로드 중이므로 작업을 시도하기에는 너무 이르다.
QPdfDocument::Error::FileNotFound3load()에 제공된 파일을 찾을 수 없습니다.
QPdfDocument::Error::InvalidFileFormat4load()에 제공된 파일이 올바른 PDF 파일이 아닙니다.
QPdfDocument::Error::IncorrectPassword5setPassword()에 제공된 비밀번호가 이 파일에 맞지 않습니다.
QPdfDocument::Error::UnsupportedSecurityScheme6QPdfDocument 는 이러한 종류의 PDF 파일의 잠금을 해제할 수 없습니다.

QPdfDocument::error()도 참조하세요 .

enum class QPdfDocument::MetaDataField

이 열거형은 메타 데이터의 사용 가능한 필드를 설명합니다.

ConstantDescription
QPdfDocument::MetaDataField::Title0문서의 제목은 QString 입니다.
QPdfDocument::MetaDataField::Author2문서를 만든 사람의 이름 QString.
QPdfDocument::MetaDataField::Subject1문서의 주제를 QString 로 설정합니다.
QPdfDocument::MetaDataField::Keywords3문서와 관련된 키워드는 QString.
QPdfDocument::MetaDataField::Creator5문서가 다른 형식에서 PDF로 변환된 경우, 변환된 원본 문서를 만든 호환 제품의 이름을 QString 으로 표시합니다.
QPdfDocument::MetaDataField::Producer4문서가 다른 형식에서 PDF로 변환된 경우, 문서를 PDF로 변환한 호환 제품의 이름은 QString 입니다.
QPdfDocument::MetaDataField::CreationDate6문서를 QDateTime 으로 만든 날짜 및 시간.
QPdfDocument::MetaDataField::ModificationDate7문서가 가장 최근에 수정된 날짜와 시간 QDateTime.

QPdfDocument::metaData()도 참조하세요 .

enum class QPdfDocument::PageModelRole

pageModel()의 역할.

ConstantValue설명
QPdfDocument::PageModelRole::LabelQt::UserRole표시 목적으로 사용할 페이지 번호 (QString).
QPdfDocument::PageModelRole::PointSize257포인트 단위의 페이지 크기(1/72인치) (QSizeF).

enum class QPdfDocument::Status

이 열거형은 문서의 현재 상태를 설명합니다.

Constant설명
QPdfDocument::Status::Null0문서가 생성된 후 또는 문서가 닫힌 후의 초기 상태입니다.
QPdfDocument::Status::Loading1load()가 호출된 후 문서가 완전히 로드되기 전의 상태입니다.
QPdfDocument::Status::Ready2문서가 완전히 로드되어 데이터에 액세스할 수 있는 상태입니다.
QPdfDocument::Status::Unloading3열려 있는 문서에서 close()가 호출된 후의 상태입니다. 이 시점에서 문서는 여전히 유효하며 모든 데이터에 액세스할 수 있습니다.
QPdfDocument::Status::Error4로드에 실패한 경우 로드 후 상태입니다.

QPdfDocument::status()도 참조하세요 .

속성 문서

[read-only] pageCount : const int

이 속성은 로드된 문서의 페이지 수(문서가 로드되지 않은 경우 0 )를 저장합니다.

액세스 기능:

int pageCount() const

알림 신호:

void pageCountChanged(int pageCount)

[read-only] pageModel : QAbstractListModel* const

이 속성은 문서의 각 페이지에 대해 하나의 행을 포함하는 페이지별 메타데이터를 제공하기 위해 QAbstractListModel 인스턴스를 보유합니다.

액세스 함수:

QAbstractListModel *pageModel()

알림 신호:

void pageModelChanged()

QPdfDocument::PageModelRole참조하세요 .

password : QString

이 속성은 문서 비밀번호를 저장합니다.

문서가 비밀번호로 보호되어 있는 경우 사용자가 비밀번호를 제공해야 하며 애플리케이션에서 이 속성을 설정해야 합니다. 그렇지 않으면 필요하지 않습니다.

액세스 기능:

QString password() const
void setPassword(const QString &password)

알림 신호:

void passwordChanged()

[read-only] status : const Status

이 속성은 문서의 현재 상태를 저장합니다.

액세스 함수:

QPdfDocument::Status status() const

알림 신호:

void statusChanged(QPdfDocument::Status status)

멤버 함수 문서

[explicit] QPdfDocument::QPdfDocument(QObject *parent)

부모 객체가 있는 새 문서를 작성합니다 parent.

[override virtual noexcept] QPdfDocument::~QPdfDocument()

문서를 삭제합니다.

void QPdfDocument::close()

문서를 닫습니다.

QPdfDocument::Error QPdfDocument::error() const

statusError 인 경우 오류 유형을 반환하고, 오류가 없는 경우 NoError 를 반환합니다.

[invokable] QPdfSelection QPdfDocument::getAllText(int page)

주어진 page 에 있는 모든 텍스트와 그 경계를 반환합니다.

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.

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

주어진 startend 지점 사이에서 찾을 수 있는 지정된 page 의 텍스트에 대한 정보를 반환합니다(있는 경우).

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.

[invokable] QPdfSelection QPdfDocument::getSelectionAtIndex(int page, int startIndex, int maxLength)

지정된 startIndex 에서 시작하여 최대 maxLength 자까지 찾을 수 있는 지정된 page 의 텍스트에 대한 정보를 반환합니다.

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.

void QPdfDocument::load(QIODevice *device)

device 에서 문서 콘텐츠를 로드합니다.

QPdfDocument::Error QPdfDocument::load(const QString &fileName)

fileName 에서 문서 콘텐츠를 로드합니다.

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

주어진 field 에 대한 문서의 메타 데이터를 반환합니다.

[invokable, since 6.6] int QPdfDocument::pageIndexForLabel(const QString &label)

label, 또는 찾을 수 없는 경우 -1 이 있는 페이지의 색인을 반환합니다.

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하십시오.

이 함수는 Qt 6.6에 도입되었습니다.

pageLabel()도 참조하십시오 .

[invokable] QString QPdfDocument::pageLabel(int page)

표시용으로 사용할 page 번호를 반환합니다.

예를 들어 문서에 번호가 다른 여러 섹션이 있을 수 있습니다. 서문은 로마 숫자를 사용하고 본문은 1페이지에서 시작하고 부록은 A1에서 시작하는 경우가 있을 수 있습니다. PDF 뷰어에 페이지 번호가 표시될 때마다 사용자가 혼동하지 않도록 API에서 사용하는 0 기반 페이지 색인 대신 페이지 모서리에 인쇄된 것과 동일한 '번호'를 사용해야 합니다(문서 작성자가 페이지 레이블을 인쇄된 번호와 일치하도록 했다는 가정 하에).

문서에 사용자 지정 페이지 번호가 없는 경우 이 함수는 page + 1 을 반환합니다.

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.

pageIndexForLabel()도 참조하세요 .

[invokable] QSizeF QPdfDocument::pagePointSize(int page) const

page 페이지의 크기를 포인트 단위(1/72인치)로 반환합니다.

참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.

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

제공된 renderOptions 에 따라 pageimageSize 크기의 QImage 로 렌더링합니다.

렌더링된 페이지를 반환하거나 오류가 있는 경우 빈 이미지를 반환합니다.

참고: imageSize 이 PDF 문서의 페이지 가로 세로 비율과 일치하지 않는 경우 페이지가 전체 imageSize 을 덮도록 크기가 조정되어 렌더링됩니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.