mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Encoding tables
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
#include "pdfglobal.h"
|
||||
#include "pdfobject.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace pdf
|
||||
{
|
||||
|
||||
@@ -56,6 +59,10 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/// Returns object from the object storage. If invalid reference is passed,
|
||||
/// then null object is returned (no exception is thrown).
|
||||
const PDFObject& getObject(PDFObjectReference reference) const;
|
||||
|
||||
/// Returns array of objects stored in this storage
|
||||
const PDFObjects& getObjects() const { return m_objects; }
|
||||
|
||||
@@ -70,24 +77,82 @@ private:
|
||||
/// PDF document main class.
|
||||
class PDFDocument
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocument)
|
||||
|
||||
public:
|
||||
explicit PDFDocument() = default;
|
||||
|
||||
const PDFObjectStorage& getStorage() const { return m_pdfObjectStorage; }
|
||||
|
||||
/// Info about the document. Title, Author, Keywords...
|
||||
struct Info
|
||||
{
|
||||
/// Indicates, that document was modified that it includes trapping information.
|
||||
/// See PDF Reference 1.7, Section 10.10.5 "Trapping Support".
|
||||
enum class Trapped
|
||||
{
|
||||
True, ///< Fully trapped
|
||||
False, ///< Not yet trapped
|
||||
Unknown ///< Either unknown, or it has been trapped partly, not fully
|
||||
};
|
||||
|
||||
QString title;
|
||||
QString author;
|
||||
QString subject;
|
||||
QString keywords;
|
||||
QString creator;
|
||||
QString producer;
|
||||
QDateTime creationDate;
|
||||
QDateTime modifiedDate;
|
||||
Trapped trapped = Trapped::Unknown;
|
||||
};
|
||||
|
||||
/// Returns info about the document (title, author, etc.)
|
||||
const Info* getInfo() const { return &m_info; }
|
||||
|
||||
private:
|
||||
friend class PDFDocumentReader;
|
||||
|
||||
explicit PDFDocument(PDFObjectStorage&& storage) :
|
||||
m_pdfObjectStorage(std::move(storage))
|
||||
{
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
/// Initialize data based on object in the storage.
|
||||
/// Can throw exception if error is detected.
|
||||
void init();
|
||||
|
||||
/// Initialize the document info from the trailer dictionary.
|
||||
/// If document info is not present, then default document
|
||||
/// info is used. If error is detected, exception is thrown.
|
||||
void initInfo();
|
||||
|
||||
/// If object is reference, the dereference attempt is performed
|
||||
/// and object is returned. If it is not a reference, then self
|
||||
/// is returned. If dereference attempt fails, then null object
|
||||
/// is returned (no exception is thrown).
|
||||
const PDFObject& getObject(const PDFObject& object) const;
|
||||
|
||||
/// Storage of objects
|
||||
PDFObjectStorage m_pdfObjectStorage;
|
||||
|
||||
/// Info about the PDF document
|
||||
Info m_info;
|
||||
};
|
||||
|
||||
inline
|
||||
const PDFObject& PDFDocument::getObject(const PDFObject& object) const
|
||||
{
|
||||
if (object.isReference())
|
||||
{
|
||||
// Try to dereference the object
|
||||
return m_pdfObjectStorage.getObject(object.getReference());
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
||||
#endif // PDFDOCUMENT_H
|
||||
|
Reference in New Issue
Block a user