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
38 void AddPages(const Document& source, const std::vector<size_t>& pageIndexes = {});
39
40#ifndef SWIG
48 void AddImage(const Graphics::Bitmap& bitmap);
49#endif
50
59 void AddImageFromFile(const std::filesystem::path& imagePath);
60
66 void AddImageFromMemory(const void* data, size_t size);
67
73
74 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(DocumentAssembler, PDFDocumentAssembler)
75};
76
78 DocumentAssembler assembler;
79 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerCreate(&assembler));
80 return assembler;
81}
82
83inline void DocumentAssembler::AddPages(const Document& source, const std::vector<size_t>& pageIndexes) {
84 PDPageRange range = {pageIndexes.data(), pageIndexes.size()};
85 const PDPageRange* rangePtr = pageIndexes.empty() ? nullptr : &range;
86 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddPages(m_handle, source.get(), rangePtr));
87}
88
89#ifndef SWIG
91 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImage(m_handle, bitmap.get()));
92}
93#endif
94
95inline void DocumentAssembler::AddImageFromFile(const std::filesystem::path& imagePath) {
96 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImageFromFile(m_handle, imagePath.wstring().c_str()));
97}
98
99inline void DocumentAssembler::AddImageFromMemory(const void* data, size_t size) {
100 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImageFromMemory(m_handle, data, size));
101}
102
104 Document result;
105 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAssemble(m_handle, &result));
106 return result;
107}
108
109} // namespace PDF
110
111#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:77
void AddImageFromMemory(const void *data, size_t size)
Adds an in-memory raw data image to the DocumentAssembler object.
Definition document_assembler.h:99
void AddPages(const Document &source, const std::vector< size_t > &pageIndexes={})
Takes specific pages from a document and adds them to the DocumentAssembler object.
Definition document_assembler.h:83
void AddImage(const Graphics::Bitmap &bitmap)
Adds an image to the DocumentAssembler object.
Definition document_assembler.h:90
void AddImageFromFile(const std::filesystem::path &imagePath)
Adds an image located on the system to the DocumentAssembler object.
Definition document_assembler.h:95
Document Assemble()
Assembles the document.
Definition document_assembler.h:103
Represents a PDF document.
Definition document.h:22
Represents a bitmap.
Definition graphics.h:63
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 PDFDocumentAssemblerCreate(PDFDocumentAssembler *pAssembler)
Creates a new PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAddPages(PDFDocumentAssembler assembler, PDDoc sourceDoc, const PDPageRange *sourcePageIndexes)
Adds a document to the PDFDocumentAssembler object.
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFDocumentAssemblerAssemble(PDFDocumentAssembler assembler, PDDoc *pResultDoc)
Assembles the documents added to the PDFDocumentAssembler object.
Specifies a structure to define a set of pages.
Definition document.h:43