Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I create a PDF fle paginated according to my own rules?



On Aug 28, 2008, at 5:51 PM, Paul Archibald wrote:
But this does not seem to be possible. The PDFDocument and PDFPage classes seem to have a weird relationship, where you can get a page from a document, or add/remove a page, but there does not seem to be any way to create a PDFPage and draw or set text into it directly.

You can by subclassing.

1) Create a class: MyPDFTextPage (or whatever) as a subclass of PDFPage.
2) Implement/override -[PDFPage boundsForBox:] and return the size you want for your PDF page (in points).
3) Implement/override -[PDFPage drawWithBox:] to draw whatever text you wish, in whatever color, font or point size you wish.
4) Add this page to an empty PDFDocument.


So there are some things I left out above. For example, your subclass will need a settor or initializer to specify the text/font/etc. And of course instance variables to store this info.

This will work.  And it will be fast as well.

John Calhoun—_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >How do I create a PDF fle paginated according to my own rules? (From: Paul Archibald <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.