Showing
2 changed files
with
26 additions
and
2 deletions
@@ -23,6 +23,21 @@ import 'object.dart'; | @@ -23,6 +23,21 @@ import 'object.dart'; | ||
23 | import 'object_stream.dart'; | 23 | import 'object_stream.dart'; |
24 | import 'page_format.dart'; | 24 | import 'page_format.dart'; |
25 | 25 | ||
26 | +/// Page rotation | ||
27 | +enum PdfPageRotation { | ||
28 | + /// No rotation | ||
29 | + none, | ||
30 | + | ||
31 | + /// Rotated 90 degree clockwise | ||
32 | + rotate90, | ||
33 | + | ||
34 | + /// Rotated 180 degree clockwise | ||
35 | + rotate180, | ||
36 | + | ||
37 | + /// Rotated 270 degree clockwise | ||
38 | + rotate270, | ||
39 | +} | ||
40 | + | ||
26 | /// Page object, which will hold any contents for this page. | 41 | /// Page object, which will hold any contents for this page. |
27 | class PdfPage extends PdfObject with PdfGraphicStream { | 42 | class PdfPage extends PdfObject with PdfGraphicStream { |
28 | /// This constructs a Page object, which will hold any contents for this | 43 | /// This constructs a Page object, which will hold any contents for this |
@@ -30,6 +45,7 @@ class PdfPage extends PdfObject with PdfGraphicStream { | @@ -30,6 +45,7 @@ class PdfPage extends PdfObject with PdfGraphicStream { | ||
30 | PdfPage( | 45 | PdfPage( |
31 | PdfDocument pdfDocument, { | 46 | PdfDocument pdfDocument, { |
32 | this.pageFormat = PdfPageFormat.standard, | 47 | this.pageFormat = PdfPageFormat.standard, |
48 | + this.rotate = PdfPageRotation.none, | ||
33 | int? index, | 49 | int? index, |
34 | }) : super(pdfDocument, type: '/Page') { | 50 | }) : super(pdfDocument, type: '/Page') { |
35 | if (index != null) { | 51 | if (index != null) { |
@@ -42,11 +58,14 @@ class PdfPage extends PdfObject with PdfGraphicStream { | @@ -42,11 +58,14 @@ class PdfPage extends PdfObject with PdfGraphicStream { | ||
42 | /// This is this page format, ie the size of the page, margins, and rotation | 58 | /// This is this page format, ie the size of the page, margins, and rotation |
43 | PdfPageFormat pageFormat; | 59 | PdfPageFormat pageFormat; |
44 | 60 | ||
61 | + /// The page rotation angle | ||
62 | + PdfPageRotation rotate; | ||
63 | + | ||
45 | /// This holds the contents of the page. | 64 | /// This holds the contents of the page. |
46 | - List<PdfObjectStream> contents = <PdfObjectStream>[]; | 65 | + final contents = <PdfObjectStream>[]; |
47 | 66 | ||
48 | /// This holds any Annotations contained within this page. | 67 | /// This holds any Annotations contained within this page. |
49 | - List<PdfAnnot> annotations = <PdfAnnot>[]; | 68 | + final annotations = <PdfAnnot>[]; |
50 | 69 | ||
51 | /// This returns a [PdfGraphics] object, which can then be used to render | 70 | /// This returns a [PdfGraphics] object, which can then be used to render |
52 | /// on to this page. If a previous [PdfGraphics] object was used, this object | 71 | /// on to this page. If a previous [PdfGraphics] object was used, this object |
@@ -71,6 +90,10 @@ class PdfPage extends PdfObject with PdfGraphicStream { | @@ -71,6 +90,10 @@ class PdfPage extends PdfObject with PdfGraphicStream { | ||
71 | // the /Parent pages object | 90 | // the /Parent pages object |
72 | params['/Parent'] = pdfDocument.pdfPageList.ref(); | 91 | params['/Parent'] = pdfDocument.pdfPageList.ref(); |
73 | 92 | ||
93 | + if (rotate != PdfPageRotation.none) { | ||
94 | + params['/Rotate'] = PdfNum(rotate.index * 90); | ||
95 | + } | ||
96 | + | ||
74 | // the /MediaBox for the page size | 97 | // the /MediaBox for the page size |
75 | params['/MediaBox'] = | 98 | params['/MediaBox'] = |
76 | PdfArray.fromNum(<double>[0, 0, pageFormat.width, pageFormat.height]); | 99 | PdfArray.fromNum(<double>[0, 0, pageFormat.width, pageFormat.height]); |
-
Please register or login to post a comment