Re: CGImage to NSImage, or PDFPage?

2010-08-11 Thread John Calhoun
On Aug 11, 2010, at 5:27 PM, Brian Postow wrote:
> Is there any way to get access to the xObjects in the PDFPage, other than 
> parsing through the PDF data?

Unfortunately, no. Hackish as it may be, perhaps you can store the original 
image resolution/size as metadata in the PDF.

All this back and forth between bitmap formats and PDF-as-container format 
though has me wondering if there isn't a better way. I don't know what you're 
trying to accomplish though so perhaps you have the optimal solution.

John Calhoun—


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImage to NSImage, or PDFPage?

2010-08-10 Thread John Calhoun
On Aug 10, 2010, at 2:45 PM, Brian Postow wrote:
> I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the 
> only way I see to do that is to turn it into an NSImage first.

That will work, but it is also possible to subclass PDFPage and override the 
-[drawWithBox:] method in your subclass. Your method would get the current 
context as a CGContext and draw the CGImageRef directly.

Make sure to return the correct size in -[PDFPage boundsForBox:] as well.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDFSelection question

2010-06-07 Thread John Calhoun
On Jun 5, 2010, at 12:26 PM, Matthew Weinstein wrote:
> I think I must be missing some simple method in the api to do this, but, 
> given a range of a PDFDocument string, how do I convert that to a selection? 
> I found the PDFPage selection from range, but how do I find what pages a 
> selection for the document string covers?

