Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2019-02-06 07:46:55 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2646e6faa07415e90547da264ea6d2850271a6c
e2646e6f
1 parent
f9e6f80a
Fix iOS printing issues
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
26 deletions
printing/CHANGELOG.md
printing/example/.gitignore
printing/example/ios/Runner.xcodeproj/project.pbxproj
printing/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
printing/ios/Classes/PageRenderer.h
printing/ios/Classes/PageRenderer.m
printing/ios/Classes/PrintingPlugin.m
printing/pubspec.yaml
printing/CHANGELOG.md
View file @
e2646e6
# 1.3.2
*
Fix iOS printing issues
# 1.3.1
*
Fix pana linting notices
...
...
printing/example/.gitignore
View file @
e2646e6
...
...
@@ -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
...
...
printing/example/ios/Runner.xcodeproj/project.pbxproj
View file @
e2646e6
...
...
@@ -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 =
09
10;
LastUpgradeCheck =
10
10;
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;
...
...
printing/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
View file @
e2646e6
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"
09
10"
LastUpgradeVersion =
"
10
10"
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"
...
...
printing/ios/Classes/PageRenderer.h
View file @
e2646e6
...
...
@@ -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
...
...
printing/ios/Classes/PageRenderer.m
View file @
e2646e6
...
...
@@ -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
...
...
printing/ios/Classes/PrintingPlugin.m
View file @
e2646e6
...
...
@@ -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
...
...
printing/pubspec.yaml
View file @
e2646e6
...
...
@@ -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"
...
...
Please
register
or
login
to post a comment