4 {
5
6
7
9 const char* documentTitle,
10 void (*writePage)(
SkCanvas*,
int page),
11 int numberOfPages,
14 metadata.
fTitle = documentTitle;
15 metadata.
fCreator =
"Example WritePDF() Function";
16 metadata.
fCreation = {0, 2019, 1, 4, 31, 12, 34, 56};
17 metadata.
fModified = {0, 2019, 1, 4, 31, 12, 34, 56};
20 for (
int page = 0;
page < numberOfPages; ++
page) {
21 SkCanvas* pageCanvas = pdfDocument->beginPage(pageSize.
width(),
23 writePage(pageCanvas, page);
24 pdfDocument->endPage();
25 }
26 pdfDocument->close();
27}
28
29
30void print_data(
const SkData* data,
const char*
name) {
31 if (data) {
33 size_t s =
data->size();
34 const uint8_t*
d =
data->bytes();
35 for (
size_t i = 0; i <
s; ++i) {
38 }
40 }
41}
42
43
44void write_page(
SkCanvas* canvas,
int) {
48 for (int i = 1; i < 8; ++i) {
51 }
55}
56
58 constexpr SkSize ansiLetterSize{8.5f * 72, 11.0f * 72};
60 WritePDF(&
buffer,
"SkPDF Example", &write_page, 1, ansiLetterSize);
62 print_data(pdfData.
get(),
"skpdf_example.pdf");
63}
64}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void drawPath(const SkPath &path, const SkPaint &paint)
@ kStroke_Style
set to stroke geometry
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static const uint8_t buffer[]
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data