Skip to content

Commit

Permalink
Release 3.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PSPDFKit committed Jul 30, 2024
1 parent a7cc9f5 commit cf2375b
Show file tree
Hide file tree
Showing 35 changed files with 722 additions and 91 deletions.
26 changes: 26 additions & 0 deletions ACKNOWLEDGEMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,32 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------
## swift-perception (https://github.com/pointfreeco/swift-perception)

MIT License

Copyright (c) 2023 Point-Free

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


--------------------------------------------------------------------------------
## Tesseract (https://tesseract-ocr.github.io/)

Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
## Newest Release

### 3.12.0 - 30 Jul 2024

- Adds `zoomToRect` and `getVisibleRect` APIs to PspdfkitWidgetController. (J#HYB-429)
- Added `processAnnotations` API support for Android. (J#HYB-426)
- Updated the `processAnnotations` parameter types to enums `AnnotationType` and `AnnotationProcessingMode`. (#44722)
- Updates for PSPDFKit 2024.4.0 for Android. (J#HYB-422)
- Updates for PSPDFKit 13.8.0 for iOS. (J#HYB-422)

## Previous Releases

### 3.11.0 - 21 Jun 2024

- Adds API to get form filed properties to PdfDocument. (J#HYB-169)
- Adds instant synchronization support on Web. (J#HYB-377)

## Previous Releases

### 3.10.1 - 28 May 2024

- Fixes issue where ViewUtils.generateViewId() cannot be resolved. (J#HYB-379)

### 3.10.0 - 03 May 2024

- Adds APIs to get page information such as size, rotation, and label. (J#HYB-195)
- Adds document load callbacks to `PspdfkitWidget`. (J#HYB-195)
- Adds page change callback to `PspdfkitWidget`. (J#HYB-195)
Expand All @@ -18,6 +29,7 @@
- Updates for PSPDFKit 13.4.1 for iOS.

### 3.9.1 - 12 Apr 2024

- Downgrades to AGP 7.* for backward compatibility (J#HYB-290)
- Allow null value for `Pspdfkit.setLicenseKey` (J#HYB-294)
- Updates for PSPDFKit 2024.2.1 for Android (J#HYB-303)
Expand All @@ -38,9 +50,11 @@
- Fixes issue where annotation toolbar items are not being displayed on Web. (J#HYB-217)

### 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)
- Deprecates imports for `package:pspdfkit_flutter/widgets/pspdfkit_widget.dart` and `package:pspdfkit_flutter/widgets/pspdfkit_widget_controller.dart`.
Expand Down Expand Up @@ -68,17 +82,20 @@
- Updates example catalog with PspdfkitWidget usage. (#40861)

### 3.6.0 - 08 May 2023

- Adds measurement tools. (#39806)
- Updates for PSPDFKit 8.6.0 for Android. (#39501)
- Updates for PSPDFKit 12.2 for iOS. (#39995)

### 3.5.1 - 15 Mar 2023

- Updates iOS license initialization in the example catalog. (#38999)
- Updates Instant web demo links. (#39018)
- Updates for PSPDFKit 8.5.1 for Android. (#39090)
- Updates for PSPDFKit 12.1.2 for iOS. (#39090)

### 3.5.0 - 17 Jan 2023

- Adds Instant Synchronization support. (#37675)
- Updates for PSPDFKit 8.5 for Android. (#38136)
- Updates for PSPDFKit 12.0.2 for iOS. (#38136)
Expand Down
2 changes: 1 addition & 1 deletion android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (pspdfkitMavenUrl == null || pspdfkitMavenUrl == '') {

ext.pspdfkitVersion = localProperties.getProperty('pspdfkit.version')
if (pspdfkitVersion == null || pspdfkitVersion == '') {
ext.pspdfkitVersion = '2024.3.0'
ext.pspdfkitVersion = '2024.4.0'
}

ext.pspdfkitMavenModuleName = 'pspdfkit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ class ConfigurationAdapter {
private static final String ENABLED_MEASUREMENT_TOOLS = "enableMeasurementTools";
private static final String ENABLE_MAGNIFIER = "enableMagnifier";
private static final String ENABLED_MEASUREMENT_TOOL_SNAPPING = "enableMeasurementToolSnapping";

private static final String MAXIMUM_ZOOM_SCALE = "maximumZoomScale";
private static final String MINIMUM_ZOOM_SCALE = "minimumZoomScale";
private static final String DEFAULT_ZOOM_SCALE = "defaultZoomScale";

@NonNull
private final PdfActivityConfiguration.Builder configuration;
@Nullable
Expand Down Expand Up @@ -386,6 +389,17 @@ class ConfigurationAdapter {
if (key != null) {
configureMeasurementToolSnappingEnabled(context,(Boolean) configurationMap.get(key));
}

key = getKeyOfType(configurationMap, MAXIMUM_ZOOM_SCALE, Double.class);
if (key != null) {
configuration.maxZoomScale((float) configurationMap.get(key));
}

key = getKeyOfType(configurationMap, DEFAULT_ZOOM_SCALE, Double.class);
if (key != null) {
double value = (double) configurationMap.get(key);
configuration.startZoomScale((float) value);
}
}
}

Expand Down
121 changes: 114 additions & 7 deletions android/src/main/java/com/pspdfkit/flutter/pspdfkit/PSPDFKitView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.pspdfkit.flutter.pspdfkit
import android.annotation.SuppressLint
import android.content.Context
import android.content.MutableContextWrapper
import android.graphics.RectF
import android.net.Uri
import android.util.Log
import android.view.View
Expand All @@ -12,15 +13,18 @@ import androidx.fragment.app.FragmentContainerView
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.commit
import androidx.fragment.app.commitNow
import com.pspdfkit.annotations.AnnotationType
import com.pspdfkit.document.formatters.DocumentJsonFormatter
import com.pspdfkit.document.processor.PdfProcessor
import com.pspdfkit.document.processor.PdfProcessor.ProcessorProgress
import com.pspdfkit.document.processor.PdfProcessorTask
import com.pspdfkit.flutter.pspdfkit.AnnotationConfigurationAdaptor.Companion.convertAnnotationConfigurations
import com.pspdfkit.flutter.pspdfkit.toolbar.FlutterMenuGroupingRule
import com.pspdfkit.flutter.pspdfkit.toolbar.FlutterViewModeController
import com.pspdfkit.flutter.pspdfkit.util.DocumentJsonDataProvider
import com.pspdfkit.flutter.pspdfkit.util.Preconditions.requireNotNullNotEmpty
import com.pspdfkit.flutter.pspdfkit.util.ProcessorHelper
import com.pspdfkit.flutter.pspdfkit.util.ProcessorHelper.annotationTypeFromString
import com.pspdfkit.flutter.pspdfkit.util.ProcessorHelper.processModeFromString
import com.pspdfkit.flutter.pspdfkit.util.addFileSchemeIfMissing
import com.pspdfkit.flutter.pspdfkit.util.areValidIndexes
import com.pspdfkit.flutter.pspdfkit.util.isImageDocument
Expand All @@ -38,13 +42,11 @@ import io.flutter.plugin.common.StandardMessageCodec
import io.flutter.plugin.platform.PlatformView
import io.flutter.plugin.platform.PlatformViewFactory
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers
import io.reactivex.rxjava3.subscribers.DisposableSubscriber
import org.json.JSONObject
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.FileOutputStream


internal class PSPDFKitView(
val context: Context,
Expand All @@ -67,7 +69,6 @@ internal class PSPDFKitView(
val password = configurationAdapter.password
val pdfConfiguration = configurationAdapter.build()
val toolbarGroupingItems: List<Any>? = configurationMap?.get("toolbarItemGrouping") as List<Any>?

val measurementValueConfigurations =
configurationMap?.get("measurementValueConfigurations") as List<Map<String, Any>>?

Expand Down Expand Up @@ -144,7 +145,7 @@ internal class PSPDFKitView(
if (!pdfUiFragment.isAdded) {
return
}
val document = pdfUiFragment.document ?: return
var document = pdfUiFragment.document ?: return

when (call.method) {
"applyInstantJson" -> {
Expand Down Expand Up @@ -481,6 +482,113 @@ internal class PSPDFKitView(
result.error("DocumentException", e.message, null)
}
}
"zoomToRect" -> {
try {
val pageIndex:Int = requireNotNull(call.argument("pageIndex"))
val rect: Map<String,Double> = requireNotNull(call.argument("rect"))
var duration:Long = 0
if(call.hasArgument("duration")){
duration = requireNotNull(call.argument("duration"))
}
val x = requireNotNull(rect["left"])
val y = requireNotNull(rect["top"])
val width = requireNotNull(rect["width"])
val height = requireNotNull(rect["height"])
val zooRect = RectF(x.toFloat(),y.toFloat(),(x+width).toFloat(),(y+height).toFloat())
pdfUiFragment.pdfFragment?.zoomTo(zooRect,pageIndex, duration)
result.success(true)
} catch (e: Exception) {
result.error("DocumentException", e.message, null)
}
}
"getVisibleRect" -> {
val pageIndex = requireNotNull(call.argument("pageIndex")) as Int
if (pageIndex < 0 || pageIndex >= document.pageCount) {
result.error("InvalidArgument", "pageIndex is required", null)
} else {
val visiblePdfRect = RectF()
pdfUiFragment.pdfFragment?.getVisiblePdfRect(visiblePdfRect, pageIndex)
result.success(
mapOf(
"left" to visiblePdfRect.left,
"top" to visiblePdfRect.top,
"height" to visiblePdfRect.height(),
"width" to visiblePdfRect.width()
)
)
}
}
"getZoomScale" -> {
val pageIndex = requireNotNull(call.argument("pageIndex")) as Int
if (pageIndex < 0 || pageIndex >= document.pageCount) {
result.error("InvalidArgument", "pageIndex is out of bounds", null)
} else {
val zoomScale = pdfUiFragment.pdfFragment?.getZoomScale(pageIndex)
result.success(zoomScale)
}
}
"processAnnotations" -> {
val outputFilePath:String? = call.argument<String>("destinationPath")
val annotationTypeString:String? = call.argument<String>("type")
val processingModeString:String? = call.argument<String>("processingMode")

// Check if the output path is valid.
if (outputFilePath.isNullOrEmpty()) {
result.error("InvalidArgument", "Output path must be a valid string", null)
return
}

// Check if the annotation type is valid.
if (annotationTypeString.isNullOrEmpty()) {
result.error("InvalidArgument", "Annotation type must be a valid string", null)
return
}

// Check if the processing mode is valid.
if (processingModeString.isNullOrEmpty()) {
result.error("InvalidArgument", "Processing mode must be a valid string", null)
return
}

// Get the annotation type and processing mode.
val annotationType = annotationTypeFromString(
annotationTypeString
)
val processingMode = processModeFromString(processingModeString)
val outputPath = File(outputFilePath)

if (outputPath.parentFile?.exists() == true || outputPath.parentFile?.mkdirs() == true) {
Log.d(LOG_TAG, "Output path is valid: $outputPath")
} else {
result.error("InvalidArgument", "Output path ${outputPath.absolutePath} is invalid", null)
return
}

// Check if we need to process all annotations or only annotations of a specific type.
val task = if (annotationType == AnnotationType.NONE) {
PdfProcessorTask.fromDocument(document).changeAllAnnotations(processingMode)
} else {
PdfProcessorTask.fromDocument(document)
.changeAnnotationsOfType(annotationType, processingMode)
}

PdfProcessor.processDocumentAsync(task, outputPath)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(object : DisposableSubscriber<ProcessorProgress?>() {
override fun onComplete() {
result.success(true)
}

override fun onNext(t: ProcessorProgress?) {
// No-op
}

override fun onError(t: Throwable) {
result.error("AnnotationException", t.message, null)
}
})
}
else -> result.notImplemented()
}
}
Expand Down Expand Up @@ -512,7 +620,6 @@ class PSPDFKitViewFactory(
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {
override fun create(context: Context?, viewId: Int, args: Any?): PlatformView {
val creationParams = args as Map<String?, Any?>?

return PSPDFKitView(
context!!,
viewId,
Expand Down
Loading

0 comments on commit cf2375b

Please sign in to comment.