I may not understand your question PDFDocument's don't really contain a 
string for the entire document — it is created by concatenating the strings 
from each page (with a  between them.

Generally, the API uses PDFSelections — for example if the user selects text in 
the PDFView -[PDFView currentSelection] returns that as a PDFSelection. If you 
search a PDFDocument the results returned are PDFSelections. Using 
PDFSelections allows you to query the pages covered by the selection 
(-[PDFSelection pages]).

Perhaps there is something else you are attempting to do though.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDFKit cpSelections?

2010-05-26 Thread John Calhoun
On May 26, 2010, at 1:13 PM, Matthew Weinstein wrote:
> Now even before I can click on it, while it is loading from nib it bombs with 
> the following pearls of wisdom. I can't find a discussion of cpSelections 
> anywhere.

cpSelection objects are internal - used by PDFSelection beginning with 
SnowLeopard.

-[PDFView becomeFirstResponder:] is calling -[PDFView(PDFViewInternal) 
invalidateSelectionBounds:] on the current selection. This would have the 
effect of forcing a redraw of the view region covered by the selection (if 
any). When a view becomes first responder the selection is drawn with a 
different color than when the focus is elsewhere

I offer this just as an explanation  for what is happening — I can't say why 
you are seeing doesNotRecognizeSelector or referecnes to cpSelection.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: initializing a pdfview

2010-05-26 Thread John Calhoun
On May 26, 2010, at 11:38 AM, Matthew Weinstein wrote:
> I think I'm on the verge of success with my attempt to create a selection 
> rectangle (that doesn't select text) for pdfview, but I'm unclear what init 
> routines I should use in my pdfview subclass. - 
> (id)initWithFrame:(NSRect)frameRect doesn't seem to get called--as it does in 
> nsview. 

Are you loading the PDFView subclass from a NIB or creating it 
programmatically? From the NIB I believe -(id) initWithCoder: (NSCoder *) coder 
is called.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating a PDFSelection...

2010-05-26 Thread John Calhoun
On May 25, 2010, at 9:37 PM, Matthew Weinstein wrote:
> Actually, I don't need the tiff; I just need the rectangle! People have to be 
> able to sketch the rectangle over the pdf, and then my program stores and 
> restores those rectangles (with some additional information). 

PDFSelection has a routine to return each line from the selection as a 
sub-selection (for a single word selection this generally is just the selection 
itself, but for selections that span multiple lines you get a new selection for 
each line).

For each "line selection" you can get its bounds. These you can store/archive 
along with the page index.

With the archived rectangles and page indices you can later create selections 
again from those rectangles (PDFPage has -[selectionForRect:]).

This isn't a perfect solution though — you may have to pad out the rectangle a 
bit for example to improve fidelity between the original selection and the 
unarchived one.

If you know the range of the original text selected, PDFPage's 
-[selectionForRange:] is unambiguously specified.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDF View - smooth text?

2010-01-27 Thread John Calhoun
On Jan 27, 2010, at 2:01 AM, Keith Blount wrote:
> In Preview app's preferences, under the "PDF" pane, there is a checkbox 
> entitled "Smooth text and line art". Does anyone know what setting this 
> corresponds to in PDFView or the PDFKit (if, indeed, any, and it isn't 
> something specific to Preview)?

Try playing with interpolation quality in the CGContext. It may be combined 
with ant-ialising as well (so you may need to set both appropriately).

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to determine if a PDFPage is image based? (A scanned page)

2009-09-14 Thread John Calhoun

On Sep 13, 2009, at 5:01 AM, DairyKnight wrote:

Is there a way to determine if a PDFPage contains only a picture?


You could see if NULL is returned for -[PDFPage string].  That sort of  
indirectly implies an image (or a blank page — or one perhaps with  
line art only ...).


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Anti-aliasing in Snow Leopard (10.6) PDFView

2009-09-08 Thread John Calhoun

On Sep 7, 2009, at 3:50 PM, Duncan McGregor wrote:


It used to be that PDFView anti-aliased nicely. Now it doesn't, at
least not for some files. Text and scans rendered in both the
PDKKitViewer and PDFLinker2 samples are horrible in 10.6.


Can you point to a specific PDF that shows this behavior?

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSPDFImageRep Memory Leak?

2009-09-08 Thread John Calhoun

On Sep 8, 2009, at 5:08 AM, DairyKnight wrote:

NSPDFImageRep *pdfImgRep = [[NSPDFImageRep alloc] initWithData:[page
dataRepresentation]];


Check [page dataRepresentation] above.

Pre-SnowLeopard the NSData returned was not autoreleased and so needed  
to be released by the caller.  This was not consistent with other  
AppKit -[xxx dataRepresentation] calls.


In SnowLeopard, -[PDDPage dataRepresentation] is properly auto- 
released.  SnowLeopard PDF Kit though checks the compiler and  
continues the non-auto-prelease behavior for apps compiled before  
SnowLeopard.


The above applies to -[PDFDocument dataRepresentation] as well.

Check the PDFXxx headers, the behavior change is documented there.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Performance Issue with Drawing PDFPages on NSView

2009-08-26 Thread John Calhoun

On Aug 26, 2009, at 4:20 AM, Naresh Kongara wrote:
I'm drawing the pages from the pdf document onto an NSVIew. The  
fallowing method draws all the pages from the document in a View,  
this method will be  called from the view's drawrect.  Its taking  
much time when there are more than 40 pages as all the pages needs  
to be displayed at a time .


Is there any other way of doing it ?  or How can increase the  
performance..?


Don't go from PDFPage -> data -> NSImage.  PDFPage has -[PDFPage  
drawWithBox:] method.  Call that directly.  It always draws at 100%  
though so you will have to set up a transform within [NSView  
drawRect:] in order to scale/position the page correctly.


That should make a significant performance difference

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory efficient way to get image metadata?

2009-08-03 Thread John Calhoun

On Aug 3, 2009, at 1:23 PM, kentoz...@comcast.net wrote:
Is there some way (other than rolling my own image readers) to just  
get the metadata from a file rather than having to load the entire  
thing? A third party class that would be something like  
"NSImageInfo" (if Apple had written such a class)


Look into ImageIO on the OS.  It is not a Cocoa class library but  
rather a C-level framework.  You can get the properties from an image  
probably a good deal more efficiently than via NSImage.  And you could  
easily wrap it all in your own "ImageInfo" Objective-C class if you  
want.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: adding PDF annotations to the output of a regular NSView

2009-07-29 Thread John Calhoun

On Jul 29, 2009, at 4:44 PM, Martin Wierschin wrote:
So the problem is that there doesn't seem to be any way of marrying  
these two systems together. Ideally there would be some Cocoa method  
I could call in my NSView's drawRect method to add PDF annotations.  
But the only solution I see is something like this:


1. Produce raw PDF data from my normal NSView hierarchy.
2. Load that NSView data into a PDFView.
3. Add PDFAnnotations to special regions as desired.
4. Resave the modified PDF data from the PDFView.


I'll start by pointing out that Step 2 is not necessary.   Adding  
annotations in PDF Kit is done at the PDFDocument level.  The  
PDFDocument you will have created from your raw PDF data (from Step  
1).  The PDFView is strictly for display purposes.


As well then Step 4 more accurately would be "re-save the modified  
PDFDocument as PDF data."


This seems very inefficient and error prone (eg: mapping coordinates  
between NSView and PDF page space). Is this really the best option  
available?


Mapping points from NSView to page space is not an issue.  Since the  
PDF data came from your NSView to begin with you can use the same  
coordinates you used in the NSView. So for example if the special  
region was of some bounds (NSRect) in the NSView you can use this same  
rect to create your PDFAnnotation and add it in PDF Kit.


But if you wanted a more straightforward model (and I understand that  
NSView->PDF data->PDFDocument is a bit of a kludge) you could replace  
your NSView with a subclass of PDFPage and display with a PDFView.  It  
depends on your application though ... how much of a kludge this  
approach would be (you could simply be trading one kludge for  
another :-)).


