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/bytes.h>
9#include <pdfsdk/cxx/document.h>
10#include <pdfsdk/cxx/graphics.h>
11#include <pdfsdk/cxx/wrapper_base.h>
13
14namespace PDF {
15
24class DocumentAssembler : public detail::RefCountedHandle<PDFDocumentAssembler> {
25public:
29 static DocumentAssembler Create();
30
39 void AddPages(const Document& source, const std::vector<size_t>& pageIndexes = {});
40
41#ifndef SWIG
49 void AddImage(const Graphics::Bitmap& bitmap);
50#endif
51
60 void AddImageFromFile(const std::filesystem::path& imagePath);
61
66 void AddImageFromMemory(std::span<const Byte> data);
67
73
74 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(DocumentAssembler, PDFDocumentAssembler)
75};
76
77inline DocumentAssembler DocumentAssembler::Create() {
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(std::span<const Byte> data) {
100 PDF_CHECK_SUCCESS_X(PDFDocumentAssemblerAddImageFromMemory(m_handle, data.data(), 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_
static DocumentAssembler Create()
Creates a new DocumentAssembler object.
Definition document_assembler.h:77
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
void AddImageFromMemory(std::span< const Byte > data)
Adds an in-memory raw data image to the DocumentAssembler object.
Definition document_assembler.h:99
Document Assemble()
Assembles the document.
Definition document_assembler.h:103
Represents a PDF document.
Definition document.h:27
Represents a bitmap.
Definition graphics.h:69
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:44