diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2014-01-11 10:42:33 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2014-01-11 10:46:46 +1030 |
commit | 26d0edbc35504624cbe96e95e338351e219bb262 (patch) | |
tree | 041c846108bd714d84d3c42e778cc8ccf1b40fe9 | |
parent | 97f6e2005d9cbc9c9dd7cc21445df7c08e084c83 (diff) |
ps: use setpagedevice to set page size
https://bugs.freedesktop.org/show_bug.cgi?id=73452
-rw-r--r-- | src/cairo-ps-surface.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 4fc9990..5dd33fa 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -335,7 +335,38 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface) " cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def\n" "/g { setgray } bind def\n" "/rg { setrgbcolor } bind def\n" - "/d1 { setcachedevice } bind def\n"); + "/d1 { setcachedevice } bind def\n" + "/cairo_set_page_size {\n" + " %% Change paper size, but only if different from previous paper size otherwise\n" + " %% duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size\n" + " %% so we use the same when checking if the size changes.\n" + " /setpagedevice where {\n" + " pop currentpagedevice\n" + " /PageSize known {\n" + " 2 copy\n" + " currentpagedevice /PageSize get aload pop\n" + " exch 4 1 roll\n" + " sub abs 5 gt\n" + " 3 1 roll\n" + " sub abs 5 gt\n" + " or\n" + " } {\n" + " true\n" + " } ifelse\n" + " {\n" + " 2 array astore\n" + " 2 dict begin\n" + " /PageSize exch def\n" + " /ImagingBBox null def\n" + " currentdict end\n" + " setpagedevice\n" + " } {\n" + " pop pop\n" + " } ifelse\n" + " } {\n" + " pop\n" + " } ifelse\n" + "} def\n"); _cairo_output_stream_printf (surface->final_stream, "%%%%EndProlog\n"); @@ -4551,6 +4582,13 @@ _cairo_ps_surface_set_bounding_box (void *abstract_surface, x1, y1, x2, y2); } + if (!surface->eps) { + _cairo_output_stream_printf (surface->stream, + "%f %f cairo_set_page_size\n", + ceil(surface->width), + ceil(surface->height)); + } + _cairo_output_stream_printf (surface->stream, "%%%%EndPageSetup\n" "q %d %d %d %d rectclip q\n", |