But in essence to do this a PDFView replaces the NSView and rather  
than overriding -[drawRect] as you might for NSView, you create a  
PDFPage subclass of your own and override the page's -[drawWithBox:]  
method as the place to draw your own content. You add your page to an  
empty PDFDocument and display this document in the PDFView.


To be clear above, the PDFPage is not a view classes but does have a  
draw method that is called by PDFView to display the page content. For  
a PDF you find laying around, the default implementation of PDFPage is  
to call upon the PDF data to render the specified page. Your subclass  
allows you to draw whatever you like.


The advantage to the above approach is that you can in fact add the  
PDFAnnotation prior to saving and have it actually function within  
your application (since PDFView will handle the mouseDown in the  
annotation).  And then as well you get zoom controls and all that with  
the PDFView class


But as I say, it sort of depends on your app.  If your app is an  
appoinment calendar then writing it to live within a PDFView is a bit  
of a stretch. :-)


John Calhoun—

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: trimbox and bleedbox from PDF

2009-06-11 Thread John Calhoun

On Jun 11, 2009, at 2:55 PM, gMail.com wrote:
I would need to get the trimbox rect and bleedbox rect from a pdf  
document.

Is anyone who can point me to the right APIs and procedures? Thanks.


You want to create either a PDFDocument (part of PDF Kit .. Cocoa) or  
a CGPDFDocumentRef (CoreGraphics ... straight C).  From there get  
either a PDFPage (PDF Kit) or CGPDFPageRef (CoreGraphics) — both have  
methods/functions then to get the trim and bleed boxen.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDFView in layer backed view appears white

2009-04-06 Thread John Calhoun

On Apr 6, 2009, at 6:31 AM, Memo Akten wrote:
Hi, I would like to add a PDFView to another view. But if my root  
view is layer backed I see nothing (just white).


The PDFView contains a subview.  You can get to it via: -[PDFView  
documentView].  Perhaps retain this subview, remove from super, and  
add the subview to a layer backed view.  I can think of a number of  
ways this may fail though (haven't tried it), so don't get your hopes  
up.


If you simply want to display a single page though, just create your  
own NSView subclass and call PDFPage's draw method in your views  
drawRect method.  You can set the needed scale on the current graphics  
context to have the PDFPage draw at the correct size.


Also, don't forget to erase to white before calling PDFPage's draw.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving a PDF Selection or converting it to an NSRange and back

2009-02-11 Thread John Calhoun

On Feb 11, 2009, at 12:44 PM, Keith Blount wrote:
The subject line says it all, really, I need to save a PDFSelection  
between sessions in my program, but there seems no way of doing  
this. A similar question came up on these last year but there was no  
solution:


To save a selection sapnning multiple pages you could convert a single  
selection into an array of single-line selections (-[PDFSelection  
selectionsByLine]).  Each selection returned by this method is going  
to be on a single page (and a single contiguous range and line).  The  
bounds then of these selections can be saved and then the selections  
recreated from those bounds.


I haven't tried the above but it should work in principle.

PDFSelection should probably expose some method of archiving in the  
future


Of course, if there is a better way of implementing PDF highlighting  
that I'm missing, please feel free to tell me point me in the  
direction of what I have overlooked. I have looked at the docs, the  
samples and searched the net before posting, though.


No better, but different: you could take the bounds returned from the  
above discussion and instead create Highlight annotations.  These you  
can add to the PDF and save out.  Might save you some work since when  
re-opening the PDF you don't need to re-create the highlights since  
they're now embedded in the PDF.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: -[PDFView drawPage:] and Printing

2009-02-10 Thread John Calhoun

On Feb 9, 2009, at 8:51 PM, Kyle Sluder wrote:

Okay, so at this point I guess I need to establish just what's going
on.  Does PDFView refer to a view containing the enclosing scroll
view, or perhaps the scroll view itself?


For better or worse, the PDFView is the enclosing view ... but as you  
describe there is a nested scrollview and deeper still the document  
view.


When the document view gets a -[drawRect:] call it determines the  
visible pages (based on the PDFView display layout, and position of  
the scroller, zoom, etc.)  and then calls PDFView's -[drawPage:] for  
each visible page.


-[PDFView drawPage:] was put in PDFView as a convenience so it can be  
overriden in a subclass of PDFView.  The default implementation of  
this method calls -[PDFPage drawWithBox:] for the page in question.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: -[PDFView drawPage:] and Printing

2009-02-09 Thread John Calhoun

On Feb 9, 2009, at 1:28 PM, Kyle Sluder wrote:

I'm overriding -drawPage: in a PDFView subclass with the intent of
layering two PDFs on top of each other.  It works great on screen, but
when I attempt to print the document, PDFKit just prints the document
PDFView rather than using my -drawPage: method.


That is true. The PDFPage draw method is instead what is being called  
(in fact it is called both via printing and by the PDFView itself in  
order to display the PDF).


So, there's the first clue  try to subclass the PDFDocument/ 
PDFPage instead and override the -[PDFPage drawWithBox:] method to  
composite your two PDF's.  This will in fact kill two birds with one  
stone.


And in fact a third bird ... saving the PDF will save the composited  
PDF as well. :-)


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: PDFView printing subviews

