Add PDF extraction support#24
Add PDF extraction support#24getaaron wants to merge 1 commit intosteventroughtonsmith:masterfrom getaaron:master
Conversation
|
|
||
| @property(readonly) bool isVectorBased; | ||
|
|
||
| -(id)initWithURL:(id)arg1 error:(id*)arg2; |
There was a problem hiding this comment.
This initializer replaces the need to use the CUIThemeFacet (in my limited testing)
|
|
||
| struct CGPDFDocument *pdfDocument = [catalog pdfDocumentWithName:key]; | ||
|
|
||
| if (pdfDocument) { |
There was a problem hiding this comment.
If there's a PDF document, I'm skipping the extraction of the generated raster images and only extracting the PDF
| return images; | ||
| } | ||
|
|
||
| void writePDFtoFile(struct CGPDFDocument *pdfDocument, NSString *path, NSString *key) { |
There was a problem hiding this comment.
I'm not super familiar with CGPDFDocument, but I cobbled this together from a few answers on Stack Overflow and pastern and it hasn't failed me yet
| /* Override CUICatalog to point to a file rather than a bundle */ | ||
| [catalog setValue:facet forKey:@"_storageRef"]; | ||
|
|
||
| carPath = [carPath stringByExpandingTildeInPath]; |
There was a problem hiding this comment.
Might as well expand this path too
| for( CUINamedImage *image in images ) | ||
| { | ||
| if( CGSizeEqualToSize(image.size, CGSizeZero) ) | ||
| if ( ![image respondsToSelector:@selector(size)]) { |
There was a problem hiding this comment.
This if statement is kinda sloppy — I wish I could do something like if ( ![image isKindOfClass:[CGPDFDocument class]]), but of course CGPDFDocument isn't a class and I don't think there's any way to check the struct type at runtime. Wonder if you know of anything better.
This change adds PDF extraction support.
I only tested it on one
Assets.carfile and it extracted the PDFs successfully. Could use some extra testing. Feedback welcome or feel free to push directly to my fork.