• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: dataWithPDFInsideRect not using drawRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dataWithPDFInsideRect not using drawRect


  • Subject: Re: dataWithPDFInsideRect not using drawRect
  • From: Shawn Erickson <email@hidden>
  • Date: Fri, 1 Oct 2004 09:38:58 -0700


On Oct 1, 2004, at 9:18 AM, stefano iacus wrote:

Hi,

I have a NSView. I don't user drawRect to draw on it.
If I try to export this to a pdf file using dataWithPDFInsideRect method, I only obtain an empty pdf file, i.e. a pdf with only an empty box inside (of the correct dimensions of the original image).

I guess this is due to the fact I'm not using drawRect.

Yes likely... I bet the way it is implement is that a PDF context is created, lock and focused and then your views drawRect: method is called.

Is there an equivalent way to do this? i.e. can I export to PDF by simply redrawing ?

I strongly suggest that you rework your drawing so that it lives in drawRect: for it is the normal way to do things and would avoid quirks like you are hitting.

I am not sure how to do this outside of drawRect: at the Cocoa level (not really explored that yet) but by dropping down to the Quartz 2D level you could create a PDF context [1], focus the context in the Cocoa sense (I guess using NSGraphicsContext) and in this case also begin a page in the PDF document [2]. Then draw things, unfocus and end page.

Humm... quickly scanning the docs for NSGraphicsContext it may expose the functionality you need without dropping down to Quartz... look at using NSGraphicsContextPDFFormat for NSGraphicsContextRepresentationFormatAttributeName, etc. into graphicsContextWithAttributes.

-Shawn

[1] <http://developer.apple.com/documentation/GraphicsImaging/Reference/ CGPDFContext/index.html>
[2] <http://developer.apple.com/documentation/GraphicsImaging/Reference/ CGContext/Reference/function_group_14.html#//apple_ref/doc/uid/ TP30000950-CH202-495599>

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >dataWithPDFInsideRect not using drawRect (From: stefano iacus <email@hidden>)

  • Prev by Date: dataWithPDFInsideRect not using drawRect
  • Next by Date: Re: Help assistant
  • Previous by thread: dataWithPDFInsideRect not using drawRect
  • Next by thread: Java VM version query
  • Index(es):
    • Date
    • Thread