2009-01-21 Thread John Calhoun


On Jan 21, 2009, at 2:03 AM, Martin F. Carianni wrote:
Now, this prints the PDFVIEW without the subview, prints just the  
model from the PDFDocument.


As you observe, calling the print method in PDFView renders the PDF  
document ... not the PDFView content.


If the PDF is a single page you can get the -[PDFView documentView]  
and print just that (using NSView methods not PDFKit).


Otherwise it gets trickier than that

One alternative might be to subclass the PDFView and override the - 
[drawPage:] method and, during the print, draw your subviews by hand  
for each page.  It seems doable to me, just unfortunately more  
complicated than you would like.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Tabbing PDF Annotation Editor between annotations in "edit mode"?

2008-11-14 Thread John Calhoun

On Nov 14, 2008, at 12:18 PM, Joel Norvell wrote:
I want to modify the PDF Annotation Editor so that it will tab from  
annotation-to-annotation in "edit mode," just like it does in "test  
mode."

:
And since PDFAnnotation isn't an NSView subclass, I'll have to  
create a mechanism that "hears" tab events and then updates the  
current annotation "by hand."


My first thought would be to go a different route ... grab keyDown's  
in your PDFView subclass and keep track of the current annotation with  
"focus".  Manually advance the focus by going round-robin threough the  
annotaions on the page.  If you can do something more sophisticated  
though, go for it. :-)


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Saving an annotated PDF to a flat image

2008-09-26 Thread John Calhoun

On Sep 26, 2008, at 5:55 AM, Danny Greg wrote:
I load a document from disk, get it's first page (they are all 1  
page docs), add the annotations by calling addAnnotation: and then  
save out the document. Am I missing  a stage?


No, that sounds right — assuming you are saving the PDF document by  
calling PDFDocument's writeToFile/URL methods.


Can you share some swatch of code?

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Saving an annotated PDF to a flat image

2008-09-25 Thread John Calhoun

On Sep 25, 2008, at 3:24 AM, Danny Greg wrote:
Just to up the anti, what do I need to do to save the annotations to  
a proper PDF, (ie keeping all its text, link properties etc). I  
tried to save off the page's data representation but no matter what  
I do it never contains any annotations! Again, I need to accomplish  
this without  opening the PDF up in a PDFView.


Okay, I'll ante up. :-)

PDFDocument has methods for saving PDF's – since Leopard, annotations  
are preserved as annotations.


PDFPage has methods for adding, removing annotations.

The PDFAnnotation classes ave initializers so that annotations can be  
created.


PDFView is really just a view.  While it has a lot of convenience  
methods to aid in PDF viewing, the real functionailty of PDF Kit is in  
the other classes.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Saving an annotated PDF to a flat image

2008-09-24 Thread John Calhoun

On Sep 23, 2008, at 4:11 AM, Danny Greg wrote:
I am trying to save a PDF annotated using subclasses of  
PDFAnnotation to an image (such as a png, jpg etc) or a PDF such  
that the annotations are displayed. So the resulting image should be  
annotated.


Not too much code.

Get the size of said page (-[PDFPage boundsForBox:]) and create an  
NSImage of this size (-[[NSImage alloc] initWithSize:]).  Lock the  
image (-[NSImage lockFocus]) and then call PDFPage;s draw method (- 
[PDFPage drawWithBox:]).  Unlock focus on the NSImage and you;re done.


This is off the top of my head so I haven't tested the code.

Oh, you may need to throw in a -[PDFPage transformContextForBox:] so  
it works with PDF's with rotated pages, etc.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


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

