PoDoFo  1.0.0-dev
PdfCanvas.h
1 
7 #ifndef PDF_CANVAS_H
8 #define PDF_CANVAS_H
9 
10 #include "PdfDeclarations.h"
11 #include "PdfResources.h"
12 #include "PdfArray.h"
13 #include <podofo/auxiliary/Rect.h>
14 
15 namespace PoDoFo {
16 
17 enum class PdfStreamAppendFlags
18 {
19  None = 0,
20  Prepend = 1,
21  NoSaveRestorePrior = 2
22 };
23 
27 class PODOFO_API PdfCanvas
28 {
29 public:
33  virtual ~PdfCanvas();
34 
40  const PdfObject* GetContentsObject() const;
41  PdfObject* GetContentsObject();
42 
46  virtual PdfObjectStream& GetOrCreateContentsStream(PdfStreamAppendFlags flags) = 0;
47 
51 
52  charbuff GetContentsCopy() const;
53 
57  void CopyContentsTo(charbuff& buffer) const;
58  virtual void CopyContentsTo(OutputStream& stream) const = 0;
59 
68  PdfObject* GetFromResources(PdfResourceType type, const std::string_view& key);
69  const PdfObject* GetFromResources(PdfResourceType type, const std::string_view& key) const;
70 
74  PdfResources* GetResources();
75  const PdfResources* GetResources() const;
76 
77  PdfDictionaryElement& GetElement();
78  const PdfDictionaryElement& GetElement() const;
79 
84 
87  virtual void EnsureResourcesCreated() = 0;
88 
92  virtual Rect GetRectRaw() const = 0;
93 
98  virtual bool HasRotation(double& teta) const = 0;
99 
100 protected:
101  virtual PdfObject* getContentsObject() = 0;
102  virtual PdfResources* getResources() = 0;
103  virtual PdfDictionaryElement& getElement() = 0;
104 
105 private:
106  PdfObject* getFromResources(PdfResourceType type, const std::string_view& key);
107 };
108 
109 };
110 
111 ENABLE_BITMASK_OPERATORS(PoDoFo::PdfStreamAppendFlags);
112 
113 #endif // PDF_CANVAS_H
SPDX-FileCopyrightText: (C) 2005 Dominik Seichter domseichter@web.de SPDX-FileCopyrightText: (C) 2020...
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
A interface that provides the necessary features for a painter to draw onto a PdfObject.
Definition: PdfCanvas.h:28
virtual PdfObjectStream & GetOrCreateContentsStream(PdfStreamAppendFlags flags)=0
Get access an object that you can use to ADD drawing to.
virtual PdfResources & GetOrCreateResources()=0
Get or create the resource object of this page.
virtual Rect GetRectRaw() const =0
Get the current canvas size in PDF Units.
virtual PdfObjectStream & ResetContentsStream()=0
Reset the contents object and create a new stream for appending.
virtual void EnsureResourcesCreated()=0
Ensure resources initialized on this canvas.
PdfObject * GetFromResources(PdfResourceType type, const std::string_view &key)
Get an element from the pages resources dictionary, using a type (category) and a key.
virtual bool HasRotation(double &teta) const =0
Get the current canvas rotation.
A PDF stream can be appended to any PdfObject and can contain arbitrary data.
Definition: PdfObjectStream.h:87
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A interface that provides a wrapper around /Resources.
Definition: PdfResources.h:25
A rectangle defined by position and size.
Definition: Rect.h:20
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition: basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
@ None
Do not add a default appearrance.