Printing a layer-backed view

  • I'm hoping that this is possible, but so far it seems like NSView's
    that are layer-backed don't print (not even a bitmap!)

      Tell me I'm wrong and we haven't stepped back into the dark ages...
    =)

    -tim
  • Tim,

    If it will make you feel better, I am having the same experience with
    layer-backed views.  Searching the list archives and the Apple website
    (using keywords  "CALayer" and "print") didn't shed any light either.
    I have temporarily(?) solved my issue my using an alternate, not-layer-
    backed view for printing.

    regards,

    douglas

    On Jan 4, 2008, at 5:27 AM, Timothy J. Wood wrote:

    >
    > I'm hoping that this is possible, but so far it seems like NSView's
    > that are layer-backed don't print (not even a bitmap!)
    >
    > Tell me I'm wrong and we haven't stepped back into the dark ages...
    > =)
    >
    > -tim
  • On Jan 4, 2008, at 2:27 AM, Timothy J. Wood wrote:
    > I'm hoping that this is possible, but so far it seems like NSView's
    > that are layer-backed don't print (not even a bitmap!)
    >
    > Tell me I'm wrong and we haven't stepped back into the dark ages...
    > =)
    >
    > -tim

    Hi Tim,

    Sorry to say there is indeed a bug that causes the views' drawing to
    be redirected to their backing layers, even though the views are being
    asked to draw for the purpose of printing.

    Ways this can be worked around:

    (1) temporarily switch off layer-backing of the view (or view
    hierarchy) during printing, or

    (2) print from an identically configured offscreen view (or hierarchy)
    that isn't layer-backed, or

    (3) if your views are employing visual effects that only work in layer-
    backed mode (effects that are rendered by Core Animation: view
    filters, shadows, alpha) and you need those same effects to appear in
    the printed output, use a CARenderer to render the layer tree to
    bitmapped form, then print the bitmap.

    I'll see about fixing this.  In the meantime, I hope the above will
    help get you un-stuck.

    Regards,
    Troy

    --
    Troy Stephens
    Cocoa Frameworks
    Apple, Inc.
  • On Jan 4, 2008, at 9:56 AM, Troy Stephens wrote:
    >> Sorry to say there is indeed a bug that causes the views' drawing
    >> to be redirected to their backing layers, even though the views are
    >> being asked to draw for the purpose of printing.

      Thanks for the confirmation.

    >
    > Ways this can be worked around:
    >
    > (1) temporarily switch off layer-backing of the view (or view
    > hierarchy) during printing, or

      When doing this, the content disappears off the on-screen view.
    Comical, and fine for testing, but not for release =)

    > (2) print from an identically configured offscreen view (or
    > hierarchy) that isn't layer-backed, or

      This would sort of work, but I don't really want to have to set up
    my views both ways if I can avoid it.  I'm just exploring right now,
    but the view I'm wanting to make layer backed is pretty complicated
    and having two setup paths would be bad.  On the flip side, while
    printing, I'm unlikely to have any CIFilters in effect and all my
    layers should be able to draw themselves via the CGContextRef path.
    In this case, I'd need to be able to render the layer tree into the
    CGContextRef as actual vector output.

      Hopefully this will work once this bug is fixed.  It'd be a bummer
    to have to traverse the layer tree myself, applying transforms and
    calling the CGContextRef methods, but it seems like I could do that if
    I had to.

      Thanks!

    -tim
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today