PoDoFo  1.0.0-dev
PdfResources.h
1 
7 #ifndef PDF_RESOURCES_H
8 #define PDF_RESOURCES_H
9 
10 #include "PdfElement.h"
11 #include "PdfResourceOperations.h"
12 
13 namespace PoDoFo {
14 
15 class PdfFont;
16 class PdfCanvas;
17 
24 class PODOFO_API PdfResources final : public PdfDictionaryElement, public PdfResourceOperations
25 {
26  friend class PdfPage;
27  friend class PdfXObjectForm;
28  friend class PdfPainter;
29  friend class PdfAcroForm;
30  friend class PdfAnnotation;
31 
32 private:
34  PdfResources(PdfObject& obj);
35  PdfResources(PdfCanvas& canvas);
36 
37 public:
38  static bool TryCreateFromObject(PdfObject& obj, std::unique_ptr<PdfResources>& resources);
39 
40  const PdfFont* GetFont(const std::string_view& name) const;
41 
42  PdfObject* GetResource(PdfResourceType type, const std::string_view& key) override;
43  const PdfObject* GetResource(PdfResourceType type, const std::string_view& key) const override;
44  PdfDictionaryIndirectIterable GetResourceIterator(PdfResourceType type) override;
45  PdfDictionaryConstIndirectIterable GetResourceIterator(PdfResourceType type) const override;
46 
47 private:
48  PdfName AddResource(PdfResourceType type, const PdfObject& obj) override;
49  void AddResource(PdfResourceType type, const PdfName& key, const PdfObject& obj) override;
50  void RemoveResource(PdfResourceType type, const std::string_view& key) override;
51  void RemoveResources(PdfResourceType type) override;
52  PdfName AddResource(const PdfName& type, const PdfObject& obj) override;
53  void AddResource(const PdfName& type, const PdfName& key, const PdfObject& obj) override;
54  PdfDictionaryIndirectIterable GetResourceIterator(const std::string_view& type) override;
55  PdfDictionaryConstIndirectIterable GetResourceIterator(const std::string_view& type) const override;
56  void RemoveResource(const std::string_view& type, const std::string_view& key) override;
57  void RemoveResources(const std::string_view& type) override;
58  PdfObject* GetResource(const std::string_view& type, const std::string_view& key) override;
59  const PdfObject* GetResource(const std::string_view& type, const std::string_view& key) const override;
60 
61 private:
62  PdfName addResource(PdfResourceType type, const PdfName& typeName, const PdfObject& obj);
63  PdfObject* getResource(const std::string_view& type, const std::string_view& key) const;
64  bool tryGetDictionary(const std::string_view& type, PdfDictionary*& dict) const;
65  PdfDictionary& getOrCreateDictionary(const PdfName& type);
66 
67 private:
68  std::array<unsigned, (unsigned)PdfResourceType::Properties> m_currResourceIds;
69 };
70 
71 };
72 
73 #endif // PDF_RESOURCES_H
An annotation to a PdfPage To create an annotation use PdfPage::CreateAnnotation.
Definition: PdfAnnotation.h:63
A interface that provides the necessary features for a painter to draw onto a PdfObject.
Definition: PdfCanvas.h:28
Helper class to iterate through indirect objects.
Definition: PdfDictionary.h:22
The PDF dictionary data type of PoDoFo (inherits from PdfDataContainer, the base class for such repre...
Definition: PdfDictionary.h:82
PdfDocument is the core interface for working with PDF documents.
Definition: PdfDocument.h:108
Before you can draw text on a PDF document, you have to create a font object first.
Definition: PdfFont.h:49
This class represents a PdfName.
Definition: PdfName.h:24
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
PdfPage is one page in the pdf document.
Definition: PdfPage.h:127
This class provides an easy to use painter object which allows you to draw on a PDF page object.
Definition: PdfPainter.h:220
Low level interface for resource handling operations Inherited by PdfResources.
Definition: PdfResourceOperations.h:19
A interface that provides a wrapper around /Resources.
Definition: PdfResources.h:25
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16