Re: Storing an NSImage File
Re: Storing an NSImage File
- Subject: Re: Storing an NSImage File
- From: Antonio Nunes <email@hidden>
- Date: Mon, 05 Aug 2013 03:31:30 +0100
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