-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf-text.cpp
More file actions
85 lines (67 loc) · 1.53 KB
/
pdf-text.cpp
File metadata and controls
85 lines (67 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* pdf-writer.cpp
*
* Created on: Oct 31, 2017
* Author: gnat
*/
#include <phpcpp.h>
#include <string.h>
#include <iostream>
#include "pdf-text.h"
PdfText::PdfText() = default;
void PdfText::__construct(Php::Parameters ¶ms) {
x = params[0].numericValue();
y = params[1].numericValue();
text = params[2].stringValue();
if (params.size() >= 4) {
fontSize = params[3].numericValue();
}
if (params.size() == 5) {
font = params[4].stringValue();
}
}
PdfText::PdfText(const PdfText &obj) {
x = obj.x;
y = obj.y;
text = obj.text;
color = obj.color;
if (obj.fontSize) {
fontSize = obj.fontSize;
}
if (!obj.font.empty()) {
font = obj.font;
}
}
Php::Value PdfText::getX() {
return x;
}
Php::Value PdfText::getY() {
return y;
}
Php::Value PdfText::getText() {
return text;
}
Php::Value PdfText::__toString() {
return getText();
}
Php::Value PdfText::getFontSize() {
return fontSize;
}
Php::Value PdfText::getFont() {
return font;
}
Php::Value PdfText::getColor() {
return color;
}
void PdfText::setColor(Php::Parameters ¶ms) {
if (params.size() == 1) {
color = params[0].numericValue();
return;
}
if (params.size() == 3) {
color = 65536*params[0].numericValue() + 256*params[1].numericValue() + params[2].numericValue();
return;
}
Php::warning << "Invalid color: Pass a color as a single value or RGB" << std::flush;
throw Php::Exception("Invalid color: Pass a color as a single value or RGB");
}