Skip to content

Commit 9819b34

Browse files
committed
Added xml comments to public members
1 parent b6eee41 commit 9819b34

File tree

11 files changed

+232
-3
lines changed

11 files changed

+232
-3
lines changed

src/Synercoding.FileFormats.Pdf/Helpers/Sizes.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
namespace Synercoding.FileFormats.Pdf.Helpers
44
{
5+
/// <summary>
6+
/// Static class that represents standard sizes
7+
/// </summary>
58
public static class Sizes
69
{
10+
/// <summary>
11+
/// Rectangle representing an A4 portrait
12+
/// </summary>
713
public static Rectangle A4Portrait { get; } = new Rectangle(0, 0, _mmToPts(210), _mmToPts(297));
14+
15+
/// <summary>
16+
/// Rectangle representing an A4 landscape
17+
/// </summary>
818
public static Rectangle A4Landscape { get; } = new Rectangle(0, 0, _mmToPts(297), _mmToPts(210));
919

1020
private static double _mmToPts(double mm) => mm / 25.4 * 72;

src/Synercoding.FileFormats.Pdf/PdfPage.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace Synercoding.FileFormats.Pdf
1212
{
13+
/// <summary>
14+
/// A class that represents a pdf page
15+
/// </summary>
1316
public class PdfPage
1417
{
1518
private int _pageCounter = 0;
@@ -30,51 +33,99 @@ internal PdfPage(TableBuilder tableBuilder)
3033

3134
internal ContentStream ContentStream { get; }
3235

36+
/// <summary>
37+
/// The media box of the <see cref="PdfPage"/>
38+
/// </summary>
3339
public Rectangle MediaBox { get; set; } = Sizes.A4Portrait;
3440

41+
/// <summary>
42+
/// The cropbox of the <see cref="PdfPage"/>, defaults to <see cref="MediaBox"/>
43+
/// </summary>
3544
public Rectangle CropBox
3645
{
3746
get => _cropBox.Equals(Rectangle.Zero) ? MediaBox : _cropBox;
3847
set => _cropBox = value;
3948
}
4049

50+
/// <summary>
51+
/// The bleedbox of the <see cref="PdfPage"/>, defaults to <see cref="CropBox"/>
52+
/// </summary>
4153
public Rectangle BleedBox
4254
{
4355
get => _bleedBox.Equals(Rectangle.Zero) ? CropBox : _bleedBox;
4456
set => _bleedBox = value;
4557
}
4658

59+
/// <summary>
60+
/// The trimbox of the <see cref="PdfPage"/>, defaults to <see cref="CropBox"/>
61+
/// </summary>
4762
public Rectangle TrimBox
4863
{
4964
get => _trimBox.Equals(Rectangle.Zero) ? CropBox : _trimBox;
5065
set => _trimBox = value;
5166
}
5267

68+
/// <summary>
69+
/// Add image to the <see cref="PdfPage"/>
70+
/// </summary>
71+
/// <param name="image">The image to be added</param>
72+
/// <param name="rectangle">The <see cref="Rectangle"/> that represents the placement on the page</param>
73+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
5374
public PdfPage AddImage(ImageSharp.Image<Rgba32> image, Rectangle rectangle)
5475
{
5576
return _addImage(image, rectangle, true);
5677
}
5778

79+
/// <summary>
80+
/// Add image to the <see cref="PdfPage"/>
81+
/// </summary>
82+
/// <param name="image">The image to be added</param>
83+
/// <param name="rectangle">The <see cref="Rectangle"/> that represents the placement on the page</param>
84+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
5885
public PdfPage AddImage(byte[] image, Rectangle rectangle)
5986
{
6087
return _addImage(ImageSharp.Image.Load(image), rectangle, false);
6188
}
6289

90+
/// <summary>
91+
/// Add image to the <see cref="PdfPage"/>
92+
/// </summary>
93+
/// <param name="image">The image to be added</param>
94+
/// <param name="rectangle">The <see cref="Rectangle"/> that represents the placement on the page</param>
95+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
6396
public PdfPage AddImage(Stream image, Rectangle rectangle)
6497
{
6598
return _addImage(ImageSharp.Image.Load(image), rectangle, false);
6699
}
67100

101+
/// <summary>
102+
/// Add image to the <see cref="PdfPage"/>
103+
/// </summary>
104+
/// <param name="image">The image to be added</param>
105+
/// <param name="matrix">The <see cref="Matrix"/> that represents the placement on the page</param>
106+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
68107
public PdfPage AddImage(ImageSharp.Image<Rgba32> image, Matrix matrix)
69108
{
70109
return _addImage(image, matrix, true);
71110
}
72111

112+
/// <summary>
113+
/// Add image to the <see cref="PdfPage"/>
114+
/// </summary>
115+
/// <param name="image">The image to be added</param>
116+
/// <param name="matrix">The <see cref="Matrix"/> that represents the placement on the page</param>
117+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
73118
public PdfPage AddImage(byte[] image, Matrix matrix)
74119
{
75120
return _addImage(ImageSharp.Image.Load(image), matrix, false);
76121
}
77122

123+
/// <summary>
124+
/// Add image to the <see cref="PdfPage"/>
125+
/// </summary>
126+
/// <param name="image">The image to be added</param>
127+
/// <param name="matrix">The <see cref="Matrix"/> that represents the placement on the page</param>
128+
/// <returns>This <see cref="PdfPage"/> so calls can be chained.</returns>
78129
public PdfPage AddImage(Stream image, Matrix matrix)
79130
{
80131
return _addImage(ImageSharp.Image.Load(image), matrix, false);

src/Synercoding.FileFormats.Pdf/PdfWriter.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Synercoding.FileFormats.Pdf
99
{
10+
/// <summary>
11+
/// Main class for writing PDF files to streams
12+
/// </summary>
1013
public class PdfWriter : IDisposable
1114
{
1215
private readonly Stream _stream;
@@ -17,6 +20,10 @@ public class PdfWriter : IDisposable
1720

1821
private readonly ICollection<IPdfObject> _pageReferences = new List<IPdfObject>();
1922

23+
/// <summary>
24+
/// Constructor for <see cref="PdfWriter"/>
25+
/// </summary>
26+
/// <param name="stream">The <see cref="Stream"/> to write the PDF file</param>
2027
public PdfWriter(Stream stream)
2128
{
2229
_stream = stream;
@@ -26,6 +33,11 @@ public PdfWriter(Stream stream)
2633
_catalog = _tableBuilder.ReserveId();
2734
}
2835

36+
/// <summary>
37+
/// Add a page to the pdf file
38+
/// </summary>
39+
/// <param name="pageAction">Action used to setup the page</param>
40+
/// <returns>Returns this <see cref="PdfWriter"/> to chain calls</returns>
2941
public PdfWriter AddPage(Action<PdfPage> pageAction)
3042
{
3143
var page = new PdfPage(_tableBuilder);
@@ -41,6 +53,9 @@ public PdfWriter AddPage(Action<PdfPage> pageAction)
4153
return this;
4254
}
4355

56+
/// <summary>
57+
/// Close the PDF document by writing the pagetree, catalog, xref table and trailer to the <see cref="Stream"/>
58+
/// </summary>
4459
public void Dispose()
4560
{
4661
_writePageTree();

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/MatrixExtensions.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
1-
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
1+
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
22
{
3+
/// <summary>
4+
/// Extension class for <see cref="Matrix"/>
5+
/// </summary>
36
public static class MatrixExtensions
47
{
8+
/// <summary>
9+
/// Apply a rotation operation on the <paramref name="matrix"/>
10+
/// </summary>
11+
/// <param name="matrix">The matrix to apply the operation on</param>
12+
/// <param name="degrees">The amount of degrees to rotate</param>
13+
/// <returns>The new <see cref="Matrix"/></returns>
514
public static Matrix Rotate(this Matrix matrix, double degrees)
615
{
716
return matrix.Multiply(new RotateMatrix(degrees));
817
}
918

19+
/// <summary>
20+
/// Apply a scale operation on the <paramref name="matrix"/>
21+
/// </summary>
22+
/// <param name="matrix">The matrix to apply the operation on</param>
23+
/// <param name="x">The X amount to scale</param>
24+
/// <param name="y">The Y amount to scale</param>
25+
/// <returns>The new <see cref="Matrix"/></returns>
1026
public static Matrix Scale(this Matrix matrix, double x, double y)
1127
{
1228
return matrix.Multiply(new ScaleMatrix(x, y));
1329
}
1430

31+
/// <summary>
32+
/// Apply a skew operation on the <paramref name="matrix"/>
33+
/// </summary>
34+
/// <param name="matrix">The matrix to apply the operation on</param>
35+
/// <param name="a">The amount of degrees to skew (top left direction)</param>
36+
/// <param name="b">The amount of degrees to skew (bottom right direction)</param>
37+
/// <returns>The new <see cref="Matrix"/></returns>
1538
public static Matrix Skew(this Matrix matrix, double a, double b)
1639
{
1740
return matrix.Multiply(new SkewMatrix(a, b));
1841
}
1942

43+
/// <summary>
44+
/// Apply a translation operation on the <paramref name="matrix"/>
45+
/// </summary>
46+
/// <param name="matrix">The matrix to apply the operation on</param>
47+
/// <param name="x">The X distance to translate</param>
48+
/// <param name="y">The Y distance to translate</param>
49+
/// <returns>The new <see cref="Matrix"/></returns>
2050
public static Matrix Translate(this Matrix matrix, double x, double y)
2151
{
2252
return matrix.Multiply(new TranslationMatrix(x, y));

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/Maxtrix.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
22
{
3+
/// <summary>
4+
/// Class that represents a <see cref="Matrix"/>
5+
/// </summary>
36
/// <remarks>
47
/// Matrix is structured as follows:
8+
/// <code>
59
/// a b 0
610
/// c d 0
711
/// e f 1
12+
/// </code>
813
/// </remarks>
914
public class Matrix
1015
{
@@ -15,6 +20,15 @@ private Matrix(double[,] matrix)
1520
_matrix = matrix;
1621
}
1722

23+
/// <summary>
24+
/// Constructor for the <see cref="Matrix"/>
25+
/// </summary>
26+
/// <param name="a">The <see cref="A"/> value</param>
27+
/// <param name="b">The <see cref="B"/> value</param>
28+
/// <param name="c">The <see cref="C"/> value</param>
29+
/// <param name="d">The <see cref="D"/> value</param>
30+
/// <param name="e">The <see cref="E"/> value</param>
31+
/// <param name="f">The <see cref="F"/> value</param>
1832
public Matrix(double a, double b, double c, double d, double e, double f)
1933
{
2034
_matrix[0, 0] = a;
@@ -28,13 +42,41 @@ public Matrix(double a, double b, double c, double d, double e, double f)
2842
_matrix[2, 2] = 1;
2943
}
3044

45+
/// <summary>
46+
/// The A value
47+
/// </summary>
3148
public double A => _matrix[0, 0];
49+
50+
/// <summary>
51+
/// The B value
52+
/// </summary>
3253
public double B => _matrix[0, 1];
54+
55+
/// <summary>
56+
/// The C value
57+
/// </summary>
3358
public double C => _matrix[1, 0];
59+
60+
/// <summary>
61+
/// The D value
62+
/// </summary>
3463
public double D => _matrix[1, 1];
64+
65+
/// <summary>
66+
/// The E value
67+
/// </summary>
3568
public double E => _matrix[2, 0];
69+
70+
/// <summary>
71+
/// The F value
72+
/// </summary>
3673
public double F => _matrix[2, 1];
3774

75+
/// <summary>
76+
/// Multiply this matrix with <paramref name="other"/>
77+
/// </summary>
78+
/// <param name="other">The other matrix to multiply by</param>
79+
/// <returns>The new <see cref="Matrix"/></returns>
3880
public Matrix Multiply(Matrix other)
3981
{
4082
var a = _matrix;

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/RotateMatrix.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33

44
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
55
{
6+
/// <summary>
7+
/// Matrix for a rotation operation
8+
/// </summary>
69
public class RotateMatrix : Matrix
710
{
11+
/// <summary>
12+
/// Constructor for <see cref="RotateMatrix"/>
13+
/// </summary>
14+
/// <param name="degree">The amount of degrees to rotate by</param>
815
public RotateMatrix(double degree)
916
: base(Math.Cos(MathHelper.DegreeToRad(degree)), Math.Sin(MathHelper.DegreeToRad(degree)), Math.Sin(MathHelper.DegreeToRad(degree)) * -1, Math.Cos(MathHelper.DegreeToRad(degree)), 0, 0)
1017
{ }

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/ScaleMatrix.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
22
{
3+
/// <summary>
4+
/// Matrix for a scale operation
5+
/// </summary>
36
public class ScaleMatrix : Matrix
47
{
8+
/// <summary>
9+
/// Constructor for <see cref="ScaleMatrix"/>
10+
/// </summary>
11+
/// <param name="x">The amount of X translation</param>
12+
/// <param name="y">The amount of Y translation</param>
513
public ScaleMatrix(double x, double y)
614
: base(x, 0, 0, y, 0, 0)
715
{ }

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/SkewMatrix.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
55
{
6+
/// <summary>
7+
/// Matrix for a skew operation
8+
/// </summary>
69
public class SkewMatrix : Matrix
710
{
11+
/// <summary>
12+
/// Constructor for <see cref="SkewMatrix"/>
13+
/// </summary>
14+
/// <param name="a">The amount of degree to skew the top left direction</param>
15+
/// <param name="b">The amount of degree to skew the bottom right direction</param>
816
public SkewMatrix(double a, double b)
917
: base(1, Math.Tan(MathHelper.DegreeToRad(a)), Math.Tan(MathHelper.DegreeToRad(b)), 1, 0, 0)
1018
{ }

src/Synercoding.FileFormats.Pdf/Primitives/Matrices/TranslationMatrix.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
namespace Synercoding.FileFormats.Pdf.Primitives.Matrices
22
{
3+
/// <summary>
4+
/// Matrix for a translation operation
5+
/// </summary>
36
public class TranslationMatrix : Matrix
47
{
8+
/// <summary>
9+
/// Constructor for <see cref="TranslationMatrix"/>
10+
/// </summary>
11+
/// <param name="x">The X coordinate</param>
12+
/// <param name="y">The Y coordinate</param>
513
public TranslationMatrix(double x, double y)
614
: base(1, 0, 0, 1, x, y)
715
{ }

0 commit comments

Comments
 (0)