36#ifdef SK_PDF_TEST_TAGS_OUTPUT_PATH
45 metadata.
fTitle =
"Example Tagged Table PDF";
55 "Car",
"Engine",
"City MPG",
"Highway MPG",
56 "Mitsubishi Mirage ES",
"Gas",
"28",
"47",
57 "Toyota Prius Three",
"Hybrid",
"43",
"59",
58 "Nissan Leaf SL",
"Electric",
"N/A",
nullptr,
59 "Tesla Model 3",
nullptr,
"N/A",
nullptr
63 auto root = std::make_unique<PDFTag>();
65 root->fTypeString =
"Document";
66 root->fLang =
"en-US";
69 auto h1 = std::make_unique<PDFTag>();
71 h1->fTypeString =
"H1";
72 h1->fAlt =
"Tagged PDF Table Alt Text";
73 root->fChildVector.push_back(std::move(h1));
76 auto table = std::make_unique<PDFTag>();
78 table->fTypeString =
"Table";
79 auto& rows =
table->fChildVector;
80 table->fAttributes.appendFloatArray(
"Layout",
"BBox", {72, 72, 360, 360});
82 for (
int rowIndex = 0; rowIndex <
kRowCount; rowIndex++) {
83 auto row = std::make_unique<PDFTag>();
84 row->fNodeId = 4 + rowIndex;
85 row->fTypeString =
"TR";
86 auto& cells = row->fChildVector;
87 for (
int colIndex = 0; colIndex <
kColCount; colIndex++) {
88 auto cell = std::make_unique<PDFTag>();
89 int cellIndex = rowIndex *
kColCount + colIndex;
90 cell->fNodeId = 10 + cellIndex;
91 if (!cellData[cellIndex]) {
92 cell->fTypeString =
"NonStruct";
93 }
else if (rowIndex == 0 || colIndex == 0) {
94 cell->fTypeString =
"TH";
96 cell->fTypeString =
"TD";
97 std::vector<int> headerIds;
98 headerIds.push_back(10 + rowIndex *
kColCount);
99 headerIds.push_back(10 + colIndex);
100 cell->fAttributes.appendNodeIdArray(
101 "Table",
"Headers", headerIds);
104 if (cellIndex == 13) {
105 cell->fAttributes.appendInt(
"Table",
"RowSpan", 2);
106 }
else if (cellIndex == 14 || cellIndex == 18) {
107 cell->fAttributes.appendInt(
"Table",
"ColSpan", 2);
108 }
else if (rowIndex == 0 || colIndex == 0) {
109 cell->fAttributes.appendName(
110 "Table",
"Scope", rowIndex == 0 ?
"Column" :
"Row");
112 cells.push_back(std::move(cell));
114 rows.push_back(std::move(row));
116 root->fChildVector.push_back(std::move(
table));
120 &outputStream, metadata);
126 document->beginPage(pageSize.
width(),
133 for (
int rowIndex = 0; rowIndex <
kRowCount; rowIndex++) {
134 for (
int colIndex = 0; colIndex <
kColCount; colIndex++) {
135 int cellIndex = rowIndex *
kColCount + colIndex;
136 const char* str = cellData[cellIndex];
140 int x = 72 + colIndex * 108 + (colIndex > 0 ? 72 : 0);
141 int y = 144 + rowIndex * 48;
150 outputStream.
flush();
constexpr SkColor SK_ColorBLACK
#define DEF_TEST(name, reporter)
#define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static constexpr int kRowCount
static constexpr int kColCount
void GetDateTime(SkPDF::DateTime *)
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)
SK_API void SetNodeId(SkCanvas *dst, int nodeID)
font
Font Metadata and Metrics.
static constexpr SkSize Make(SkScalar w, SkScalar h)