Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

Add PDF extraction support#24

Open
getaaron wants to merge 1 commit intosteventroughtonsmith:masterfrom
getaaron:master
Open

Add PDF extraction support#24
getaaron wants to merge 1 commit intosteventroughtonsmith:masterfrom
getaaron:master

Conversation

@getaaron
Copy link

This change adds PDF extraction support.

I only tested it on one Assets.car file and it extracted the PDFs successfully. Could use some extra testing. Feedback welcome or feel free to push directly to my fork.


@property(readonly) bool isVectorBased;

-(id)initWithURL:(id)arg1 error:(id*)arg2;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initializer replaces the need to use the CUIThemeFacet (in my limited testing)


struct CGPDFDocument *pdfDocument = [catalog pdfDocumentWithName:key];

if (pdfDocument) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well expand this path too

for( CUINamedImage *image in images )
{
if( CGSizeEqualToSize(image.size, CGSizeZero) )
if ( ![image respondsToSelector:@selector(size)]) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@getaaron getaaron mentioned this pull request Sep 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant