PDF SDK Documentation

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

Loading...
Searching...
No Matches
optional_content.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_OPTIONAL_CONTENT_H_INCLUDED_
4#define PDFSDK_CXX_OPTIONAL_CONTENT_H_INCLUDED_
5
6#include <string>
7#include <vector>
8
10
11#include "forward_declarations.h"
12#include "wrapper_base.h"
13
14namespace PDF {
15
24class OCGroup : public detail::RefCountedHandle<PDOCG> {
25public:
31 static OCGroup CreateFromPdfObject(const Object& object);
32
38
44 bool Equals(const OCGroup& that) const;
45
50 void SetName(const std::wstring& name);
51
56 std::wstring GetName() const;
57
63
73 void SetUsageEntry(PDOCUsageCategory category, const Object& entry);
74
83
84 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(OCGroup, PDOCG)
85};
86
96class OCMembership : public detail::RefCountedHandle<PDOCMD> {
97public:
103 static OCMembership CreateFromPdfObject(const Object& object);
104
114 static OCMembership CreateFromGroups(const std::vector<OCGroup>& ocgs, PDOCVisibilityPolicy policy = kPDOCVisibilityPolicyAnyOn);
115
121
130 bool IsVisible(const OCContext& context) const;
131
139
145
150 std::vector<OCGroup> GetOCGs() const;
151
152 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(OCMembership, PDOCMD)
153};
154
160class OCConfig : public detail::RefCountedHandle<PDOCConfig> {
161public:
167 static OCConfig CreateFromPdfObject(const Object& object);
168
174
187 void AddOrderEntry(const OCGroup& ocg);
188
194
208 void SetInitialState(const OCGroup& ocg, bool state, bool preserveRB = true);
209
219 bool GetInitialState(const OCGroup& ocg) const;
220
232 void AddAutoState(PDOCUsageEvent event, const std::vector<OCGroup>& ocgs, const std::vector<PDOCUsageCategory>& categories = {});
233
242 void SetLocked(const OCGroup& ocg, bool locked);
243
250 bool IsLocked(const OCGroup& ocg) const;
251
252 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(OCConfig, PDOCConfig)
253};
254
288class OCContext : public detail::RefCountedHandle<PDOCContext> {
289public:
296 static OCContext Create(const OCConfig& config);
297
307 static OCContext CreateWithAutoStates(const OCConfig& config, PDOCUsageEvent event);
308
313 OCContext Copy() const;
314
323 OCContext CopyWithAutoStates(PDOCUsageEvent event) const;
324
330 bool GetState(const OCGroup& ocg) const;
331
339 void SetState(const OCGroup& ocg, bool state, bool preserveRB = true);
340
345 void ResetStates(bool all_on);
346
366
377 template<class Evaluator>
378 bool ApplyRuntimeAutoStates(PDOCUsageEvent event, Evaluator&& evaluator);
379
385
391
396 void SetNonOCDrawing(bool draw);
397
402 bool GetNonOCDrawing() const;
403
410 void CommitTo(const OCConfig& config) const;
411
412 PDF_CXX_CORE_WRAPPER_DEFINE_MEMBERS_(OCContext, PDOCContext)
413};
414
415} // namespace PDF
416
417#include "optional_content_impl.inl"
418
419#endif // PDFSDK_CXX_OPTIONAL_CONTENT_H_INCLUDED_
Optional content configuration.
Definition optional_content.h:160
void AddOrderEntry(const OCGroup &ocg)
Object GetPdfObject() const
bool IsLocked(const OCGroup &ocg) const
void AddAutoState(PDOCUsageEvent event, const std::vector< OCGroup > &ocgs, const std::vector< PDOCUsageCategory > &categories={})
void SetInitialState(const OCGroup &ocg, bool state, bool preserveRB=true)
bool GetInitialState(const OCGroup &ocg) const
Object GetOrder() const
void SetLocked(const OCGroup &ocg, bool locked)
static OCConfig CreateFromPdfObject(const Object &object)
A runtime optional-content visibility context for a document.
Definition optional_content.h:288
void SetDrawMode(PDOCDrawMode mode)
void SetState(const OCGroup &ocg, bool state, bool preserveRB=true)
bool ApplyAutoStates(PDOCUsageEvent event)
PDOCDrawMode GetDrawMode() const
bool ApplyRuntimeAutoStates(PDOCUsageEvent event, Evaluator &&evaluator)
void CommitTo(const OCConfig &config) const
OCContext CopyWithAutoStates(PDOCUsageEvent event) const
void ResetStates(bool all_on)
void SetNonOCDrawing(bool draw)
bool GetNonOCDrawing() const
static OCContext CreateWithAutoStates(const OCConfig &config, PDOCUsageEvent event)
static OCContext Create(const OCConfig &config)
bool GetState(const OCGroup &ocg) const
OCContext Copy() const
Optional content group (OCG).
Definition optional_content.h:24
void SetUsageEntry(PDOCUsageCategory category, const Object &entry)
Object GetPdfObject() const
std::wstring GetName() const
void SetName(const std::wstring &name)
bool Equals(const OCGroup &that) const
OCMembership CreateOCMembership() const
static OCGroup CreateFromPdfObject(const Object &object)
Object GetUsageEntry(PDOCUsageCategory category) const
Optional content membership dictionary (OCMD).
Definition optional_content.h:96
PDOCVisibilityPolicy GetVisibilityPolicy() const
static OCMembership CreateFromGroups(const std::vector< OCGroup > &ocgs, PDOCVisibilityPolicy policy=kPDOCVisibilityPolicyAnyOn)
static OCMembership CreateFromPdfObject(const Object &object)
Object GetPdfObject() const
void SetVisibilityPolicy(PDOCVisibilityPolicy policy)
std::vector< OCGroup > GetOCGs() const
bool IsVisible(const OCContext &context) const
Represents a PDF object.
Definition object.h:25
Optional Content API.
struct PDOCContextRec_ * PDOCContext
A runtime optional-content visibility context.
Definition optional_content.h:71
struct PDOCMDRec_ * PDOCMD
Represents an optional content membership dictionary.
Definition optional_content.h:40
struct PDOCConfigRec_ * PDOCConfig
Definition optional_content.h:59
PDOCDrawMode
Controls how optional content is drawn or enumerated for a context.
Definition optional_content.h:79
struct PDOCGRec_ * PDOCG
Represents an optional content group (OCG) in a PDF document.
Definition optional_content.h:28
PDOCVisibilityPolicy
The visibility policy of an optional content membership dictionary (OCMD).
Definition optional_content.h:126
@ kPDOCVisibilityPolicyAnyOn
Definition optional_content.h:127
PDOCUsageEvent
A usage event: the situation in which a document is being used — viewed on screen,...
Definition optional_content.h:92
PDOCUsageCategory
A category of an optional-content group's usage (/Usage) dictionary.
Definition optional_content.h:104