Skip to content

Commit e8a8ffc

Browse files
author
PSPDFKit
committed
Release 3.2.2
1 parent e8354b1 commit e8a8ffc

13 files changed

+241
-60
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
## Newest Release
22

3+
### 3.2.2 - 16 Mar 2022
4+
5+
- Improves the example project by using the `PlatformUtils` class to check for supported platforms (#33212)
6+
- Adds a new **Save As** example to the example project. (#33376)
7+
- Updates for PSPDFKit 11.3.0 for iOS. (#33514)
8+
9+
## Previous Releases
10+
311
### 3.2.1 - 04 Mar 2022
412

513
- Updates for PSPDFKit 8.1.2 for Android. (#33314)
614
- Updates for PSPDFKit 11.2.4 for iOS. (#33314)
715

8-
## Previous Releases
9-
1016
### 3.2.0 - 14 Feb 2022
1117

1218
- This release requires you to update your Android project's `compileSdkVersion` to version 31. Please refer to [our migration guide](https://pspdfkit.com/guides/flutter/migration-guides/flutter-3-2-0-migration-guide) for this release.

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ flutter_ios_podfile_setup
2929

3030
target 'Runner' do
3131
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
32-
pod 'PSPDFKit', '~> 11.2.4'
32+
pod 'PSPDFKit', '~> 11.3.0'
3333
end
3434

3535
post_install do |installer|

example/lib/main.dart

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'dart:async';
1212
import 'package:flutter/cupertino.dart';
1313
import 'package:flutter/material.dart';
1414
import 'package:flutter/services.dart';
15+
import 'package:pspdfkit_example/pspdfkit_save_as_example.dart';
1516

1617
import 'package:pspdfkit_flutter/src/main.dart';
1718
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
@@ -21,7 +22,9 @@ import 'pspdfkit_form_example.dart';
2122
import 'pspdfkit_instantjson_example.dart';
2223
import 'pspdfkit_annotations_example.dart';
2324
import 'pspdfkit_manual_save_example.dart';
25+
import 'pspdfkit_save_as_example.dart';
2426
import 'pspdfkit_annotation_processing_example.dart';
27+
import 'platform_utils.dart';
2528

2629
const String _documentPath = 'PDFs/PSPDFKit.pdf';
2730
const String _lockedDocumentPath = 'PDFs/protected.pdf';
@@ -59,8 +62,11 @@ const String _annotationsExample =
5962
const String _annotationsExampleSub =
6063
'Programmatically adds and removes annotations using a custom Widget.';
6164
const String _manualSaveExample = 'Manual Save';
65+
const String _saveAsExample = 'Save As';
6266
const String _manualSaveExampleSub =
6367
'Add a save button at the bottom and disable automatic saving.';
68+
const String _saveAsExampleSub =
69+
'Embed and save the changes made to a document into a new file';
6470
const String _annotationProcessingExample = 'Process Annotations';
6571
const String _annotationProcessingExampleSub =
6672
'Programmatically adds and removes annotations using a custom Widget.';
@@ -145,31 +151,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
145151
return file;
146152
}
147153

148-
bool isCupertino(BuildContext context) {
149-
final defaultTargetPlatform = Theme.of(context).platform;
150-
switch (defaultTargetPlatform) {
151-
case TargetPlatform.iOS:
152-
case TargetPlatform.macOS:
153-
return true;
154-
case TargetPlatform.android:
155-
case TargetPlatform.fuchsia:
156-
case TargetPlatform.linux:
157-
case TargetPlatform.windows:
158-
return false;
159-
}
160-
}
161-
162154
void showDocument() async {
163155
final extractedDocument = await extractAsset(_documentPath);
164156
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
165157
builder: (_) => Scaffold(
166-
extendBodyBehindAppBar: isCupertino(context) ? false : true,
158+
extendBodyBehindAppBar:
159+
PlatformUtils.isCupertino(context) ? false : true,
167160
appBar: AppBar(),
168161
body: SafeArea(
169162
top: false,
170163
bottom: false,
171164
child: Container(
172-
padding: isCupertino(context)
165+
padding: PlatformUtils.isCupertino(context)
173166
? null
174167
: const EdgeInsets.only(top: kToolbarHeight),
175168
child: PspdfkitWidget(
@@ -179,7 +172,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
179172
void showDocumentPlatformStyle() async {
180173
final extractedDocument = await extractAsset(_documentPath);
181174

182-
if (isCupertino(context)) {
175+
if (PlatformUtils.isCupertino(context)) {
183176
await Navigator.of(context).push<dynamic>(CupertinoPageRoute<dynamic>(
184177
builder: (_) => CupertinoPageScaffold(
185178
navigationBar: const CupertinoNavigationBar(),
@@ -206,13 +199,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
206199
final extractedImage = await extractAsset(_imagePath);
207200
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
208201
builder: (_) => Scaffold(
209-
extendBodyBehindAppBar: isCupertino(context) ? false : true,
202+
extendBodyBehindAppBar:
203+
PlatformUtils.isCupertino(context) ? false : true,
210204
appBar: AppBar(),
211205
body: SafeArea(
212206
top: false,
213207
bottom: false,
214208
child: Container(
215-
padding: isCupertino(context)
209+
padding: PlatformUtils.isCupertino(context)
216210
? null
217211
: const EdgeInsets.only(top: kToolbarHeight),
218212
child:
@@ -223,13 +217,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
223217
final extractedDocument = await extractAsset(_documentPath);
224218
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
225219
builder: (_) => Scaffold(
226-
extendBodyBehindAppBar: isCupertino(context) ? false : true,
220+
extendBodyBehindAppBar:
221+
PlatformUtils.isCupertino(context) ? false : true,
227222
appBar: AppBar(),
228223
body: SafeArea(
229224
top: false,
230225
bottom: false,
231226
child: Container(
232-
padding: isCupertino(context)
227+
padding: PlatformUtils.isCupertino(context)
233228
? null
234229
: const EdgeInsets.only(top: kToolbarHeight),
235230
child: PspdfkitWidget(
@@ -245,13 +240,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
245240
final extractedDocument = await extractAsset(_documentPath);
246241
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
247242
builder: (_) => Scaffold(
248-
extendBodyBehindAppBar: isCupertino(context) ? false : true,
243+
extendBodyBehindAppBar:
244+
PlatformUtils.isCupertino(context) ? false : true,
249245
appBar: AppBar(),
250246
body: SafeArea(
251247
top: false,
252248
bottom: false,
253249
child: Container(
254-
padding: isCupertino(context)
250+
padding: PlatformUtils.isCupertino(context)
255251
? null
256252
: const EdgeInsets.only(top: kToolbarHeight),
257253
child: PspdfkitWidget(
@@ -312,13 +308,14 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
312308
final extractedLockedDocument = await extractAsset(_lockedDocumentPath);
313309
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
314310
builder: (_) => Scaffold(
315-
extendBodyBehindAppBar: isCupertino(context) ? false : true,
311+
extendBodyBehindAppBar:
312+
PlatformUtils.isCupertino(context) ? false : true,
316313
appBar: AppBar(),
317314
body: SafeArea(
318315
top: false,
319316
bottom: false,
320317
child: Container(
321-
padding: isCupertino(context)
318+
padding: PlatformUtils.isCupertino(context)
322319
? null
323320
: const EdgeInsets.only(top: kToolbarHeight),
324321
child: PspdfkitWidget(
@@ -350,8 +347,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
350347
}
351348

352349
void manualSaveExample() async {
353-
final extractedWritableDocument =
354-
await extractAsset(_documentPath, shouldOverwrite: false, prefix: 'persist');
350+
final extractedWritableDocument = await extractAsset(_documentPath,
351+
shouldOverwrite: false, prefix: 'persist');
355352

356353
// Automatic Saving of documents is enabled by default in certain scenarios [see for details: https://pspdfkit.com/guides/flutter/save-a-document/#auto-save]
357354
// In order to manually save documents, you might consider disabling automatic saving with disableAutosave: true in the config
@@ -361,6 +358,18 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
361358
configuration: const {disableAutosave: true})));
362359
}
363360

361+
void saveAsExample() async {
362+
final extractedWritableDocument = await extractAsset(_documentPath,
363+
shouldOverwrite: false, prefix: 'persist');
364+
365+
// Automatic Saving of documents is enabled by default in certain scenarios [see for details: https://pspdfkit.com/guides/flutter/save-a-document/#auto-save]
366+
// In order to manually save documents, you might consider disabling automatic saving with disableAutosave: true in the config
367+
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
368+
builder: (_) => PspdfkitSaveAsExampleWidget(
369+
documentPath: extractedWritableDocument.path,
370+
configuration: const {disableAutosave: true})));
371+
}
372+
364373
void annotationProcessingExample() async {
365374
final extractedDocument = await extractAsset(_documentPath);
366375
await Navigator.of(context).push<dynamic>(MaterialPageRoute<dynamic>(
@@ -374,7 +383,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
374383
final extractedDocument = await extractAsset(_documentPath);
375384
final extractedFormDocument = await extractAsset(_formPath);
376385

377-
if (isCupertino(context)) {
386+
if (PlatformUtils.isCupertino(context)) {
378387
await Navigator.of(context).push<dynamic>(CupertinoPageRoute<dynamic>(
379388
builder: (_) => CupertinoPageScaffold(
380389
navigationBar: CupertinoNavigationBar(),
@@ -669,20 +678,25 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
669678
title: const Text(_manualSaveExample),
670679
subtitle: const Text(_manualSaveExampleSub),
671680
onTap: () => manualSaveExample()),
681+
if (PlatformUtils.isCupertino(context))
682+
ListTile(
683+
title: const Text(_saveAsExample),
684+
subtitle: const Text(_saveAsExampleSub),
685+
onTap: () => saveAsExample()),
672686
// The annotation processing example is supported by iOS only for now.
673-
if (isCupertino(context))
687+
if (PlatformUtils.isCupertino(context))
674688
ListTile(
675689
title: const Text(_annotationProcessingExample),
676690
subtitle: const Text(_annotationProcessingExampleSub),
677691
onTap: () => annotationProcessingExample()),
678692
// The import Instant JSON example is supported by iOS only for now.
679-
if (isCupertino(context))
693+
if (PlatformUtils.isCupertino(context))
680694
ListTile(
681695
title: const Text(_importInstantJsonExample),
682696
subtitle: const Text(_importInstantJsonExampleSub),
683697
onTap: () => importInstantJsonExample()),
684698
// The push two PspdfWidgets simultaneously example is supported by iOS only for now.
685-
if (isCupertino(context))
699+
if (PlatformUtils.isCupertino(context))
686700
ListTile(
687701
title: const Text(_widgetExampleFullScreen),
688702
subtitle: const Text(_widgetExampleFullScreenSub),

example/lib/platform_utils.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/foundation.dart';
2+
import 'package:flutter/material.dart';
23

34
class PlatformUtils {
45
static bool isCurrentPlatformSupported() {
@@ -13,4 +14,18 @@ class PlatformUtils {
1314
static bool isIOS() {
1415
return defaultTargetPlatform == TargetPlatform.iOS;
1516
}
17+
18+
static bool isCupertino(BuildContext context) {
19+
final defaultTargetPlatform = Theme.of(context).platform;
20+
switch (defaultTargetPlatform) {
21+
case TargetPlatform.iOS:
22+
case TargetPlatform.macOS:
23+
return true;
24+
case TargetPlatform.android:
25+
case TargetPlatform.fuchsia:
26+
case TargetPlatform.linux:
27+
case TargetPlatform.windows:
28+
return false;
29+
}
30+
}
1631
}

example/lib/pspdfkit_annotation_processing_example.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
1414
import 'package:flutter/foundation.dart';
1515
import 'package:flutter/cupertino.dart';
1616
import 'package:flutter/material.dart';
17+
import 'package:pspdfkit_example/platform_utils.dart';
1718

1819
import 'package:pspdfkit_flutter/src/main.dart';
1920
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
@@ -64,7 +65,7 @@ class _PspdfkitAnnotationProcessingExampleWidgetState
6465
'configuration': widget.configuration
6566
};
6667

67-
if (defaultTargetPlatform == TargetPlatform.iOS) {
68+
if (PlatformUtils.isIOS()) {
6869
return CupertinoPageScaffold(
6970
navigationBar: const CupertinoNavigationBar(),
7071
child: SafeArea(
@@ -117,7 +118,7 @@ class _PspdfkitAnnotationProcessingExampleWidgetState
117118
child: Text('Print Annotations'))
118119
]))
119120
])));
120-
} else if (defaultTargetPlatform == TargetPlatform.android) {
121+
} else if (PlatformUtils.isAndroid()) {
121122
// This example is only supported in iOS at the moment.
122123
// Support for Android is coming soon.
123124
return Text('Unsupported Widget');

example/lib/pspdfkit_annotations_example.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import 'package:flutter/material.dart';
1818

1919
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
2020

21+
import 'platform_utils.dart';
22+
2123
const annotationJsonHashMap = {
2224
'uuid': 'A92AA288-B11D-490C-847B-D1A0BC64D3E9',
2325
'bbox': [
@@ -130,22 +132,20 @@ class _PspdfkitAnnotationsExampleWidgetState
130132
'document': widget.documentPath,
131133
'configuration': widget.configuration
132134
};
133-
if (defaultTargetPlatform == TargetPlatform.android ||
134-
defaultTargetPlatform == TargetPlatform.iOS) {
135+
if (PlatformUtils.isCurrentPlatformSupported()) {
135136
return Scaffold(
136-
extendBodyBehindAppBar:
137-
defaultTargetPlatform == TargetPlatform.android,
137+
extendBodyBehindAppBar: PlatformUtils.isAndroid(),
138138
appBar: AppBar(),
139139
body: SafeArea(
140140
top: false,
141141
bottom: false,
142142
child: Container(
143-
padding: defaultTargetPlatform == TargetPlatform.iOS
143+
padding: PlatformUtils.isIOS()
144144
? null
145145
: const EdgeInsets.only(top: kToolbarHeight),
146146
child: Column(children: <Widget>[
147147
Expanded(
148-
child: defaultTargetPlatform == TargetPlatform.android
148+
child: PlatformUtils.isAndroid()
149149
? PlatformViewLink(
150150
viewType: viewType,
151151
surfaceFactory: (BuildContext context,
@@ -197,7 +197,7 @@ class _PspdfkitAnnotationsExampleWidgetState
197197
// E.g: `await view.addAnnotation(annotationJsonString);`
198198
},
199199
child: const Text('Add Annotation')),
200-
if (defaultTargetPlatform == TargetPlatform.iOS)
200+
if (PlatformUtils.isIOS())
201201
ElevatedButton(
202202
onPressed: () async {
203203
dynamic annotationsJson =

example/lib/pspdfkit_form_example.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:flutter/gestures.dart';
1515
import 'package:flutter/rendering.dart';
1616
import 'package:flutter/cupertino.dart';
1717
import 'package:flutter/material.dart';
18+
import 'package:pspdfkit_example/platform_utils.dart';
1819

1920
import 'package:pspdfkit_flutter/src/widgets/pspdfkit_widget_controller.dart';
2021

@@ -53,25 +54,23 @@ class _PspdfkitFormExampleWidgetState extends State<PspdfkitFormExampleWidget> {
5354
'document': widget.documentPath,
5455
'configuration': widget.configuration
5556
};
56-
if (defaultTargetPlatform == TargetPlatform.android ||
57-
defaultTargetPlatform == TargetPlatform.iOS) {
57+
if (PlatformUtils.isCurrentPlatformSupported()) {
5858
return Scaffold(
59-
extendBodyBehindAppBar:
60-
defaultTargetPlatform == TargetPlatform.android,
59+
extendBodyBehindAppBar: PlatformUtils.isAndroid(),
6160
// Do not resize the the document view on Android or
6261
// it won't be rendered correctly when filling forms.
63-
resizeToAvoidBottomInset: defaultTargetPlatform == TargetPlatform.iOS,
62+
resizeToAvoidBottomInset: PlatformUtils.isIOS(),
6463
appBar: AppBar(),
6564
body: SafeArea(
6665
top: false,
6766
bottom: false,
6867
child: Container(
69-
padding: defaultTargetPlatform == TargetPlatform.iOS
68+
padding: PlatformUtils.isIOS()
7069
? null
7170
: const EdgeInsets.only(top: kToolbarHeight),
7271
child: Column(children: <Widget>[
7372
Expanded(
74-
child: defaultTargetPlatform == TargetPlatform.android
73+
child: PlatformUtils.isAndroid()
7574
? PlatformViewLink(
7675
viewType: viewType,
7776
surfaceFactory: (BuildContext context,
@@ -117,8 +116,7 @@ class _PspdfkitFormExampleWidgetState extends State<PspdfkitFormExampleWidget> {
117116
// On Android do not show the buttons when the Keyboard
118117
// is visible. PSPDFKit for Android automatically
119118
// fills the space available and re-render the document view.
120-
if (!_keyboardVisible ||
121-
defaultTargetPlatform == TargetPlatform.iOS)
119+
if (!_keyboardVisible || PlatformUtils.isIOS())
122120
SizedBox(
123121
child: Row(
124122
mainAxisAlignment: MainAxisAlignment.spaceEvenly,

0 commit comments

Comments
 (0)