David PHAM-VAN

Fix large PDF generation on web with compressed xref

1 # Changelog 1 # Changelog
2 2
  3 +## 3.8.1
  4 +
  5 +- Fix large PDF generation on web with compressed xref
  6 +
3 ## 3.8.0 7 ## 3.8.0
4 8
5 - Update xml dependency range 9 - Update xml dependency range
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
  17 +import 'dart:math' as math;
17 import 'dart:typed_data'; 18 import 'dart:typed_data';
18 19
19 import 'data_types.dart'; 20 import 'data_types.dart';
@@ -185,11 +186,7 @@ class PdfXrefTable extends PdfDataType { @@ -185,11 +186,7 @@ class PdfXrefTable extends PdfDataType {
185 params['/Index'] = PdfArray.fromNum(blocks); 186 params['/Index'] = PdfArray.fromNum(blocks);
186 } 187 }
187 188
188 - var bytes = 2; // A pdf less than 256 bytes is unlikely  
189 - while (1 << (bytes * 8) < offset) {  
190 - bytes++;  
191 - }  
192 - 189 + final bytes = (math.log(offset) ~/ math.ln2) ~/ 8;
193 final w = [1, bytes, 1]; 190 final w = [1, bytes, 1];
194 params['/W'] = PdfArray.fromNum(w); 191 params['/W'] = PdfArray.fromNum(w);
195 final wl = w.reduce((a, b) => a + b); 192 final wl = w.reduce((a, b) => a + b);
@@ -3,7 +3,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl @@ -3,7 +3,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
3 homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf 3 homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf
4 repository: https://github.com/DavBfr/dart_pdf 4 repository: https://github.com/DavBfr/dart_pdf
5 issue_tracker: https://github.com/DavBfr/dart_pdf/issues 5 issue_tracker: https://github.com/DavBfr/dart_pdf/issues
6 -version: 3.8.0 6 +version: 3.8.1
7 7
8 environment: 8 environment:
9 sdk: ">=2.12.0 <3.0.0" 9 sdk: ">=2.12.0 <3.0.0"