Files
pdf/engine/include/pdfengine/content_object.hpp
T

80 lines
1.6 KiB
C++
Raw Normal View History

2026-06-16 19:06:48 +05:30
#pragma once
#include <string>
#include <vector>
#include <memory>
2026-06-18 16:14:29 +05:30
#include <pdfengine/graphics_state.hpp>
2026-06-22 10:17:51 +05:30
#include <pdfengine/path.hpp>
2026-08-01 16:19:11 +05:30
#include <pdfengine/image_object.hpp>
2026-06-16 19:06:48 +05:30
namespace pdfengine {
enum class ContentObjectType {
Text,
Path,
Image,
Unknown
};
2026-06-18 16:14:29 +05:30
enum class XObjectType {
Image,
Form,
Pattern,
Unknown
};
2026-06-16 19:06:48 +05:30
class ContentObject {
public:
virtual ~ContentObject() = default;
virtual ContentObjectType getType() const = 0;
};
class TextObject : public ContentObject {
public:
ContentObjectType getType() const override { return ContentObjectType::Text; }
2026-06-22 15:18:47 +05:30
std::string text;
std::string fontName;
double fontSize = 0.0;
2026-06-16 19:06:48 +05:30
double tm[6] = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
};
2026-08-01 16:19:11 +05:30
class ImageContentObject : public ContentObject {
2026-06-18 16:14:29 +05:30
public:
ContentObjectType getType() const override { return ContentObjectType::Image; }
2026-08-01 16:19:11 +05:30
std::shared_ptr<const ImageObject> image;
Matrix transform;
// Helper compatibility properties
2026-06-18 16:14:29 +05:30
std::string name;
int width = 0;
int height = 0;
std::string colorSpace;
std::string filter;
int bitsPerComponent = 8;
bool hasSoftMask = false;
std::vector<uint8_t> pixelData;
};
2026-08-01 16:19:11 +05:30
using LegacyImageObject = ImageContentObject;
2026-06-22 10:17:51 +05:30
enum class PathPaintOp {
Stroke,
Fill,
FillStroke
};
class PathObject : public ContentObject {
public:
ContentObjectType getType() const override { return ContentObjectType::Path; }
Path path;
PathPaintOp paintOp = PathPaintOp::Stroke;
FillRule fillRule = FillRule::NonZero;
2026-06-22 10:17:51 +05:30
Matrix transform;
};
2026-08-01 16:19:11 +05:30
} // namespace pdfengine