David PHAM-VAN

Default compress output if available

... ... @@ -4,6 +4,7 @@
* Add encryption support
* Increase PDF version to 1.7
* Add document signature support
* Default compress output if available
## 1.3.13
... ...
... ... @@ -4,7 +4,7 @@ import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
void main() {
final Document pdf = Document(deflate: zlib.encode);
final Document pdf = Document();
pdf.addPage(MultiPage(
pageFormat:
... ...
... ... @@ -26,6 +26,8 @@ import 'package:meta/meta.dart';
import 'package:utf/utf.dart';
import 'package:vector_math/vector_math_64.dart';
import 'src/io.dart' if (dart.library.io) 'src/archive.dart';
part 'src/annotation.dart';
part 'src/array.dart';
part 'src/ascii85.dart';
... ...
import 'package:archive/archive.dart';
import 'package:pdf/pdf.dart';
DeflateCallback defaultDeflate = ZLibEncoder().encode;
... ...
... ... @@ -46,7 +46,11 @@ class PdfDocument {
/// This creates a Pdf document
/// @param pagemode an int, determines how the document will present itself to
/// the viewer when it first opens.
PdfDocument({PdfPageMode pageMode = PdfPageMode.none, this.deflate}) {
PdfDocument({
PdfPageMode pageMode = PdfPageMode.none,
DeflateCallback deflate,
bool compress = true,
}) : deflate = compress ? (deflate ?? defaultDeflate) : null {
_objser = 1;
// Now create some standard objects
... ...
import 'dart:io';
import 'package:pdf/pdf.dart';
DeflateCallback defaultDeflate = zlib.encode;
... ...
... ... @@ -20,6 +20,7 @@ class Document {
Document(
{PdfPageMode pageMode = PdfPageMode.none,
DeflateCallback deflate,
bool compress = true,
this.theme,
String title,
String author,
... ... @@ -27,7 +28,11 @@ class Document {
String subject,
String keywords,
String producer})
: document = PdfDocument(pageMode: pageMode, deflate: deflate) {
: document = PdfDocument(
pageMode: pageMode,
deflate: deflate,
compress: compress,
) {
if (title != null ||
author != null ||
creator != null ||
... ...
... ... @@ -14,6 +14,7 @@ dependencies:
vector_math: "^2.0.0"
utf: "^0.9.0"
crypto: "^2.0.6"
archive: "^2.0.10"
dev_dependencies:
test: any
... ...
... ... @@ -14,7 +14,7 @@ for documentation.
Example:
```dart
final pdf = PdfDoc();
final pdf = Document();
pdf.addPage(Page(
pageFormat: PdfPageFormat.a4,
... ...
... ... @@ -34,7 +34,7 @@ class MyApp extends StatelessWidget {
}
List<int> buildPdf(PdfPageFormat format) {
final PdfDoc doc = PdfDoc();
final Document doc = Document();
doc.addPage(
pdf.Page(
... ...
... ... @@ -107,7 +107,7 @@ class Category extends StatelessWidget {
}
Future<Document> generateDocument(PdfPageFormat format) async {
final PdfDoc pdf = PdfDoc(title: 'My Résumé', author: 'David PHAM-VAN');
final Document pdf = Document(title: 'My Résumé', author: 'David PHAM-VAN');
final PdfImage profileImage = await pdfImageFromImageProvider(
pdf: pdf.document,
... ...
... ... @@ -74,7 +74,7 @@ class MyAppState extends State<MyApp> {
print('Print Screen ${im.width}x${im.height} ...');
Printing.layoutPdf(onLayout: (PdfPageFormat format) {
final pdf.Document document = PdfDoc();
final pdf.Document document = pdf.Document();
final PdfImage image = PdfImage(document.document,
image: bytes.buffer.asUint8List(),
... ...
... ... @@ -17,7 +17,6 @@
library printing;
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;
... ...
... ... @@ -16,6 +16,7 @@
part of printing;
@deprecated
class PdfDoc extends Document {
/// Wrapper for a [Document] with zlib compression enabled by default
PdfDoc(
... ... @@ -29,7 +30,7 @@ class PdfDoc extends Document {
String keywords,
String producer})
: super(
deflate: compress ? zlib.encode : null,
compress: compress,
pageMode: pageMode,
theme: theme,
title: title,
... ...