Comment 130 for bug 179988

Revision history for this message
Adrian Johnson (ajohnson-redneon) wrote : Re: [Bug 179988] Re: no printing from Windows

Rygle wrote:
> Actually, I think I should nominate this now given the short deadline.
> The rest will have to wait for 0.46.1.
>
> The latest patch is attached.
>
> There are also some patched cairo libs that stop a crash. See here -
> http://annarchy.freedesktop.org/~ajohnson/cairo/
>
> ** Attachment added: "ink_win32.046.print.patch"
> http://launchpadlibrarian.net/12826073/ink_win32.046.print.patch
>

There few things that should be tidied up before this can be committed
to the 0.46 branch.

- I'll push out my cairo patch to the cairo repository in the next few
hours. Then Ishmal can do a cairo build from that. As the current cairo
snapshot (1.4.14) is the release candidate for 1.6.0 I need to do
further testing to make sure I have not broken anything before I push
out this patch.

- The workaround for using win32_printing_surface with gtkprint should
be made more robust. It should be changed to check of the surface
returned by gtkprint is of type CAIRO_SURFACE_TYPE_WIN32 before
substituting it with win32_printing_surface. That way the code will work
correctly if gtkprint returns some other surface like pdf. It will also
ensure that when gtkprint is fixed to use the surface of type
CAIRO_SURFACE_TYPE_WIN32_PRINTING, the workaround will be bypassed.

eg

    cairo_t *cr = gtk_print_context_get_cairo_context (context);
    cairo_surface_t *surface = cairo_get_target(cr);
#ifdef WIN32
+ if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_WIN32) {
        HDC dc = cairo_win32_surface_get_dc (surface);
        surface = _cairo_win32_printing_surface_create (dc);
+ }
#endif

    bool ret = ctx->setSurfaceTarget (surface, true);

The problem with the low resolution fallback should be easily fixed by
changing the fallback resolution. Radial gradients are not supported by
GDI so they will always use fallback images. Linear gradients are only
supported on PostScript level 3 printers. Otherwise they will fallback
as well.

The cairo function for controlling the fallback resolution is:

  cairo_surface_set_fallback_resolution (surface, x_dpi, y_dpi);

It is in the patch but commented out. The default fallback resolution is
300dpi so that should not be causing the problem unless Inkscape is
changing it. The commented out line in the patch sets the fallback dpi
to the printer resolution. However the problem with doing this is with
higher resolutions (600dpi or more) you can easily run out of memory
when doing full page fallbacks. I would generally setting this to
between 150 to 300 dpi. Laser printers generally get a lot less
resolution when printing color than their native resolution due to the
half toning. For example my 600dpi laser prints grayscale at 120dpi.

The other source of low resolution bitmaps is the resolution that
Inkscape prints images at. I am not familiar with the Inkscape code so I
don't know what it is doing with images.