Skip to content

Commit

Permalink
Release 3.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Feb 27, 2024
1 parent 91651d8 commit 05b38da
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 40 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## Newest Release

### 3.8.1 - 14 Feb 2024
- Fixes callbacks when Pspdfkit.present() is used. (J#HYB-204)
### 3.8.2 - 27 Feb 2024

- Updates for PSPDFKit 13.3.1 for iOS. (#43550)
- Fixes issue where PSPDFKit for Flutter does not work on web with Flutter SDK version 13.19.0 (J#HYB-216)
- Fixes issue where annotation toolbar items are not being displayed on Web. (J#HYB-217)

## Previous Releases

### 3.8.1 - 14 Feb 2024
- Fixes callbacks when Pspdfkit.present() is used. (J#HYB-204)

### 3.8.0 - 06 Feb 2024
- Adds Flutter for Web support. (#42151)
- Replaces configuration `Map` with a dedicated `PdfConfiguration` class. (#42191)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class FlutterInstantPdfActivity : InstantPdfActivity() {

override fun onDocumentLoaded(pdfDocument: PdfDocument) {
super.onDocumentLoaded(pdfDocument)
EventDispatcher.getInstance().notifyDocumentLoaded(pdfDocument)
val result = loadedDocumentResult.getAndSet(null)
result?.success(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected void onDestroy() {
@Override
public void onDocumentLoaded(@NonNull PdfDocument pdfDocument) {
super.onDocumentLoaded(pdfDocument);
EventDispatcher.getInstance().notifyDocumentLoaded(pdfDocument);
Result result = loadedDocumentResult.getAndSet(null);
if (result != null) {
result.success(true);
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pspdfkit_example
description: Demonstrates how to use the pspdfkit plugin.
version: 3.8.1
version: 3.8.2
homepage: https://pspdfkit.com/
environment:
sdk: '>=2.17.0 <4.0.0'
Expand Down
8 changes: 4 additions & 4 deletions ios/pspdfkit_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
Pod::Spec.new do |s|
s.name = "pspdfkit_flutter"
s.version = "3.8.1"
s.version = "3.8.2"
s.homepage = "https://PSPDFKit.com"
s.documentation_url = "https://pspdfkit.com/guides/flutter"
s.license = { type: "Commercial", file: "../LICENSE" }
Expand All @@ -18,10 +18,10 @@ Pod::Spec.new do |s|
s.source_files = "Classes/**/*.{h,m,swift}"
s.public_header_files = "Classes/**/*.h"
s.dependency("Flutter")
s.dependency("PSPDFKit", "13.3.0")
s.dependency("Instant", "13.3.0")
s.dependency("PSPDFKit", "13.3.1")
s.dependency("Instant", "13.3.1")
s.swift_version = "5.0"
s.platform = :ios, "15.0"
s.version = "3.8.1"
s.version = "3.8.2"
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES", "SWIFT_INSTALL_OBJC_HEADER" => "NO" }
end
13 changes: 8 additions & 5 deletions lib/src/web/pspdfkit_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
/// This notice may not be removed from this file.
///
import 'dart:html';
import 'dart:js';
import 'package:pspdfkit_flutter/src/web/models/pspdfkit_web_toolbar_item.dart';
import 'package:pspdfkit_flutter/src/web/pspdfkit_web_instance.dart';
import 'package:pspdfkit_flutter/src/web/pspdfkit_web_configuration_helper.dart';

import '../pdf_configuration.dart';
import 'pspdfkit_web_utils.dart';

const flutterWebProductId = 'FlutterForWeb';

/// Provides access to PSPDFKit for web.
///
/// This class represents the [PSPDFKit](https://pspdfkit.com/api/web/PSPDFKit.html) object in the PSPDFKit Web SDK.
Expand All @@ -33,6 +35,7 @@ class PSPDFKitWeb {
// Try to set the license key to confirm it is valid, then store it in local storage.
var config = JsObject.jsify({
'licenseKey': licenseKey,
'productId': flutterWebProductId,
});

await promiseToFuture(_pspdfkit.callMethod('preloadWorker', [config]))
Expand All @@ -48,7 +51,7 @@ class PSPDFKitWeb {
///
/// The [documentPath] parameter specifies the path to the document that will be loaded.
///
/// The [id] parameter is used to identify the container element in which the PSPDFKit instance will be rendered.
/// The [element] parameter is used to identify the container element in which the PSPDFKit instance will be rendered.
///
/// The [configuration] parameter is an optional configuration object that can be used to customize the behavior of PSPDFKit.
///
Expand All @@ -68,10 +71,10 @@ class PSPDFKitWeb {
///
/// // Use the instance to interact with the document.
/// ```
static Future<PspdfkitWebInstance> load(
String documentPath, int id, PdfConfiguration? configuration) async {
static Future<PspdfkitWebInstance> load(String documentPath, Element element,
PdfConfiguration? configuration) async {
var webConfiguration = WebConfigurationHelper.populateWebConfiguration(
id,
element,
documentPath,
_pspdfkitLicenseKey,
configuration,
Expand Down
16 changes: 11 additions & 5 deletions lib/src/web/pspdfkit_web_configuration_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
/// This notice may not be removed from this file.
///
import 'dart:html';
import 'dart:js';
import 'package:pspdfkit_flutter/src/web/pspdfkit_web_utils.dart';

import '../../pspdfkit.dart';
import 'pspdfkit_web.dart';
import 'pspdfkit_web_utils.dart';

/// This is a utility class used to convert a [PdfConfiguration] to a [PSPDFKit.Configuration](https://pspdfkit.com/api/web/PSPDFKit.Configuration.html) JsObject for Web.
/// It is used in [PSPDFKitWeb.load]. This class isolates the js interop code from the rest of the plugin.
Expand All @@ -28,7 +29,7 @@ class WebConfigurationHelper {
///
/// Returns a [PSPDFKit.Configuration](https://pspdfkit.com/api/web/PSPDFKit.Configuration.html) JsObject.
static JsObject populateWebConfiguration(
int id,
Element element,
String documentPath,
String? licenseKey,
PdfConfiguration? configuration,
Expand Down Expand Up @@ -94,7 +95,11 @@ class WebConfigurationHelper {

// Return a list of new annotation toolbar items.
return JsObject.jsify(
newAnnotationToolbarItems?.map((e) => e.toJsObject()).toList() ?? []);
newAnnotationToolbarItems?.map((e) => e.toJsObject()).toList() ??
[
...callbackOptions.defaultAnnotationToolbarItems
.map((e) => e.toJsObject())
]);
}

// Remove the annotation toolbar items from the configuration.
Expand All @@ -104,7 +109,8 @@ class WebConfigurationHelper {
var map = <String, dynamic>{
'document': documentPath,
'licenseKey': licenseKey,
'container': '#pspdfkit-$id',
'productId': flutterWebProductId,
'container': element,
'initialViewState': initialViewState,
'password': configuration?.password,
'editableAnnotationTypes': configuration?.editableAnnotationTypes,
Expand Down
2 changes: 0 additions & 2 deletions lib/src/widgets/pspdfkit_widget_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import '../../pspdfkit.dart';

/// A controller for a PSPDFKit widget.
abstract class PspdfkitWidgetController {
PspdfkitWidgetController(int id);

/// Sets the value of a form field by specifying its fully qualified field name.
Future<bool?> setFormFieldValue(String value, String fullyQualifiedName);

Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/pspdfkit_widget_controller_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import 'package:flutter/services.dart';
import '../../pspdfkit.dart';
import 'pspdfkit_widget_controller.dart';

/// A controller for a PSPDFKit widget for native platforms that use the [MethodChannel].
class PspdfkitWidgetControllerNative implements PspdfkitWidgetController {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/pspdfkit_widget_controller_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'pspdfkit_widget_controller.dart';
class PspdfkitWidgetControllerWeb implements PspdfkitWidgetController {
final PspdfkitWebInstance pspdfkitInstance;

PspdfkitWidgetControllerWeb(int id, this.pspdfkitInstance);
PspdfkitWidgetControllerWeb(this.pspdfkitInstance);

@override
Future<dynamic> getAnnotations(int pageIndex, String type) async {
Expand Down
34 changes: 20 additions & 14 deletions lib/src/widgets/pspdfkit_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
library pspdfkit_widget_web;

import 'dart:async';
import 'dart:html';
import 'dart:html' as html;
import 'dart:ui_web' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:pspdfkit_flutter/pspdfkit.dart';

import '../web/pspdfkit_web.dart';
import 'pspdfkit_widget_controller.dart';
import 'pspdfkit_widget_controller_web.dart';

typedef PspdfkitWidgetCreatedCallback = void Function(
Expand Down Expand Up @@ -48,17 +46,23 @@ class _PspdfkitWidgetState extends State<PspdfkitWidget> {
Widget build(BuildContext context) {
ui.platformViewRegistry.registerViewFactory('pspdfkit-widget',
(int viewId) {
return DivElement()..id = 'pspdfkit-$viewId';
return html.DivElement()..id = 'pspdfkit-$viewId';
});
return HtmlElementView(
viewType: 'pspdfkit-widget',
onPlatformViewCreated: (int id) {
_onPlatformViewCreated(id);
// Elements are no longer available when onPlatformViewCreated is called.
// Therefore we need to pass the element to the PSPDFKit.load method instead of the id.
// See this GH issue for more details: https://github.com/flutter/flutter/issues/143922#issuecomment-1960133128
var div = (ui.platformViewRegistry.getViewById(id) as html.Element)
..style.width = '100%'
..style.height = '100%';
_onPlatformViewCreated(div);
});
}

/// Load the document and create the PSPDFKit instance.
Future<void> _onPlatformViewCreated(int id) async {
Future<void> _onPlatformViewCreated(html.Element id) async {
// Prepare the configuration object.
// Only pass the configuration if it is a PdfConfiguration.
PdfConfiguration? configuration;
Expand All @@ -73,13 +77,15 @@ class _PspdfkitWidgetState extends State<PspdfkitWidget> {
} else {
configuration = null;
}

await PSPDFKitWeb.load(widget.documentPath, id, configuration)
.then((value) {
var controller = PspdfkitWidgetControllerWeb(id, value);
widget.onPspdfkitWidgetCreated?.call(controller);
}).catchError((error) {
throw Exception('Failed to load: $error');
// Adding a delay to ensure that the view is properly registered before we try to create the PSPDFKit instance.
Future.delayed(const Duration(milliseconds: 10), () async {
await PSPDFKitWeb.load(widget.documentPath, id, configuration)
.then((value) {
var controller = PspdfkitWidgetControllerWeb(value);
widget.onPspdfkitWidgetCreated?.call(controller);
}).catchError((error) {
throw Exception('Failed to load: $error');
});
});
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pspdfkit_flutter
description: A Flutter plugin providing a feature-rich PDF viewing and editing experience to your users with the powerful PSPDFKit PDF SDK.
version: 3.8.1
version: 3.8.2
homepage: https://pspdfkit.com/
repository: https://github.com/PSPDFKit/pspdfkit-flutter
issue_tracker: https://support.pspdfkit.com/hc/en-us/requests/new
Expand Down

0 comments on commit 05b38da

Please sign in to comment.