|
@@ -1,116 +0,0 @@
|
|
-/*
|
|
|
|
- * Copyright © 2014-2025 PDF Technologies, Inc. All Rights Reserved.
|
|
|
|
- *
|
|
|
|
- * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
|
- * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
|
- * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
|
- * This notice may not be removed from this file.
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-import 'dart:io';
|
|
|
|
-
|
|
|
|
-import 'package:compdfkit_flutter/compdfkit.dart';
|
|
|
|
-import 'package:compdfkit_flutter/configuration/cpdf_configuration.dart';
|
|
|
|
-import 'package:compdfkit_flutter/widgets/cpdf_reader_widget.dart';
|
|
|
|
-import 'package:compdfkit_flutter/widgets/cpdf_reader_widget_controller.dart';
|
|
|
|
-import 'package:compdfkit_flutter_example/cpdf_reader_widget_example.dart';
|
|
|
|
-import 'package:compdfkit_flutter_example/examples.dart';
|
|
|
|
-import 'package:flutter/material.dart';
|
|
|
|
-
|
|
|
|
-class CPDFSaveAsExample extends StatefulWidget {
|
|
|
|
- final String document;
|
|
|
|
-
|
|
|
|
- const CPDFSaveAsExample({super.key, required this.document});
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- State<CPDFSaveAsExample> createState() => _CPDFSaveAsExampleState();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-class _CPDFSaveAsExampleState extends State<CPDFSaveAsExample> {
|
|
|
|
- late CPDFReaderWidgetController controller;
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- void initState() {
|
|
|
|
- super.initState();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void initPDFPath() async {}
|
|
|
|
- @override
|
|
|
|
- Widget build(BuildContext context) {
|
|
|
|
- return Scaffold(
|
|
|
|
- appBar: AppBar(
|
|
|
|
- title: const Text('Save As issues'),
|
|
|
|
- actions: [
|
|
|
|
- IconButton(
|
|
|
|
- onPressed: () async {
|
|
|
|
- // await controller.document.save();
|
|
|
|
-
|
|
|
|
- final tempDir = await ComPDFKit.getTemporaryDirectory();
|
|
|
|
- String savePath = '${tempDir.path}/test_2.pdf';
|
|
|
|
- bool saveResult = await controller.document.saveAs(savePath);
|
|
|
|
- if (saveResult) {
|
|
|
|
- var jump = await _showSaveResultDialog(savePath);
|
|
|
|
- if (jump != null && context.mounted) {
|
|
|
|
- goTo(CPDFReaderWidgetExample(documentPath: jump), context);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- icon: const Icon(Icons.download)),
|
|
|
|
- IconButton(
|
|
|
|
- onPressed: () async {
|
|
|
|
-
|
|
|
|
- final tempDir = await ComPDFKit.getTemporaryDirectory();
|
|
|
|
- String savePath = '${tempDir.path}/test_2.pdf';
|
|
|
|
- final file = File(savePath);
|
|
|
|
- if(await file.exists()){
|
|
|
|
- await file.delete();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // File xfdfFile = await extractAsset(context, 'pdfs/test.xfdf');
|
|
|
|
- //
|
|
|
|
- // // android Uri:
|
|
|
|
- // //String xfdfFile = "content://xxx";
|
|
|
|
- //
|
|
|
|
- // bool result = await controller.document
|
|
|
|
- // .importAnnotations(xfdfFile.path);
|
|
|
|
- // debugPrint('ComPDFKit:Document: importAnnotations:$result');
|
|
|
|
- },
|
|
|
|
- icon: const Icon(Icons.settings_ethernet_rounded)),
|
|
|
|
-
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- body: CPDFReaderWidget(
|
|
|
|
- document: widget.document,
|
|
|
|
- configuration: CPDFConfiguration(),
|
|
|
|
- onCreated: (controller) {
|
|
|
|
- setState(() {
|
|
|
|
- this.controller = controller;
|
|
|
|
- });
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Future<String?> _showSaveResultDialog(String path) async {
|
|
|
|
- return await showDialog(
|
|
|
|
- context: context,
|
|
|
|
- builder: (context) {
|
|
|
|
- return AlertDialog(
|
|
|
|
- title: const Text('Save Result'),
|
|
|
|
- content: Text('Save Path:$path'),
|
|
|
|
- actions: [
|
|
|
|
- TextButton(
|
|
|
|
- onPressed: () {
|
|
|
|
- Navigator.pop(context, null);
|
|
|
|
- },
|
|
|
|
- child: const Text('Cancel')),
|
|
|
|
- TextButton(
|
|
|
|
- onPressed: () {
|
|
|
|
- Navigator.pop(context, path);
|
|
|
|
- },
|
|
|
|
- child: const Text('Jump'))
|
|
|
|
- ],
|
|
|
|
- );
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-}
|
|
|