David PHAM-VAN

Fix iOS printing issues

# 1.3.2
* Fix iOS printing issues
# 1.3.1
* Fix pana linting notices
... ...
... ... @@ -63,6 +63,7 @@
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
**/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
**/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
**/ios/Podfile.lock
**/ios/Podfile
... ...
... ... @@ -14,7 +14,6 @@
669503AD9820A2FB8EB7D135 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 438EF44EBD2180BA9FEB6DD7 /* libPods-Runner.a */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
... ... @@ -173,7 +172,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
... ... @@ -206,7 +205,6 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
... ... @@ -336,12 +334,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
... ... @@ -408,12 +408,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
... ... @@ -462,12 +464,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
... ...
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
... ... @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
... ... @@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
... ...
... ... @@ -20,8 +20,7 @@
- (instancetype)init:(FlutterMethodChannel*)channel;
- (void)drawPageAtIndex:(NSInteger)pageIndex inRect:(CGRect)printableRect;
- (void)setDocument:(NSData*)data;
@property(nonatomic, readonly) NSInteger numberOfPages;
@property(nonatomic, readonly) NSLock* lock;
@property(nonatomic) CGPDFDocumentRef pdfDocument;
@end
... ...
... ... @@ -18,11 +18,10 @@
@implementation PdfPrintPageRenderer {
FlutterMethodChannel* channel;
CGPDFDocumentRef pdfDocument;
NSLock* lock;
}
@synthesize lock;
@synthesize pdfDocument;
- (instancetype)init:(FlutterMethodChannel*)channel {
self = [super init];
self->channel = channel;
... ... @@ -31,6 +30,12 @@
return self;
}
- (void)dealloc {
if (self->pdfDocument != nil) {
CGPDFDocumentRelease(self->pdfDocument);
}
}
- (NSInteger)numberOfPages {
NSNumber* width = [[NSNumber alloc] initWithDouble:self.paperRect.size.width];
NSNumber* height =
... ... @@ -75,4 +80,24 @@
CGContextDrawPDFPage(ctx, page);
}
void dataProviderReleaseDataCallback(void* info,
const void* data,
size_t size) {
free((void*)data);
}
- (void)setDocument:(NSData*)data {
void* buffer = malloc(data.length);
memcpy(buffer, data.bytes, data.length);
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(
NULL, buffer, data.length, dataProviderReleaseDataCallback);
if (pdfDocument != nil) {
CGPDFDocumentRelease(pdfDocument);
pdfDocument = nil;
}
pdfDocument = CGPDFDocumentCreateWithProvider(dataProvider);
CGDataProviderRelease(dataProvider);
[lock unlock];
}
@end
... ...
... ... @@ -33,7 +33,7 @@
- (instancetype)init:(FlutterMethodChannel*)channel {
self = [super init];
self->channel = channel;
self->renderer = [[PdfPrintPageRenderer alloc] init:channel];
self->renderer = nil;
return self;
}
... ... @@ -72,6 +72,7 @@
printInfo.jobName = name;
printInfo.outputType = UIPrintInfoOutputGeneral;
controller.printInfo = printInfo;
renderer = [[PdfPrintPageRenderer alloc] init:channel];
[controller setPrintPageRenderer:renderer];
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController* printController, BOOL completed,
... ... @@ -80,25 +81,14 @@
NSLog(@"FAILED! due to error in domain %@ with error code %u",
error.domain, (unsigned int)error.code);
}
if (self->renderer.pdfDocument != nil) {
CGPDFDocumentRelease(self->renderer.pdfDocument);
self->renderer.pdfDocument = nil;
}
self->renderer = nil;
};
[controller presentAnimated:YES completionHandler:completionHandler];
}
- (void)writePdf:(nonnull FlutterStandardTypedData*)data {
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(
NULL, data.data.bytes, data.data.length, NULL);
if (renderer.pdfDocument != nil) {
CGPDFDocumentRelease(renderer.pdfDocument);
renderer.pdfDocument = nil;
}
renderer.pdfDocument = CGPDFDocumentCreateWithProvider(dataProvider);
CGDataProviderRelease(dataProvider);
[renderer.lock unlock];
[renderer setDocument:data.data];
}
- (void)sharePdf:(nonnull FlutterStandardTypedData*)data
... ...
... ... @@ -2,7 +2,7 @@ name: printing
author: David PHAM-VAN <dev.nfet.net@gmail.com>
description: Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers
homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
version: 1.3.1
version: 1.3.2
environment:
sdk: ">=1.19.0 <3.0.0"
... ...