|
java-gnome version 4.0.15 | ||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.freedesktop.bindings.Pointer
org.freedesktop.bindings.Proxy
org.freedesktop.cairo.Surface
org.freedesktop.cairo.PdfSurface
public class PdfSurface
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.
Constructor Summary | |
---|---|
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 | |
---|---|
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, 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 |
---|
public PdfSurface(String filename, double width, double height) throws IOException
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.
IOException
- If you do not have write permissions on the given file.Method Detail |
---|
public void copyPage()
Surface
copyPage
in class Surface
public void showPage()
Surface
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.
showPage
in class Surface
|
![]() java-gnome |
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |