Re: Storing an NSImage File
Re: Storing an NSImage File
- Subject: Re: Storing an NSImage File
- From: Gordon Apple <email@hidden>
- Date: Mon, 05 Aug 2013 09:32:08 -0500
- Thread-topic: Storing an NSImage File
Fantastic! I knew these forums were useful. I’ll delve into that and see
if I can make that work. Thanks.
There should only be one page, but the pieceInfo is under the page level. I
won’t be editing it (other than size and baseline) — I just need to identify
it. The original program edits it. Double-clicking the attachment should
send the pdf back to the original program, then the edited result will be
reinserted at the previously identified text index. (BTW, this is the same
thing the iWorks suite does with this stuff.)
Useful info:
If you want to embed attachments in NSTextView using paste and drag, you
need to set the following in your NSTextView subclass:
self.importGraphics = YES;
self.allowsImageEditing = YES;
self.importsGraphics = YES;
Now, I guess I’ll have create my own code for resizing the embedded graphics
and setting the baseline.
On 8/4/13 9:31 PM, "Antonio Nunes" <email@hidden> wrote:
> On 5 Aug, 2013, at 01:02 , Gordon Apple <email@hidden> wrote:
>
>> > I can¹t find any access to ³pieceInfo² via PDFKit.
>> >
>> > ³PieceInfo² is a standard pdf component, which many companies use for
>> > storage of private date. In this case, the main info I need is to test for
>> > a particular key in the pieceInfo dictionary to determine if it is editable
>> > by the original source program, and can be sent back to that program for
>> > editing, then reinserted.
>
> You can't get there through PDFKit, but you can go lower down to Quartz to
> extract the information. This will allow you to find the PieceInfo dictionary
> and extract its data. I know of no way though to alter the data without going
> outside of Cocoa, so if by the above you mean you need to be able to extract
> the PieceInfo, then later put an altered version back in, then you probably
> have to look outside of whatever the system frameworks offer.
>
> If you only need to read the PieceInfo dictionary then the following may get
> you going. Depending on whether you need the document level PieceInfo or one
> form an individual page you can do something to the extent of:
>
> For document level:
> If you already have a PDFDocument from PDFKit, you can ask for its documentRef
> to dive down into Quartz. Then extract the document catalog, and find the
> PieceInfo dictionary in there.
>
> (Off the top of my head, typed directly into Mail, so take this loosely:)
>
> CGPDFDocumentRef doc = myPDFKitDoc.documentRef;
> CGPDFDictionaryRef docDict = CGPDFDocumentGetCatalog(doc);
> CGPDFDictionaryRef pieceInfoDict = NULL;
> CGPDFDictionaryGetDictionary(docDict, "PieceInfo", &pieceInfoDict);
>
> You now have the pieceInfoDict and can use CGPDF… functions to access its
> info. If you need to test for the product name key, I think you need to use
> CGPDFDictionaryApplyFunction to find the key. This should be easy, since the
> key is the only top level entry in the PieceInfo dictionary.
>
> If you need page level access:
>
> If you already have a PDFKit page object, ask it for its pageRef:
>
> CGPDFDictionaryRef pageDict = CGPDFPageGetDictionary(myPDFKitPage.pageRef);
> CGPDFDictionaryRef pieceInfoDict = NULL;
> CGPDFDictionaryGetDictionary(pageDict, "PieceInfo", & pieceInfoDict);
>
> To get the key, see above.
>
> -António
>
>
> ----------------------------------------------------
> There is a world of difference between
> searching for happiness and choosing
> to be happy.
> ----------------------------------------------------
>
>
>
>
_______________________________________________
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:
This email sent to email@hidden