David PHAM-VAN

Fix podspec for Swift

  1 +# 1.3.4
  2 +* Fix iOS build with Swift
  3 +* Add installation instructions in the Readme
  4 +
1 # 1.3.3 5 # 1.3.3
2 * Fix dart lint warnings 6 * Fix dart lint warnings
3 * Add documentation 7 * Add documentation
@@ -34,3 +34,29 @@ PdfTtfFont ttf = PdfTtfFont(pdf, font); @@ -34,3 +34,29 @@ PdfTtfFont ttf = PdfTtfFont(pdf, font);
34 g.setColor(PdfColor(0.3, 0.3, 0.3)); 34 g.setColor(PdfColor(0.3, 0.3, 0.3));
35 g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0); 35 g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0);
36 ``` 36 ```
  37 +
  38 +## Installing
  39 +
  40 +1. Add this to your package's `pubspec.yaml` file:
  41 +
  42 + ```yaml
  43 + dependencies:
  44 + printing: any # <-- Add this line
  45 + ```
  46 +
  47 +2. Enable Swift on the iOS project, in `ios/Podfile`:
  48 +
  49 + ```Ruby
  50 + target 'Runner' do
  51 + use_frameworks! # <-- Add this line
  52 + ```
  53 +
  54 +3. Set minimum Android version in `android/app/build.gradle`:
  55 +
  56 + ```java
  57 + defaultConfig {
  58 + ...
  59 + minSdkVersion 19 // <-- Change this line to 19 or more
  60 + ...
  61 + }
  62 + ```
1 # Pdf Printing Example 1 # Pdf Printing Example
2 2
3 ```dart 3 ```dart
4 -void printPdf() {  
5 - Printing.layoutPdf(onLayout: (PdfPageFormat format) {  
6 - final pdf = Document()  
7 - ..addPage(Page(  
8 - pageFormat: PdfPageFormat.a4,  
9 - build: (Context context) {  
10 - return Center(  
11 - child: Text("Hello World"),  
12 - ); // Center 4 +import 'dart:async';
  5 +import 'package:flutter/material.dart';
  6 +
  7 +import 'package:pdf/pdf.dart';
  8 +import 'package:pdf/widgets.dart' as Pdf;
  9 +import 'package:printing/printing.dart';
  10 +
  11 +void main() => runApp(MyApp());
  12 +
  13 +class MyApp extends StatelessWidget {
  14 + @override
  15 + Widget build(BuildContext context) {
  16 + return MaterialApp(
  17 + home: Scaffold(
  18 + appBar: AppBar(
  19 + title: Text('Printing Demo'),
  20 + ),
  21 + body: Center(
  22 + child: FlatButton(
  23 + child: Text("Print Document"),
  24 + onPressed: () {
  25 + Printing.layoutPdf(onLayout: buildPdf);
  26 + },
  27 + ),
  28 + ),
  29 + ),
  30 + );
  31 + }
  32 +
  33 + List<int> buildPdf(PdfPageFormat format) {
  34 + final PdfDoc pdf = PdfDoc()
  35 + ..addPage(Pdf.Page(
  36 + pageFormat: format,
  37 + build: (Pdf.Context context) {
  38 + return Pdf.ConstrainedBox(
  39 + constraints: const Pdf.BoxConstraints.expand(),
  40 + child: Pdf.FittedBox(
  41 + child: Pdf.Text(
  42 + "Hello World",
  43 + )),
  44 + );
13 })); 45 }));
14 - return pdf.save();  
15 - }); // Page 46 + return pdf.document.save();
  47 + }
16 } 48 }
17 ``` 49 ```
@@ -17,5 +17,5 @@ Plugin that allows Flutter apps to generate and print documents to android or io @@ -17,5 +17,5 @@ Plugin that allows Flutter apps to generate and print documents to android or io
17 s.dependency 'Flutter' 17 s.dependency 'Flutter'
18 18
19 s.ios.deployment_target = '8.0' 19 s.ios.deployment_target = '8.0'
  20 + s.swift_version = '4.2'
20 end 21 end
21 -  
@@ -2,7 +2,7 @@ name: printing @@ -2,7 +2,7 @@ name: printing
2 author: David PHAM-VAN <dev.nfet.net@gmail.com> 2 author: David PHAM-VAN <dev.nfet.net@gmail.com>
3 description: Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers 3 description: Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers
4 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 4 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
5 -version: 1.3.3 5 +version: 1.3.4
6 6
7 environment: 7 environment:
8 sdk: ">=1.19.0 <3.0.0" 8 sdk: ">=1.19.0 <3.0.0"