org.freedesktop.cairo

## Class PdfSurface

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.freedesktop.cairo.Surface
      - - org.freedesktop.cairo.PdfSurface

-     public class PdfSurface
      extends Surface

  A Surface that will be rendered to a file in the Portable Document Format.

  You specify the size of a PdfSurface in points, and all subsequent operations on a Context based on this Surface will likewise be in points. If you are used to using Cairo to draw to screen where a device unit equals a pixel, be aware that here your a distance of `1.0` is in points, not pixels.

  Cairo's PDF support is still nascent but is improving steadily! Wherever possible graphics drawn in your Context will be rendered in vector form in the PDF; when that is not available the PDF backend will fallback to rendering bitmaps of the desired content.

  Since:
    4.0.10
  Author:
    Andrew Cowie

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PdfSurface(String filename, double width, double height)` Create a new PdfSurface, supplying the file you want to write to and the size of the page you are creating.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `copyPage()` Emit the current page, but keep the content of the Surface as the starting point for the next page.
    `void` | `showPage()` Emit the current page and clear the Surface, allowing you to continue drawing with your Context but to a new blank page.

    - ### Methods inherited from class org.freedesktop.cairo.Surface

      `createSimilar, finish, flush, setMimeData, setMimeData, writeToPNG`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PdfSurface

          public PdfSurface(String filename,
                    double width,
                    double height)
                     throws IOException

      Create a new PdfSurface, supplying the file you want to write to and the size of the page you are creating. The `width` and `height` parameters are specified in points, where 1 point equals 1/72nd of an inch.

      A4 paper is 210mm x 297mm, which works out as about:

           surface = new PdfSurface("output.pdf", 595.275, 841.889);

      more generally, you can use get paper size information via GTK's printing support using [`org.gnome.gtk`] PaperSize's `getWidth()` and `getHeight()` methods, for example:

           paper = PaperSize.getDefault();
           width = paper.getWidth(Unit.POINTS);
           height = paper.getHeight(Unit.POINTS);

           surface = new PdfSurface("output.pdf", width, height);

      saving you having to worry about just how big such paper really is.
      Throws:
        `IOException` - If you do not have write permissions on the given file.
      Since:
        4.0.10

  - ### Method Detail

    - #### copyPage

          public void copyPage()

      Description copied from class: `Surface`
      Emit the current page, but keep the content of the Surface as the starting point for the next page.
      Overrides:
        `copyPage` in class `Surface`

    - #### showPage

          public void showPage()

      Description copied from class: `Surface`
      Emit the current page and clear the Surface, allowing you to continue drawing with your Context but to a new blank page.

      If you want to render the current page, but keep the page content in your Context, then call `copyPage()` instead.

      This method only applies to Surfaces which are paginated, which in practise means the PDF backend.

      Overrides:
        `showPage` in class `Surface`