2008-08-28 Thread John Calhoun

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 (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you create a new PDF file and write text to it?

2008-08-06 Thread John Calhoun

On Aug 6, 2008, at 11:37 AM, Paul Archibald wrote:
It looks like PDFKit is aimed at simply reading and navigating  
within an existing PDF file, but what I need to do is create a new  
PDF and write some simple text to it.


Sorry, I had to jump in and refute that — PDF Kit does allow PDF  
content creation, but it may not be so obvious looking at the API.


Subclassing PDFPage is a way to do this.  Subclass and implement - 
[boundsForBox:] and -[drawWithBox:] and you're there.  You report back  
the size of the PDF page in -[boundsForBox:] (in points where 72 == 1  
inch) and you draw your text in the -[drawWithBox:] method.


You create an empty PDFDocument (alloc, init) and add your subclassed  
PDFPage to the document.



On Aug 6, 2008, at 11:42 AM, Charles Steinman wrote:
Easiest way: Create a view that draws what you want, send it - 
dataWithPDFInsideRect: and write that data to a file.


Charles is correct.  And it is easiest.  The PDF Kit method I outlined  
above gives you slightly more control over the resulting PDF (you can  
for example add metadata, multiple pages, differing crop/media boxes,  
etc.).


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: [PDFDocument documentRef] internal method questions.

2008-07-14 Thread John Calhoun

On Jul 14, 2008, at 9:04 AM, Kevin Ross wrote:
In my subclassing PDFDocument adventures I wanted to add a method to  
my subclass like so:


- (CGPDFDocumentRef)documentRef;

I realized that it was overriding an internal PDFDocument method  
that I was unaware of.  This actually helps a big performance  
bottleneck in the application because I can use it instead of  
creating my own docRef from scratch each time.  What I'm not sure  
about though is how safe I am using this in my application since it  
might break on future OS updates.  I'm planning on filing an  
enhancement request since it is useful to be able to get a  
CGPDFDocumentRef directly from a PDFDocument object.  How safe am I  
using this method in my application?


Hmmm  Best of course to check for the symbol and have a fallback  
(presuably though a slower fallback method).  But I believe you'll  
find the symbol you found exists back to Tiger and may be made public  
in SnowLeopard.  It is something PDF Kit could benefit from — I just  
need to make sure the headers don't break (since we'd be declaring a  
CoreGraphics type in essentially a Cocoa-universe header).


So, be safe, but stay tuned.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFKit guidance

2008-06-24 Thread John Calhoun

On Jun 24, 2008, at 7:15 AM, Adam R. Maxwell wrote:

On Jun 23, 2008, at 3:01 PM, John Calhoun wrote:
You can then either apply it to a context (in your PDFPage  
subclass) with:


- (BOOL) applyToContext:(CGContextRef) aContext;

Or better still, pass it in the options dictionary to one of  
PDFDocument's save routines (key == @"QuartzFilter"):


Should I file a bug asking for that key to be documented also?  And  
can that option be used when creating a CGPDFContext?  I'm sure I'll  
think of more questions :).  Since the OP was trying to stay in  
memory, I was avoiding the save routines.


The key is "documented" in PDFDocument.h.  :-)

Yes, you can apply the QuartzFilter to a CGPDFContext with the - 
[applyToContext:] call listed above.  And, yes, they should better  
document QuartzFilters ... they're nice.


I'm feeling dumb now, but I don't see how that helps?  You can  
insert a subclassed PDFPage in an empty PDFDocument, but then what  
do you do to use it with your PDF file?


Well, in a very crude fashion you can still accomplish what it is I  
think you;re trying to accomplish.  You're subclassed PDFPage's could,  
on Tiger, render a regular PDFPage.  It's gross but what I'm  
describing is basically having two parallel PDFDocuments — one created  
from a file or data ([PDFDocument initWithURL:] or [PDFDocument  
initWithData:]) and the other empty PDFDocument you create with - 
[init].  For each page in the former document you create a new  
PDFPageSubclass object and add it to the empty document.  Your  
subclass does the various scaling/filtering in it's draw method and  
calls it's doppleganger PDFPage to render.


So I said it was gross

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFKit guidance

2008-06-23 Thread John Calhoun

On Jun 21, 2008, at 6:34 PM, Adam R. Maxwell wrote:
I appreciated Antonio's (and your) reminder :).  If I understand  
correctly, the OP could create a PDF context with  
kCGPDFXDestinationOutputProfile set to a grayscale profile


QuartzFilters make all that a lot simpler. You would create a  
QuartzFilter that does grayscale (look at ColorSync Utility for  
examples and how to create them).  The load the QuartzFilter with:


 + (QuartzFilter*) quartzFilterWithURL:(NSURL*) aURL;

You can then either apply it to a context (in your PDFPage subclass)  
with:


 - (BOOL) applyToContext:(CGContextRef) aContext;

Or better still, pass it in the options dictionary to one of  
PDFDocument's save routines (key == @"QuartzFilter"):


 - (BOOL) writeToFile: (NSString *) path withOptions:  
(NSDictionary *) options;


Subclassing PDFPage apparently requires 10.5, also, unless I'm  
missing something.


Not strictly speaking.  You can subclass PDFPage in 10.4 but you will  
not be able to get PDFDocument to create instances of your subclass  
when handed a PDF file (i.e. through -[PDFDocument initWithURL:]).   
You can however still create an empty PDFDocument on 10.4 and - 
insertPage your subclassed PDFPage.


