Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting allowed image qualities #20

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/ios/PSPDFKitPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ @interface PSPDFKitPlugin () <PSPDFViewControllerDelegate, PSPDFFlexibleToolbarC
@property (nonatomic, strong) PSPDFDocument *pdfDocument;
@property (nonatomic, strong) NSDictionary *defaultOptions;
@property (nonatomic) BOOL disableAutomaticSaving;
@property (nonatomic) PSPDFImageQuality allowedImageQualities;

@end

Expand Down Expand Up @@ -762,6 +763,15 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type {
@{@"flatten": @(PSPDFImageSaveModeFlatten),
@"flattenAndEmbed": @(PSPDFImageSaveModeFlattenAndEmbed),
},

@"PSPDFImageQuality":

@{@"low": @(PSPDFImageQualityLow),
@"medium": @(PSPDFImageQualityMedium),
@"higher": @(PSPDFImageQualityHigher),
@"best": @(PSPDFImageQualityBest),
@"all": @(PSPDFImageQualityAll)
},
};

//Note: this method crashes the second time a
Expand Down Expand Up @@ -1128,6 +1138,14 @@ - (NSString *)searchTypeAsJSON {
return [self searchModeAsJSON];
}

- (void)setAllowedImageQualitiesForPSPDFViewControllerWithJSON:(NSArray *)option {
self.allowedImageQualities = [self optionsValueForKeys:option ofType:@"PSPDFImageQuality" withDefault:PSPDFImageQualityAll];
}

- (NSArray *)allowedImageQualitiesAsJSON {
return [self optionKeysForValue:self.allowedImageQualities ofType:@"PSPDFImageQuality"];
}

#pragma mark PDFProcessing methods

- (void)convertPDFFromHTMLString:(CDVInvokedUrlCommand *)command {
Expand Down Expand Up @@ -1499,6 +1517,14 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didHideUserInterf
[self sendEventWithJSON:@{@"type": @"didHideUserInterface", @"animated": @(animated)}];
}

- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowController:(UIViewController *)controller options:(NSDictionary<NSString *,id> *)options animated:(BOOL)animated {
if ([controller isKindOfClass:PSPDFImagePickerController.class]) {
PSPDFImagePickerController *imagePicker = (PSPDFImagePickerController *)controller;
imagePicker.allowedImageQualities = self.allowedImageQualities;
}
return YES;
}

#pragma mark Annotation toolbar delegate methods

- (void)flexibleToolbarContainerDidShow:(nonnull PSPDFFlexibleToolbarContainer *)container {
Expand Down