David PHAM-VAN

Run dartfmt on sources

  1 +* Add example
@@ -64,4 +64,3 @@ part 'src/stream.dart'; @@ -64,4 +64,3 @@ part 'src/stream.dart';
64 part 'src/ttffont.dart'; 64 part 'src/ttffont.dart';
65 part 'src/xobject.dart'; 65 part 'src/xobject.dart';
66 part 'src/xref.dart'; 66 part 'src/xref.dart';
67 -  
@@ -59,7 +59,18 @@ class PDFAnnot extends PDFObject { @@ -59,7 +59,18 @@ class PDFAnnot extends PDFObject {
59 PDFBorder border; 59 PDFBorder border;
60 60
61 PDFAnnot(PDFPage pdfPage, 61 PDFAnnot(PDFPage pdfPage,
62 - {String type, this.s, this.l, this.b, this.r, this.t, this.subtype, this.dest, this.fl, this.fb, this.fr, this.ft}) 62 + {String type,
  63 + this.s,
  64 + this.l,
  65 + this.b,
  66 + this.r,
  67 + this.t,
  68 + this.subtype,
  69 + this.dest,
  70 + this.fl,
  71 + this.fb,
  72 + this.fr,
  73 + this.ft})
63 : super(pdfPage.pdfDocument, type) { 74 : super(pdfPage.pdfDocument, type) {
64 pdfPage.annotations.add(this); 75 pdfPage.annotations.add(this);
65 } 76 }
@@ -70,7 +81,8 @@ class PDFAnnot extends PDFObject { @@ -70,7 +81,8 @@ class PDFAnnot extends PDFObject {
70 /// @param b Bottom coordinate 81 /// @param b Bottom coordinate
71 /// @param r Right coordinate 82 /// @param r Right coordinate
72 /// @param t Top coordinate 83 /// @param t Top coordinate
73 - factory PDFAnnot.annotation(PDFPage pdfPage, String s, double l, double b, double r, double t) => 84 + factory PDFAnnot.annotation(
  85 + PDFPage pdfPage, String s, double l, double b, double r, double t) =>
74 new PDFAnnot(pdfPage, type: "/Annot", s: s, l: l, b: b, r: r, t: t); 86 new PDFAnnot(pdfPage, type: "/Annot", s: s, l: l, b: b, r: r, t: t);
75 87
76 /// Creates a text annotation 88 /// Creates a text annotation
@@ -94,9 +106,14 @@ class PDFAnnot extends PDFObject { @@ -94,9 +106,14 @@ class PDFAnnot extends PDFObject {
94 /// @param ft Top coordinate 106 /// @param ft Top coordinate
95 /// <br><br>Rectangle describing what part of the page to be displayed 107 /// <br><br>Rectangle describing what part of the page to be displayed
96 /// (must be in User Coordinates) 108 /// (must be in User Coordinates)
97 - factory PDFAnnot.link(PDFPage pdfPage, double l, double b, double r, double t, PDFObject dest,  
98 - [double fl = FULL_PAGE, double fb = FULL_PAGE, double fr = FULL_PAGE, double ft = FULL_PAGE]) =>  
99 - new PDFAnnot(pdfPage, type: "/Link", l: l, b: b, r: r, t: t, dest: dest, fl: fl, fb: fb, fr: fr, ft: ft); 109 + factory PDFAnnot.link(
  110 + PDFPage pdfPage, double l, double b, double r, double t, PDFObject dest,
  111 + [double fl = FULL_PAGE,
  112 + double fb = FULL_PAGE,
  113 + double fr = FULL_PAGE,
  114 + double ft = FULL_PAGE]) =>
  115 + new PDFAnnot(pdfPage,
  116 + type: "/Link", l: l, b: b, r: r, t: t, dest: dest, fl: fl, fb: fb, fr: fr, ft: ft);
100 117
101 /// Sets the border for the annotation. By default, no border is defined. 118 /// Sets the border for the annotation. By default, no border is defined.
102 /// 119 ///
@@ -36,7 +36,8 @@ class PDFBorder extends PDFObject { @@ -36,7 +36,8 @@ class PDFBorder extends PDFObject {
36 /// @param style The style of the border 36 /// @param style The style of the border
37 /// @param dash The line pattern definition 37 /// @param dash The line pattern definition
38 /// @see PDFAnnot 38 /// @see PDFAnnot
39 - PDFBorder(PDFDocument pdfDocument, this.width, {this.style = 0, this.dash}) : super(pdfDocument); 39 + PDFBorder(PDFDocument pdfDocument, this.width, {this.style = 0, this.dash})
  40 + : super(pdfDocument);
40 41
41 /// @param os OutputStream to send the object to 42 /// @param os OutputStream to send the object to
42 @override 43 @override
@@ -34,7 +34,8 @@ class PDFCatalog extends PDFObject { @@ -34,7 +34,8 @@ class PDFCatalog extends PDFObject {
34 /// of the documents page tree 34 /// of the documents page tree
35 /// @param pagemode How the document should appear when opened. 35 /// @param pagemode How the document should appear when opened.
36 /// Allowed values are USENONE, USEOUTLINES, USETHUMBS or FULLSCREEN. 36 /// Allowed values are USENONE, USEOUTLINES, USETHUMBS or FULLSCREEN.
37 - PDFCatalog(PDFDocument pdfDocument, this.pdfPageList, this.pageMode) : super(pdfDocument, "/Catalog"); 37 + PDFCatalog(PDFDocument pdfDocument, this.pdfPageList, this.pageMode)
  38 + : super(pdfDocument, "/Catalog");
38 39
39 /// @param os OutputStream to send the object to 40 /// @param os OutputStream to send the object to
40 @override 41 @override
@@ -29,8 +29,8 @@ class PDFColor { @@ -29,8 +29,8 @@ class PDFColor {
29 PDFColor(this.r, this.g, this.b, [this.a = 1.0]); 29 PDFColor(this.r, this.g, this.b, [this.a = 1.0]);
30 30
31 factory PDFColor.fromInt(int color) { 31 factory PDFColor.fromInt(int color) {
32 - return new PDFColor(  
33 - (color >> 16 & 0xff) / 255.0, (color >> 8 & 0xff) / 255.0, (color & 0xff) / 255.0, (color >> 24 & 0xff) / 255.0); 32 + return new PDFColor((color >> 16 & 0xff) / 255.0, (color >> 8 & 0xff) / 255.0,
  33 + (color & 0xff) / 255.0, (color >> 24 & 0xff) / 255.0);
34 } 34 }
35 35
36 factory PDFColor.fromHex(String color) { 36 factory PDFColor.fromHex(String color) {
@@ -72,7 +72,12 @@ class PDFDocument { @@ -72,7 +72,12 @@ class PDFDocument {
72 /// <p> 72 /// <p>
73 /// These map the page modes just defined to the pagemodes setting of PDF. 73 /// These map the page modes just defined to the pagemodes setting of PDF.
74 /// </p> 74 /// </p>
75 - static const _PDF_PAGE_MODES = const ["/UseNone", "/UseOutlines", "/UseThumbs", "/FullScreen"]; 75 + static const _PDF_PAGE_MODES = const [
  76 + "/UseNone",
  77 + "/UseOutlines",
  78 + "/UseThumbs",
  79 + "/FullScreen"
  80 + ];
76 81
77 /// This holds the current fonts 82 /// This holds the current fonts
78 final Set<PDFFont> fonts = new Set<PDFFont>(); 83 final Set<PDFFont> fonts = new Set<PDFFont>();
@@ -32,7 +32,8 @@ class PDFFont extends PDFObject { @@ -32,7 +32,8 @@ class PDFFont extends PDFObject {
32 /// @param type The pdf type, ie /Type1 32 /// @param type The pdf type, ie /Type1
33 /// @param font The font name, ie Helvetica 33 /// @param font The font name, ie Helvetica
34 /// @param style The java.awt.Font style, ie: Font.PLAIN 34 /// @param style The java.awt.Font style, ie: Font.PLAIN
35 - PDFFont(PDFDocument pdfDocument, {this.subtype = "/Type1", this.baseFont = "/Helvetica"}) : super(pdfDocument, "/Font") { 35 + PDFFont(PDFDocument pdfDocument, {this.subtype = "/Type1", this.baseFont = "/Helvetica"})
  36 + : super(pdfDocument, "/Font") {
36 pdfDocument.fonts.add(this); 37 pdfDocument.fonts.add(this);
37 } 38 }
38 39
@@ -23,7 +23,8 @@ class PDFFontDescriptor extends PDFObject { @@ -23,7 +23,8 @@ class PDFFontDescriptor extends PDFObject {
23 final TtfFont font; 23 final TtfFont font;
24 final PDFTTFFont ttfFont; 24 final PDFTTFFont ttfFont;
25 25
26 - PDFFontDescriptor(this.ttfFont, this.file, this.font) : super(ttfFont.pdfDocument, "/FontDescriptor"); 26 + PDFFontDescriptor(this.ttfFont, this.file, this.font)
  27 + : super(ttfFont.pdfDocument, "/FontDescriptor");
27 28
28 @override 29 @override
29 void prepare() { 30 void prepare() {
@@ -32,7 +33,8 @@ class PDFFontDescriptor extends PDFObject { @@ -32,7 +33,8 @@ class PDFFontDescriptor extends PDFObject {
32 params["/FontName"] = PDFStream.string(ttfFont.baseFont); 33 params["/FontName"] = PDFStream.string(ttfFont.baseFont);
33 params["/FontFile2"] = file.ref(); 34 params["/FontFile2"] = file.ref();
34 params["/Flags"] = PDFStream.intNum(32); 35 params["/Flags"] = PDFStream.intNum(32);
35 - params["/FontBBox"] = new PDFStream()..putStringArray([font.head.xMin, font.head.yMin, font.head.xMax, font.head.yMax]); 36 + params["/FontBBox"] = new PDFStream()
  37 + ..putStringArray([font.head.xMin, font.head.yMin, font.head.xMax, font.head.yMax]);
36 params["/Ascent"] = PDFStream.intNum(font.hhea.ascent); 38 params["/Ascent"] = PDFStream.intNum(font.hhea.ascent);
37 params["/Descent"] = PDFStream.intNum(font.hhea.descent); 39 params["/Descent"] = PDFStream.intNum(font.hhea.descent);
38 params["/ItalicAngle"] = PDFStream.intNum(0); 40 params["/ItalicAngle"] = PDFStream.intNum(0);
@@ -33,7 +33,8 @@ class PDFFormXObject extends PDFXObject { @@ -33,7 +33,8 @@ class PDFFormXObject extends PDFXObject {
33 /// set matrix 33 /// set matrix
34 void setMatrix(Matrix4 t) { 34 void setMatrix(Matrix4 t) {
35 var s = t.storage; 35 var s = t.storage;
36 - params["/Matrix"] = PDFStream.string("[${s[0]} ${s[1]} ${s[4]} ${s[5]} ${s[12]} ${s[13]}]"); 36 + params["/Matrix"] =
  37 + PDFStream.string("[${s[0]} ${s[1]} ${s[4]} ${s[5]} ${s[12]} ${s[13]}]");
37 } 38 }
38 39
39 @override 40 @override
@@ -174,8 +174,7 @@ class PDFGraphics { @@ -174,8 +174,7 @@ class PDFGraphics {
174 /// 174 ///
175 /// @param c Color to use 175 /// @param c Color to use
176 void setColor(PDFColor color) { 176 void setColor(PDFColor color) {
177 - buf.putString("${color.r} ${color.g} ${color.b} rg ${color.r} ${color.g} ${color  
178 - .b} RG\n"); 177 + buf.putString("${color.r} ${color.g} ${color.b} rg ${color.r} ${color.g} ${color.b} RG\n");
179 } 178 }
180 179
181 /// Set the transformation Matrix 180 /// Set the transformation Matrix
@@ -26,7 +26,8 @@ class PDFInfo extends PDFObject { @@ -26,7 +26,8 @@ class PDFInfo extends PDFObject {
26 String keywords; 26 String keywords;
27 27
28 /// @param title Title of this document 28 /// @param title Title of this document
29 - PDFInfo(PDFDocument pdfDocument, {this.title, this.author, this.creator, this.subject, this.keywords}) 29 + PDFInfo(PDFDocument pdfDocument,
  30 + {this.title, this.author, this.creator, this.subject, this.keywords})
30 : super(pdfDocument, null) { 31 : super(pdfDocument, null) {
31 params["/Producer"] = PDFStream.text("dpdf - David PHAM-VAN"); 32 params["/Producer"] = PDFStream.text("dpdf - David PHAM-VAN");
32 } 33 }
@@ -76,7 +76,8 @@ class PDFOutline extends PDFObject { @@ -76,7 +76,8 @@ class PDFOutline extends PDFObject {
76 PDFOutline add({String title, PDFPage dest, double x, y, w, h}) { 76 PDFOutline add({String title, PDFPage dest, double x, y, w, h}) {
77 var xy1 = dest.cxy(x, y + h); 77 var xy1 = dest.cxy(x, y + h);
78 var xy2 = dest.cxy(x + w, y); 78 var xy2 = dest.cxy(x + w, y);
79 - PDFOutline outline = new PDFOutline(pdfDocument, title: title, dest: dest, l: xy1.w, b: xy1.h, r: xy2.w, t: xy2.h); 79 + PDFOutline outline = new PDFOutline(pdfDocument,
  80 + title: title, dest: dest, l: xy1.w, b: xy1.h, r: xy2.w, t: xy2.h);
80 // Tell the outline of ourselves 81 // Tell the outline of ourselves
81 outline.parent = this; 82 outline.parent = this;
82 return outline; 83 return outline;
@@ -48,7 +48,8 @@ class PDFPage extends PDFObject { @@ -48,7 +48,8 @@ class PDFPage extends PDFObject {
48 /// @see PageFormat#LANDSCAPE 48 /// @see PageFormat#LANDSCAPE
49 /// @see PageFormat#REVERSE_LANDSCAPE 49 /// @see PageFormat#REVERSE_LANDSCAPE
50 /// @param pageFormat PageFormat describing the page size 50 /// @param pageFormat PageFormat describing the page size
51 - PDFPage(PDFDocument pdfDocument, {int orientation, this.pageFormat}) : super(pdfDocument, "/Page") { 51 + PDFPage(PDFDocument pdfDocument, {int orientation, this.pageFormat})
  52 + : super(pdfDocument, "/Page") {
52 pdfDocument.pdfPageList.pages.add(this); 53 pdfDocument.pdfPageList.pages.add(this);
53 if (pageFormat == null) pageFormat = new PDFPageFormat(); 54 if (pageFormat == null) pageFormat = new PDFPageFormat();
54 setOrientation(orientation); 55 setOrientation(orientation);
@@ -132,12 +133,16 @@ class PDFPage extends PDFObject { @@ -132,12 +133,16 @@ class PDFPage extends PDFObject {
132 /// @param vh Height of the view area 133 /// @param vh Height of the view area
133 /// @return Returns the annotation, so other settings can be changed. 134 /// @return Returns the annotation, so other settings can be changed.
134 PDFAnnot addLink(double x, y, w, h, PDFObject dest, 135 PDFAnnot addLink(double x, y, w, h, PDFObject dest,
135 - [double vx = PDFAnnot.FULL_PAGE, vy = PDFAnnot.FULL_PAGE, vw = PDFAnnot.FULL_PAGE, vh = PDFAnnot.FULL_PAGE]) { 136 + [double vx = PDFAnnot.FULL_PAGE,
  137 + vy = PDFAnnot.FULL_PAGE,
  138 + vw = PDFAnnot.FULL_PAGE,
  139 + vh = PDFAnnot.FULL_PAGE]) {
136 var xy1 = cxy(x, y + h); 140 var xy1 = cxy(x, y + h);
137 var xy2 = cxy(x + w, y); 141 var xy2 = cxy(x + w, y);
138 var xy3 = cxy(vx, vy + vh); 142 var xy3 = cxy(vx, vy + vh);
139 var xy4 = cxy(vx + vw, vy); 143 var xy4 = cxy(vx + vw, vy);
140 - PDFAnnot ob = new PDFAnnot.link(this, xy1.w, xy1.h, xy2.w, xy2.h, dest, xy3.w, xy3.h, xy4.w, xy4.h); 144 + PDFAnnot ob =
  145 + new PDFAnnot.link(this, xy1.w, xy1.h, xy2.w, xy2.h, dest, xy3.w, xy3.h, xy4.w, xy4.h);
141 return ob; 146 return ob;
142 } 147 }
143 148
@@ -152,7 +157,8 @@ class PDFPage extends PDFObject { @@ -152,7 +157,8 @@ class PDFPage extends PDFObject {
152 PDFOutline addOutline(String title, {double x, double y, double w, double h}) { 157 PDFOutline addOutline(String title, {double x, double y, double w, double h}) {
153 PDFPoint xy1 = cxy(x, y + h); 158 PDFPoint xy1 = cxy(x, y + h);
154 PDFPoint xy2 = cxy(x + w, y); 159 PDFPoint xy2 = cxy(x + w, y);
155 - PDFOutline outline = new PDFOutline(pdfDocument, title: title, dest: this, l: xy1.w, b: xy1.h, r: xy2.w, t: xy2.h); 160 + PDFOutline outline = new PDFOutline(pdfDocument,
  161 + title: title, dest: this, l: xy1.w, b: xy1.h, r: xy2.w, t: xy2.h);
156 pdfDocument.outline.outlines.add(outline); 162 pdfDocument.outline.outlines.add(outline);
157 return outline; 163 return outline;
158 } 164 }
@@ -166,7 +172,8 @@ class PDFPage extends PDFObject { @@ -166,7 +172,8 @@ class PDFPage extends PDFObject {
166 params["/Parent"] = pdfDocument.pdfPageList.ref(); 172 params["/Parent"] = pdfDocument.pdfPageList.ref();
167 173
168 // the /MediaBox for the page size 174 // the /MediaBox for the page size
169 - params["/MediaBox"] = new PDFStream()..putStringArray([0, 0, pageFormat.getWidth(), pageFormat.getHeight()]); 175 + params["/MediaBox"] = new PDFStream()
  176 + ..putStringArray([0, 0, pageFormat.getWidth(), pageFormat.getHeight()]);
170 177
171 // Rotation (if not zero) 178 // Rotation (if not zero)
172 // if(rotate!=0) { 179 // if(rotate!=0) {
@@ -119,7 +119,8 @@ class PDFStream { @@ -119,7 +119,8 @@ class PDFStream {
119 putString(">>"); 119 putString(">>");
120 } 120 }
121 121
122 - static PDFStream dictionary(Map<String, PDFStream> values) => new PDFStream()..putDictionary(values); 122 + static PDFStream dictionary(Map<String, PDFStream> values) =>
  123 + new PDFStream()..putDictionary(values);
123 124
124 void putObjectDictionary(Map<String, PDFObject> values) { 125 void putObjectDictionary(Map<String, PDFObject> values) {
125 putString("<< "); 126 putString("<< ");
@@ -28,7 +28,8 @@ class PDFTTFFont extends PDFFont { @@ -28,7 +28,8 @@ class PDFTTFFont extends PDFFont {
28 int _charMax; 28 int _charMax;
29 29
30 /// Constructs a PDFTTFFont 30 /// Constructs a PDFTTFFont
31 - PDFTTFFont(PDFDocument pdfDocument, Uint8List bytes) : super(pdfDocument, subtype: "/TrueType") { 31 + PDFTTFFont(PDFDocument pdfDocument, Uint8List bytes)
  32 + : super(pdfDocument, subtype: "/TrueType") {
32 _font = new TtfParser().parse(bytes); 33 _font = new TtfParser().parse(bytes);
33 baseFont = "/" + _font.name.fontName.replaceAll(" ", ""); 34 baseFont = "/" + _font.name.fontName.replaceAll(" ", "");
34 35
@@ -36,7 +36,8 @@ class PDFXref { @@ -36,7 +36,8 @@ class PDFXref {
36 36
37 /// @return The xref in the format of the xref section in the PDF file 37 /// @return The xref in the format of the xref section in the PDF file
38 String ref() { 38 String ref() {
39 - String rs = offset.toString().padLeft(10, '0') + " " + generation.toString().padLeft(5, '0'); 39 + String rs =
  40 + offset.toString().padLeft(10, '0') + " " + generation.toString().padLeft(5, '0');
40 41
41 if (generation == 65535) return rs + " f "; 42 if (generation == 65535) return rs + " f ";
42 return rs + " n "; 43 return rs + " n ";