10 #include "PdfElement.h"
12 #include <podofo/auxiliary/Matrix.h>
13 #include <podofo/auxiliary/Rect.h>
19 class PdfXObjectPostScript;
29 class PODOFO_API
PdfXObject :
public PdfDictionaryElement
31 friend class PdfXObjectForm;
33 friend class PdfXObjectPostScript;
41 static bool TryCreateFromObject(
PdfObject& obj, std::unique_ptr<PdfXObject>& xobj);
43 static bool TryCreateFromObject(
const PdfObject& obj, std::unique_ptr<const PdfXObject>& xobj);
45 template <
typename XObjectT>
46 static bool TryCreateFromObject(
PdfObject& obj, std::unique_ptr<XObjectT>& xobj);
48 template <
typename XObjectT>
49 static bool TryCreateFromObject(
const PdfObject& obj, std::unique_ptr<const XObjectT>& xobj);
51 virtual Rect GetRect()
const = 0;
53 Matrix GetMatrix()
const;
55 inline PdfXObjectType GetType()
const {
return m_Type; }
59 static std::unique_ptr<PdfXObject> CreateFromObject(
const PdfObject& obj, PdfXObjectType reqType, PdfXObjectType& detectedType);
61 static PdfXObject* createFromObject(
const PdfObject& obj, PdfXObjectType reqType, PdfXObjectType& detectedType);
62 static PdfXObjectType getPdfXObjectType(
const PdfObject& obj);
63 template <
typename TXObject>
64 static constexpr PdfXObjectType GetXObjectType();
67 PdfXObjectType m_Type;
70 template<
typename XObjectT>
71 inline bool PdfXObject::TryCreateFromObject(
PdfObject& obj, std::unique_ptr<XObjectT>& xobj)
73 PdfXObjectType detectedType;
74 xobj.reset((XObjectT*)createFromObject(obj, GetXObjectType<XObjectT>(), detectedType));
75 return xobj !=
nullptr;
78 template<
typename XObjectT>
79 inline bool PdfXObject::TryCreateFromObject(
const PdfObject& obj, std::unique_ptr<const XObjectT>& xobj)
81 PdfXObjectType detectedType;
82 xobj.reset((
const XObjectT*)createFromObject(obj, GetXObjectType<XObjectT>(), detectedType));
83 return xobj !=
nullptr;
86 template<
typename TXObject>
87 constexpr PdfXObjectType PdfXObject::GetXObjectType()
89 if (std::is_same_v<TXObject, PdfXObjectForm>)
90 return PdfXObjectType::Form;
91 else if (std::is_same_v<TXObject, PdfImage>)
92 return PdfXObjectType::Image;
93 else if (std::is_same_v<TXObject, PdfXObjectPostScript>)
94 return PdfXObjectType::PostScript;
96 return PdfXObjectType::Unknown;
Reader class to read content streams.
Definition: PdfContentStreamReader.h:82
PdfDocument is the core interface for working with PDF documents.
Definition: PdfDocument.h:108
A PdfImage object is needed when ever you want to embed an image file into a PDF document.
Definition: PdfImage.h:44
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A XObject is a content stream with several drawing commands and data which can be used throughout a P...
Definition: PdfXObject.h:30
A rectangle defined by position and size.
Definition: Rect.h:20
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16