PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
document_assembler.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_DOCUMENT_ASSEMBLER_H_INCLUDED_
4#define PDFSDK_CXX_DOCUMENT_ASSEMBLER_H_INCLUDED_
5
6#include <filesystem>
7
8#include <pdfsdk/cxx/document.h>
9#include <pdfsdk/cxx/graphics.h>
10#include <pdfsdk/cxx/wrapper_base.h>
12
13namespace PDF {
14
23class DocumentAssembler : public detail::RefCountedHandle<PDFDocumentAssembler> {
24public:
29
36 void AddPages(const Document& source);
37
47 void AddPages(const Document& source, const PDPageRange& page_range);
48
49#ifndef SWIG
58 void AddPages(const Document& source, const std::vector<size_t>& page_indices);
59#endif
60
61#ifndef SWIG
69 void AddImage(const Graphics::Bitmap& bitmap);
70#endif
71
80 void AddImageFromFile(const std::filesystem::path& image_path);
81
87 void AddImageFromMemory(const void* data, size_t size);
88
94
95 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(DocumentAssembler, PDFDocumentAssembler)
96};
97
99 DocumentAssembler assembler;
100 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerCreate(&assembler));
101 return assembler;
102}
103
104inline void DocumentAssembler::AddPages(const Document& source) {
105 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddPages(m_handle, source.get(), nullptr));
106}
107
108void DocumentAssembler::AddPages(const Document& source, const PDPageRange& page_range) {
109 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddPages(m_handle, source.get(), &page_range));
110}
111
112#ifndef SWIG
113inline void DocumentAssembler::AddPages(const Document& source, const std::vector<size_t>& page_indices) {
114 PDPageRange source_range = {
115 .iPages = page_indices.data(),
116 .numPages = page_indices.size()};
117 AddPages(source, source_range);
118}
119#endif
120
121#ifndef SWIG
123 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImage(m_handle, bitmap.get()));
124}
125#endif
126
127inline void DocumentAssembler::AddImageFromFile(const std::filesystem::path& image_path) {
128 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImageFromFile(m_handle, image_path.wstring().c_str()));
129}
130
131inline void DocumentAssembler::AddImageFromMemory(const void* data, size_t size) {
132 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImageFromMemory(m_handle, data, size));
133}
134
136 Document result;
137 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAssemble(m_handle, &result));
138 return result;
139}
140
141} // namespace PDF
142
143#endif // PDFSDK_CXX_DOCUMENT_ASSEMBLER_H_INCLUDED_
Assembles PDF documents.
Definition document_assembler.h:23
static DocumentAssembler Create()
Creates a new DocumentAssembler object.
Definition document_assembler.h:98
void AddImageFromFile(const std::filesystem::path &image_path)
Adds an image located on the system to the DocumentAssembler object.
Definition document_assembler.h:127
void AddImageFromMemory(const void *data, size_t size)
Adds an in-memory raw data image to the DocumentAssembler object.
Definition document_assembler.h:131
void AddImage(const Graphics::Bitmap &bitmap)
Adds an image to the DocumentAssembler object.
Definition document_assembler.h:122
void AddPages(const Document &source)
Adds a document to the DocumentAssembler object.
Definition document_assembler.h:104
Document Assemble()
Assembles the document.
Definition document_assembler.h:135
Represents a PDF document.
Definition document.h:22
Represents a bitmap.
Definition graphics.h:61
The PDF Document Assembler API.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAddImageFromFile(PDFDocumentAssembler assembler, const wchar_t *filePath)
Adds an image to the PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAddImageFromMemory(PDFDocumentAssembler assembler, const void *data, size_t size)
Adds an image to the PDFDocumentAssembler object.
struct PDFDocumentAssemblerRec_ * PDFDocumentAssembler
The opaque handle to the PDFDocumentAssembler object.
Definition document_assembler.h:35
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAddImage(PDFDocumentAssembler assembler, GXBitmap bitmap)
Adds an image to the PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAddPages(PDFDocumentAssembler assembler, PDDoc sourceDoc, const PDPageRange *sourcePageIndices)
Adds a document to the PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerCreate(PDFDocumentAssembler *pAssembler)
Creates a new PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAssemble(PDFDocumentAssembler assembler, PDDoc *pResultDoc)
Assembles the documents added to the PDFDocumentAssembler object.
Definition document.h:37