QuartzFilters though were only introduced in 10.5

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFKit guidance

2008-06-20 Thread John Calhoun


On Jun 20, 2008, at 5:21 AM, Adam R. Maxwell wrote:
If you want to draw in memory, I think you have to drop down to  
Quartz; using PDFKit would likely be easier, but it looks like you  
can only specify a Quartz filter when saving to a file?.


I think there may be some confusion with regards to drawing

Antonio is correct that PDFPage has a -[drawWithBox:] method that is  
used not simply for displaying to screen but also for rendering into a  
PDF context for saving to file as well.  So, you can still use  
PDFPage, override -[drawWithBox:] in an app that has no intention of  
displaying the PDF to screen.


The saving method is in PDFDocument.  When called it walks through  
each PDFPage in the document and calls it to render into a PDF  
context.  (Printing within PDF Kit does something similar, BTW.)   
Optionally too, you can pass a QuartzFilter to the save method in  
PDFDocument and get, for example, grayscale output.


You can also do something similar in Quartz with CGPDFDocumentRefs and  
CGPDFPageRefs.  The QuartzFilter stuff should work for CGContexts as  
well.


There is I think a perception that PDF Kit is only for displaying  
PDF's and I like to try to dispell that when I can. :-)


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFKit guidance

2008-06-19 Thread John Calhoun

On Jun 19, 2008, at 4:35 PM, Torsten Curdt wrote:
I would like to convert a PDF of any size so it fits to A4/Letter. I  
would also like to reduce it to gray scale. This all without  
displaying anything.


PDFKit gives you -[PDFPage setBounds:forBox] which would easily give  
you A4/Letter size if that is what you specified.  However, no scaling  
is done.  A PDFPage subclass could be fairly easily written that would  
do the scaling though


Look at QuartzFilters (in Quartz.framework) — this is where you can  
create a filter for converting to greyscale.  PDFDocument allows you  
to pass in a QuartzFilter in the save methods (in the options  
dictionary) if you want to apply this Quartz Filter on saving.


So, PDF Kit can I think do what you want.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFDocuments and CGPDFDocuments

2008-06-02 Thread John Calhoun

On May 31, 2008, at 3:43 PM, Kevin Ross wrote:
My ultimate goal is an application that is like a printer's PDF  
workflow, that will allow page manipulations like resizing /  
cropping / adding bleed information, and imposing multiple pages  
onto one with crop marks and the like.  After researching it seems  
like some of the functions (imposition with crop marks, page  
cropping/scaling with/without preserving aspects, etc) are best  
suited for quartz, while the rest (page reordering/inserting,  
rotating, etc) have Cocoa APIs.



Well, FWIW, Apple's Preview is cropping in PDF Kit ... basically you  
call -[setBoundsForBox:] on the PDFPage in question.


Additionally you should probably look into subclassing PDFPage.   
Within that domain you can overlay crop marks, apply additional  
transforms, etc.


See PDFCalendar sample code for a PDFPage subclassing example.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFDocuments and CGPDFDocuments

2008-05-30 Thread John Calhoun

On May 29, 2008, at 6:50 PM, Kevin Ross wrote:
I think there has to be either a better way of doing this or a way  
to do it where I will not have to convert (PDFDocument *) to  
CGPDFDocumentRef every time I perform a transformation.


Joel was right. I think it would be easier for you to stay in PDF Kit  
(PDFView) and do your transforms there.


Since I don't know exactly what you are doing, I can't recommend  
specific advice.  If you explain what you think you need to do with  
CGPDFDocumentRef, I'll try to suggest a parallel way of doing it in  
PDF Kit.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFPage Creation query

2008-05-23 Thread John Calhoun


On May 23, 2008, at 1:43 AM, Amrit Majumdar wrote:

There are a couple of other queries I have.

1. How to display the thumbnails in a PDFThumbnailView without their
corresponding labels ?


There is no API - labels are always on.  ImageKit has an image browser  
view that is analogous to the PDFTHumbnailView but gives you a lot  
more flexibility.  You might want to investigate that.


2. On double clicking on a PDFPage in an document I want to change  
the color

of the page,eg.


I don't follow.  Change the color of the background content of the  
main PDFView page?  Or the thumbnail only?  Both?


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: PDFPage Creation query

2008-05-22 Thread John Calhoun

On May 22, 2008, at 1:20 AM, Amrit Majumdar wrote:
I was planning to create a new PDFDocument, with my own PDF Page  
that I

generate after subclassing  PDFPage
Accordingly  I subclassed PDFPage and have over-riden the following
menthods.

- (id)initWithImage:(NSImage *)image;


Antonio is correct.  In short, instead override the draw and bounds  
method in yor own subclass.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Storing PDF selection

