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-06-24 07:06:13 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
774b03b999875226f10e8f01d7deb5b031b8ba8c
774b03b9
1 parent
293aa807
Add encryption support
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
0 deletions
pdf/CHANGELOG.md
pdf/lib/pdf.dart
pdf/lib/src/document.dart
pdf/lib/src/encryption.dart
pdf/lib/src/object_stream.dart
pdf/lib/src/output.dart
pdf/CHANGELOG.md
View file @
774b03b
## 1.3.14
*
Add Document ID
*
Add encryption support
## 1.3.13
...
...
pdf/lib/pdf.dart
View file @
774b03b
...
...
@@ -35,6 +35,7 @@ part 'src/color.dart';
part
'src/colors.dart'
;
part
'src/compatibility.dart'
;
part
'src/document.dart'
;
part
'src/encryption.dart'
;
part
'src/font_descriptor.dart'
;
part
'src/font_metrics.dart'
;
part
'src/font.dart'
;
...
...
pdf/lib/src/document.dart
View file @
774b03b
...
...
@@ -86,6 +86,9 @@ class PdfDocument {
/// No compression by default
final
DeflateCallback
deflate
;
/// Object used to encrypt the document
PdfEncryption
encryption
;
/// These map the page modes just defined to the pagemodes setting of Pdf.
static
const
List
<
String
>
_PdfPageModes
=
<
String
>[
'/UseNone'
,
...
...
pdf/lib/src/encryption.dart
0 → 100644
View file @
774b03b
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
part of
pdf
;
abstract
class
PdfEncryption
extends
PdfObject
{
PdfEncryption
(
PdfDocument
pdfDocument
)
:
super
(
pdfDocument
,
null
);
List
<
int
>
encrypt
(
List
<
int
>
input
,
PdfObject
object
);
}
...
...
pdf/lib/src/object_stream.dart
View file @
774b03b
...
...
@@ -54,6 +54,9 @@ class PdfObjectStream extends PdfObject {
// This is a non-deflated stream
_data
=
buf
.
output
();
}
if
(
pdfDocument
.
encryption
!=
null
)
{
_data
=
pdfDocument
.
encryption
.
encrypt
(
_data
,
this
);
}
params
[
'/Length'
]
=
PdfStream
.
intNum
(
_data
.
length
);
}
...
...
pdf/lib/src/output.dart
View file @
774b03b
...
...
@@ -37,6 +37,9 @@ class PdfOutput {
/// This is used to track the /Info object (info)
PdfObject
infoID
;
/// This is used to track the /Encrypt object (encryption)
PdfEncryption
encryptID
;
/// This method writes a [PdfObject] to the stream.
///
/// @param ob [PdfObject] Object to write
...
...
@@ -49,6 +52,9 @@ class PdfOutput {
if
(
ob
is
PdfInfo
)
{
infoID
=
ob
;
}
if
(
ob
is
PdfEncryption
)
{
encryptID
=
ob
;
}
offsets
.
add
(
PdfXref
(
ob
.
objser
,
os
.
offset
));
ob
.
_write
(
os
);
...
...
@@ -117,6 +123,11 @@ class PdfOutput {
params
[
'/Info'
]
=
infoID
.
ref
();
}
// the /Encrypt reference (OPTIONAL)
if
(
encryptID
!=
null
)
{
params
[
'/Encrypt'
]
=
encryptID
.
ref
();
}
// end the trailer object
os
.
putDictionary
(
params
);
os
.
putString
(
'
\n
startxref
\n
$xref
\n
%%EOF
\n
'
);
...
...
Please
register
or
login
to post a comment