3#ifndef PDFSDK_CXX_PDF_DOCUMENT_H_INCLUDED_
4#define PDFSDK_CXX_PDF_DOCUMENT_H_INCLUDED_
10#include <pdfsdk/cxx/math.h>
11#include <pdfsdk/cxx/progress_monitor.h>
13#include "forward_declarations.h"
14#include "standard_security.h"
15#include "wrapper_base.h"
22class Document :
public detail::RefCountedHandle<PDDoc> {
39 static Document OpenDocument(
const std::filesystem::path& path,
const std::wstring& password = std::wstring());
52 static Document OpenDocument(
const void* data,
size_t size,
bool copy =
false,
const std::wstring& password = std::wstring());
97 void Save(
const std::filesystem::path& path,
98 PDDocSaveFlags flags = kPDDocSaveFull | kPDDocSaveCompressed,
349 PDETilingPatternTilingType tilingType,
673 template<
class EnumProc>
703 template<
class EnumProc>
850 Annot CreateInkAnnot(PDColorValue color,
float lineWidth,
const std::vector<std::vector<PointF>>& points);
1073 bool RequestPermission(PDPermReqObj
object, PDPermReqOp operation,
const std::wstring& password = std::wstring())
const;
1104 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(
Document, PDDoc)
1109#include "document_impl.inl"
Represents an action in a PDF document.
Definition action.h:21
Represents an annotation in a PDF document.
Definition annot.h:19
Represents a bookmark in a PDF document.
Definition bookmark.h:20
Represents the content of a PDF page.
Definition content.h:20
Represents a destination in a PDF document.
Definition dest.h:23
Represents a PDF document.
Definition document.h:22
Bookmark CreateRootBookmark()
Creates a root bookmark for the document.
Action CreateActionGoTo(Dest dest)
Creates a GoTo action with the specified destination.
Action GetOpenAction() const
Gets the open action of the document.
void AddAttachment(const std::wstring &name, FileSpec filespec)
Adds an attachment to the document.
Dest CreateDestFitV(size_t pageIndex, float left, bool isRemote=false)
Creates a destination that fits the height of the page.
Pattern CreatePatternShading(const Shading &shading)
Creates a pattern object in the document using the specified pattern shading. A shading pattern objec...
OCGroup GetOCGroup(size_t index) const
Gets the optional content (OC) group at the specified index.
std::wstring GetInfoString(PDAtom infoStringAtom) const
Gets the information string associated with the specified info string atom.
Object CreateStringObjectUnicode(const std::wstring &unicode, bool indirect=false)
Creates a literal string object from a Unicode string.
Annot CreateStampAnnot(const RectF &rect, const XObject &appearance)
Creates a (rubber) stamp annotation with the specified rectangle and appearance.
Object CreateRealObject(float value, bool indirect=false)
Creates a real number object.
FileSpec CreateEmbeddedFile(const std::wstring &path)
Creates an embedded file with the specified path.
void MovePages(size_t insertAt, const PDPageRange &range, ProgressMonitor *mon=nullptr)
Moves pages within the document to a new position.
static Document OpenDocument(const std::filesystem::path &path, const std::wstring &password=std::wstring())
A function to open a PDF file.
bool IsCompressed() const
Checks if the document is compressed.
Object CreateIntObject(int64_t value, bool indirect=false)
Creates an integer value object.
void CreatePages(size_t insertAt, size_t count, const RectF &mediaBox)
Creates multiple pages starting at the specified index with the given media box.
Object CreateDictObject(bool indirect)
Creates a dictionary object.
void RemoveDocLevelJS()
Removes the document-level JavaScript actions.
std::wstring GetAttachmentNameByIndex(size_t index) const
Gets the name of the attachment at the specified index.
Dest CreateDestXYZ(size_t pageIndex, const PointF &xy, float zoom, bool isRemote=false)
Creates a destination with XYZ coordinates and zoom level.
Pattern CreatePatternTiling(PDETilingPatternPaintType paintType, PDETilingPatternTilingType tilingType, const RectF &bbox, float xStep, float yStep, const Content &content)
Creates a pattern object in the document using the specified pattern paint type.
Dest CreateDestFitBH(size_t pageIndex, float top, bool isRemote=false)
Creates a destination that fits the width of the bounding box of the page.
void SetModDate(const PDDateTime &date)
Sets the modification date of the document.
std::filesystem::path GetFilePath() const
Gets the file path of the document.
Dest CreateDestFit(size_t pageIndex, bool isRemote=false)
Creates a destination that fits the entire page.
Action CreateActionJavaScript(const std::wstring &jscode)
Creates a JavaScript action with the specified JavaScript code.
size_t GetNumPages() const
Gets the number of pages in the document.
void SetPageLayout(PDAtom layout)
Sets the page layout of the document.
Dest CreateDestFitH(size_t pageIndex, float top, bool isRemote=false)
Creates a destination that fits the width of the page.
Object CreateBoolObject(bool value, bool indirect=false)
Creates a boolean value object.
Object GetInfoObject() const
Gets the info object of the document.
static Document NewDocument()
A function to create an empty PDF file.
OCGroup CreateOCGroup(const std::wstring &name)
Creates an optional content (OC) group with the specified name.
size_t GetNumOCGroups() const
Gets the number of optional content (OC) groups in the document.
FormField FindField(const std::wstring &fullname) const
Finds a form field with the specified full name.
Action GetDocLevelJSAction(const std::wstring &name) const
Gets the document-level JavaScript action with the specified name.
void SetOpenDestination(Dest dest)
Sets the open destination for the document.
StdSecurityParams GetStandardSecurityParams() const
Gets the standard security parameters of the document.
Annot CreateTextAnnot(const RectF &rect)
Creates a text annotation with the specified dimensions.
Dest CreateDestFitBV(size_t pageIndex, float left, bool isRemote=false)
Creates a destination that fits the height of the bounding box of the page.
Annot CreateFreeTextAnnot(const RectF &rect)
Creates a free text annotation with the specified rectangle.
void SetOpenAction(Action action)
Sets the open action for the document.
void EnumDocLevelJSActions(EnumProc enumProc) const
Enumerates the document-level JavaScript actions.
void SetInfoString(PDAtom infoStringAtom, const std::wstring &string)
Sets the information string associated with the specified info string atom.
Object GetRootObject() const
Gets the root object of the document.
PDPageDirection GetPageDirection() const
Gets the page direction of the document.
void DeletePage(size_t index)
Deletes the page at the specified index.
Object CreateNameObject(PDAtom value, bool indirect=false)
Creates a name object.
FileSpec GetAttachment(const std::wstring &name) const
Gets the attachment with the specified name.
Action CreateActionHide()
Creates a Hide action.
PDDateTime GetModDate() const
Gets the modification date of the document.
void RemoveAttachment(const std::wstring &name)
Removes the attachment with the specified name.
Font CreateFontInDoc(const PDFontInfo &fontInfo, bool needSubset=true, bool forceSysFont=true)
Creates a font in the document using the specified font information.
Page GetPage(size_t index) const
Gets the page at the specified index.
XObject ImportIcon(const Document &source, size_t pageIndex=0)
Imports an icon from another document.
PDAtom GetPageLayout() const
Gets the page layout of the document.
void InsertPages(size_t insertAt, const Document &sourceDoc, const PDPageRange &sourceRange, ProgressMonitor *mon=nullptr)
Inserts pages from another document into the current document.
static Document OpenDocument(const void *data, size_t size, bool copy=false, const std::wstring &password=std::wstring())
A function to open a PDF file from a memory buffer.
Dest CreateDestFitR(size_t pageIndex, const RectF &rect, bool isRemote=false)
Creates a destination that fits the specified rectangle on the page.
Action CreateActionResetForm()
Creates a ResetForm action.
void CreatePageFromIcon(size_t insertAt, const Document &iconDoc, const XObject &icon)
Creates a page from an icon.
Action CreateActionNamed(PDAtom name)
Creates a Named action with the specified name.
Dest GetOpenDestination() const
Gets the open destination of the document.
PDAtom GetPageMode() const
Gets the page mode of the document.
FormField GetField(size_t index) const
Gets the form field at the specified index.
size_t GetNumFormFields() const
Gets the number of form fields in the document.
void DeletePages(const PDPageRange &range, ProgressMonitor *mon=nullptr)
Deletes the pages within the specified range.
void SetPageMode(PDAtom mode)
Sets the page mode of the document.
FormField CreateField(const std::wstring &fullname, PDAtom type, PDFieldFlags flags)
Creates a new form field with the specified name, type, and flags.
Annot CreateTextMarkupAnnot(PDAtom type, PDColorValue color, const QuadPoints &quads)
Creates a text markup annotation with the specified type, color, and quad points.
bool IsSigned() const
Checks if the document is signed.
void SetStandardSecurityParams(const StdSecurityParams &requestedParams)
Sets the standard security parameters of the document.
Annot CreateInkAnnot(PDColorValue color, float lineWidth, const std::vector< std::vector< PointF > > &points)
Creates an ink annotation with the specified color, line width, and points.
size_t GetNumAttachments() const
Gets the number of attachments in the document.
Object CreateStringObject(const std::string &bytes, bool hex=false, bool indirect=false)
Creates a string object from a byte string.
void SetModified(bool modified)
Sets the state of the document to modified.
void SaveSignedVersion(FormField sigField, const std::filesystem::path &path) const
Writes to a file the version of the document as it was at the time of signing.
void SetCreationDate(const PDDateTime &date)
Sets the creation date of the document.
Page CreatePage(size_t insertAt, const RectF &mediaBox)
Creates a new page at the specified index with the given media box.
FileSpec CreateFileSpec(PDAtom fileSys, const std::wstring &path)
Creates a FileSpec with the specified file system and path.
void RenameField(FormField field, const std::wstring &fullname)
Renames a specified form field.
Bookmark GetRootBookmark() const
Gets the root bookmark of the document.
Object CreateStreamObject(const void *buffer, size_t bufSize, const Object &attributesDict, const Object &encodeParms, bool encodeSource)
Creates a stream object.
Action CreateActionSubmitForm(const std::string &serverUri)
Creates a SubmitForm action with the specified server URI.
void EnumAttachments(EnumProc enumProc) const
Enumerates the attachments in the document.
void InsertPage(const Page &page, size_t insertAt)
Inserts a page at the specified index.
Object GetObjectByID(uint32_t id) const
Gets the indirect object with the specified ID.
void SetPageDirection(PDPageDirection direction)
Sets the page direction of the document.
Action CreateActionURI(const std::string &uri)
Creates a URI action with the specified URI.
PDDateTime GetCreationDate() const
Gets the creation date of the document.
Object CopyObject(const Object &source)
Copies an object.
void RemoveField(FormField field)
Removes the specified form field from the document.
bool IsModified() const
Checks if the document has been modified.
bool RequestPermission(PDPermReqObj object, PDPermReqOp operation, const std::wstring &password=std::wstring()) const
Requests permission to perform an operation on the document. Permissions can be set either by the doc...
OCConfig GetOCConfig() const
Gets the optional content (OC) configuration of the document.
void Save(const std::filesystem::path &path, PDDocSaveFlags flags=kPDDocSaveFull|kPDDocSaveCompressed, ProgressMonitor *progmon=nullptr, const PDOptSaveSettings *optSettings=nullptr, const PDVersion *version=nullptr)
A function to save a PDF file.
XObject CreateFormXObject(const Content &content)
Creates a form XObject from the specified content stream.
Object CreateArrayObject(bool indirect)
Creates an array object.
void AppendField(FormField field)
Appends a form field to the document.
Dest CreateDestFitB(size_t pageIndex, bool isRemote=false)
Creates a destination that fits the bounding box of the page.
ReadStream OpenXfaStream() const
Opens an XFA (XML Forms Architecture) stream.
Represents a file specification in a PDF document.
Definition filespec.h:21
Represents a font in a PDF document.
Definition font.h:21
Optional content configuration.
Definition optional_content.h:72
Optional content group.
Definition optional_content.h:20
Represents a PDF object.
Definition object.h:20
Represents a leaf node (Page Object).
Definition page.h:20
Represents a shading or tiling pattern in a PDF document.
Definition pattern.h:18
Progress monitor for tracking the progress of an operation.
Definition progress_monitor.h:14
Represents a read stream for reading data.
Definition read_stream.h:15
Represents a shading in a PDF document.
Definition shading.h:17
Represents an XObject in a PDF document.
Definition xobject.h:22
Helper class that represents the data of the Standard Security Handler.
Definition standard_security.h:29
Definition document.h:138