2008-05-16 Thread John Calhoun


On May 15, 2008, at 11:43 PM, Laurent Cerveau wrote:
If I have a PDF View , select part of it and get the  
currentSelection, showing it tells something like

Page index = 2, Range = (0, 21]

However I do not see where I could get the range of the PDFSelection  
and later recreate a selection with this value


Not the range, but you can get the bounds for each page the selection  
covers:  -[PDFSelection boundsForPage: (PDFPage *) page].


To "unflatten" you can call [PDFPage selectionForRect:] for each  
partial selection you saved off.  Selections can be added then  
[PDFSelection addSelection: (PDFSelection *) selection].


Yeah, a little hacky....

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Query with PDF Page display in PDFview

2008-05-15 Thread John Calhoun

On May 15, 2008, at 3:07 AM, Amrit Majumdar wrote:

With the PDFView we can display upto two pages in a row.
I need to display more than two PDF pages in a row.

An earlier post pointed me to the fact that the PDFThumbnailView can  
be used

for the same.

But the catch is PDFThumbnailView doesn't help me acheive all my
requirements.


What are your requirements?

You may, I think, have to write your own PDFView.  This is not as hard  
as it seems though (depending on how much functionailty you want).   
PDFVew itself is just using the other classes in PDF Kit (like PDFPage  
for rendering, PDFSelection for selecting text, etc.).


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Threading - How its done?

2008-05-06 Thread John Calhoun

On May 6, 2008, at 4:51 PM, Karl von Moller wrote:
Does anyone know whether there is a way to get progress info from a  
PDF loading into a view - percentage/bytes loaded for example?


No, I can think of no way to do this.

Be careful with threading and PDF...  PDFKit classes are ultimately  
based on CFPDFDocumentRef and CGPDFPageRef — these are not thread  
safe.  You cannot for example search for text in a PDFDocument while  
rendering a PDFPage from that same PDFDocument.  Or even render two  
different PDFPages from the PDFDocument.


You can however have several CGPDFDocumwentRefs that point to the same  
underlying file/data working on separate threads.  You want separate   
PDFDocument objects though:


PDFDocument	*mainPDFDocument = [[PDFDocument alloc] initWithUR:  
someURL];
PDFDocument	*threadPDFDocument = [[PDFDocument alloc] initWithUR:  
someURL];


Note, same URL, different PDFDocument instance.

John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Threading - How its done?

2008-05-05 Thread John Calhoun

On May 5, 2008, at 7:17 PM, Karl von Moller wrote:

-(void)openPDFandCreatePreview:(id)sender
{
//[progressOutlet setUsesThreadedAnimation:YES];
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[progressOutlet startAnimation:nil];
NSPDFImageRep  *pdfRep;
NSImage  *pdfImage;
	pdfRep = [NSPDFImageRep imageRepWithContentsOfFile:  
finalStringOutput];

pdfImage = [[[NSImage alloc] init] autorelease];
[pdfImage addRepresentation: pdfRep];
[imageWellOutlet setImage:pdfImage];
PDFDocument *pdfDoc;

	pdfDoc = [[[PDFDocument alloc] initWithURL: [NSURL fileURLWithPath:  
finalStringOutput]] autorelease];

[pdfOutlet setDocument:pdfDoc];
[progressOutlet stopAnimation:nil];
[pool release];
return;
}


If there is another way to load a PDF into a PDF view using  
Multithreading techniques that is easier to understand please let me  
know! Any help with this would be much appreciated.


I'm not exactly following the above

Why the mix of NSImage and PDFDocument?  You seem to be creating the  
PDF twice (at least the first page).


Are mutliple threads trying to share a single PDFView? I know that wll  
break....


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Saving/restoring PDFAnnotationTextWidget stringValues with PDFKit 10.5

2008-05-05 Thread John Calhoun

On May 3, 2008, at 1:58 AM, Antonio Nunes wrote:
They are not preserved. If you are saving data into your own file  
format you can can query the widgets at saving time and write them  
out explicitly. Then restore them when the file is read back in,  
after the PDF pages have been restored.


Antonio is right.  This was a bug. Hopefully I can get the fix into a  
software update.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Create a PDFPage instance from Quartz-format image

2008-03-03 Thread John Calhoun

On Mar 3, 2008, at 3:06 PM, Scott.D.R wrote:
However, I want to know whether it is possible to create the PDFPage  
instance directly from the CGImage, CIImage and so on?


Yes.  The best way to be sure is to subclass PDFPage.

Your subclass should implement -[drawWithBox:] and -[boundsForBox:].   
Other methods you may want to subclass are optional (an init method  
for example so you have a hook to set up your unique instance  
variables).


Your bounds method needs to return the bounds for the page in points  
for the given box passed in (likely you can return the same bounds for  
all boxes).


