1
2---
3title: "Using Skia's PDF Backend"
4linkTitle: "Using Skia's PDF Backend"
5
6---
7
8
9Here is an example of using Skia's PDF backend (SkPDF) via the
10SkDocument and SkCanvas APIs.
11
12<fiddle-embed name='@PDF'></fiddle-embed>
13<!-- https://fiddle.skia.org/c/@PDF docs/examples/PDF.cpp -->
14
15* * *
16
17<span id="limits">SkPDF Limitations</span>
18------------------------------------------
19
20There are several corners of Skia's public API that SkPDF currently
21does not handle because either no known client uses the feature or
22there is no simple PDF-ish way to handle it.
23
24In this document:
25
26  + **drop** means to draw nothing.
27
28  + **ignore** means to draw without the effect
29
30  + **expand** means to implement something in a non-PDF-ish way.
31    This may mean to rasterize vector graphics, to expand paths with
32    path effects into many individual paths, or to convert text to
33    paths.
34
35<style scoped><!--
36#pdftable {border-collapse:collapse;}
37#pdftable tr th, #pdftable tr td {border:#888888 2px solid;padding: 5px;}
38--></style>
39<table id="pdftable">
40<tr><th>Effect</th>                  <th>text</th>   <th>images</th> <th>everything
41                                                                         else</th></tr>
42<tr><th>SkMaskFilter</th>            <td>drop</td>   <td>ignore</td> <td>ignore</td></tr>
43<tr><th>SkPathEffect</th>            <td>ignore</td> <td>n/a</td>    <td>expand</td></tr>
44<tr><th>SkColorFilter</th>           <td>ignore</td> <td>expand</td> <td>ignore</td></tr>
45<tr><th>SkImageFilter</th>           <td>expand</td> <td>expand</td> <td>expand</td></tr>
46<tr><th>unsupported SkXferModes</th> <td>ignore</td> <td>ignore</td> <td>ignore</td></tr>
47<tr><th>non-gradient SkShader</th>   <td>expand</td> <td>n/a</td>    <td>expand</td></tr>
48</table>
49
50Notes:
51
52  - *SkImageFilter*: When SkImageFilter is expanded, text-as-text is lost.
53
54  - *SkXferMode*: The following transfer modes are not natively
55    supported by PDF: DstOver, SrcIn, DstIn, SrcOut, DstOut, SrcATop,
56    DstATop, and Modulate.
57
58Other limitations:
59
60  - *drawText with VerticalText* — drop. No known clients seem to make use
61    of the VerticalText flag.
62
63  - *drawTextOnPath* — expand. (Text-as-text is lost.)
64
65  - *drawVertices* — drop.
66
67  - *drawPatch* — drop.
68
69* * *
70
71