And it is in your draw method that you draw your PDF content in "page  
space" (that is, assume 1 pixel equals one point — you need not scale  
or rotate since the viewer - PDFView for example - will be applying  
the needed transform).


Want to make your PDFPage CGImage backed?  Draw the CGImage in your  
draw method.  It's that simple.


There is a sample app or two floating around somewhere that illustrate  
this:  PDFCalendar and PDF Watermarker I believe.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Use pdfkit to display a batch of pictures...

2008-02-26 Thread John Calhoun

On Feb 21, 2008, at 1:30 PM, Leopard x86 wrote:
Most of us have been used to use Mac OS X preview to open pictures  
and pdf files. So my exact goal is to create an application of the  
Preview-style to show my CGImage pictures, in other words, to  
replace the page(PDFKit page object) of a displayed pdf document  
with the CGImage object.


You can do this, but since you mention Preview, the Leopard version of  
Preview uses in fact the ImageKit view and ImageKit browser class  
(thumbnails)  for displaying images.


If we can use the PDFKit document model to display a batch of  
CGImages, then how to use the pdf built-in functions such as: Move 
\Select\Rotate\Scale\Zoom and so on?


Zoom is built in to PDFView (-[PDFView setScaleFactor:].

You can rotate a page by setting the rotation on the PDFPage and  
telling the PDFView to re-layout.


Move is done by tracking the mouse in a PDFView subclass and calling  
scrollToPoint: on the clip view enclosing the PDFView's document view.


Select is also done with a PDFView subclass.  Also handle the mouse as  
for tracking above, but in select mode you keep track of the selected  
area as a rectangle - in the PDFView subclass you can "post draw" on  
top of the PDF page in -[PDFPage drawPage:] and draw part of the page  
"darkended" or selected.


The above is a little brief (no sample code) but is essentially what  
Preview does.


There is sample code to show you how to subclass PDFView and handle  
your own mouse tracking, post-drawing, etc.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: indexForPage: page not found - Problem with PDFView on Tiger, works fine on Leopard

2008-02-26 Thread John Calhoun

On Feb 17, 2008, at 1:07 PM, Kevin Ross wrote:

This snippet of code works fine on Leopard but not on Tiger.

- (void)awakeFromNib  {

	NSString *outPath = [@"~/Desktop/debug.pdf"  
stringByExpandingTildeInPath];

[self writeDebugPDFDocument:[self pdfDocument] toPath:outPath];


	[self setPageCount:[pdfDocument pageCount]];	< pageCount = 1  
(like it should)
	[pdfView setDocument:[self pdfDocument]];<---  Throws  
exception here.

[self skipToPage:[NSNumber numberWithInt:1]];
[pdfView layoutDocumentView];
}

Debugger log output:
2008-02-17 12:26:51.163 Imposer[455] indexForPage: page not found
2008-02-17 12:26:51.163 Imposer[455] *** Uncaught exception:  
 indexForPage: page not found


Stack trace:
#0  0x92c0107c in _NSRaiseError
#1  0x92c00db8 in +[NSException raise:format:]
#2  0x9648b894 in -[PDFDocument indexForPage:]
#3  0x9648aaec in -[PDFView viewSizeForPage:]
#4  0x9648a1b0 in -[PDFView resizeDisplayView:]
#5  0x964899e0 in -[PDFView setDocument:]
#6	0x000d512c in -[KRImposerDocument awakeFromNib] at  
KRImposerDocument.m:78


It's hard to answer you without knowing more about your class/app.

I take it the code snippet is from KRImposerDocument?  This is a  
PDFView subclass?


What does skipToPage: do?  Specifically, is it 1-based or zero based  
(because PDFKit is zero-based).



I'm sure it's something I'm doing (possibly some autorelease  
craziness?) since this snippet works fine when the document is  
opened via the "Open" menu, and only happens when a new document has  
been created programmatically from the originally opened one.


That bit puzzles me.  How are you creating the document  
programatically?  There were small odd differences between Leopard and  
Tiger here


John Calhoun—

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Help with displaying encrypted PDF image

2008-02-26 Thread John Calhoun

On Feb 17, 2008, at 5:52 AM, Mario Gajardo Tassara wrote:
Hi, im trying to displaying encrypted pdf formated images in cocoa.  
this is  my code to load these images, but nothing is displayed,  
however non encrypted pdf displayed with zero problems. All my  
encrypted images seems to be decrypted because the printf statement  
"unlocked" is reached always.


Yes, for an encrypted PDF document, -[PDFDocument dataRepresentation],  
-[PDFDocument writeToURL:], etc. do nothing.


You can still get the image data by hand by drawing the PDFPage into a  
CGPDFContext.


John Calhoun—___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]