Skip to content

Commit 29f2c40

Browse files
committed
Some code cleanup
1 parent 835806c commit 29f2c40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3419
-3714
lines changed

samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs

Lines changed: 173 additions & 174 deletions
Large diffs are not rendered by default.

src/Synercoding.FileFormats.Pdf/DocumentInformation.cs

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,65 @@
22
using System;
33
using System.Collections.Generic;
44

5-
namespace Synercoding.FileFormats.Pdf
5+
namespace Synercoding.FileFormats.Pdf;
6+
7+
/// <summary>
8+
/// This class contains information about the document
9+
/// </summary>
10+
public class DocumentInformation
611
{
7-
/// <summary>
8-
/// This class contains information about the document
9-
/// </summary>
10-
public class DocumentInformation
12+
internal DocumentInformation(PdfReference id)
1113
{
12-
internal DocumentInformation(PdfReference id)
13-
{
14-
Reference = id;
15-
}
14+
Reference = id;
15+
}
1616

17-
/// <summary>
18-
/// The document's title
19-
/// </summary>
20-
public string? Title { get; set; }
17+
/// <summary>
18+
/// The document's title
19+
/// </summary>
20+
public string? Title { get; set; }
2121

22-
/// <summary>
23-
/// The name of the person who created the document
24-
/// </summary>
25-
public string? Author { get; set; }
22+
/// <summary>
23+
/// The name of the person who created the document
24+
/// </summary>
25+
public string? Author { get; set; }
2626

27-
/// <summary>
28-
/// The subject of the document
29-
/// </summary>
30-
public string? Subject { get; set; }
27+
/// <summary>
28+
/// The subject of the document
29+
/// </summary>
30+
public string? Subject { get; set; }
3131

32-
/// <summary>
33-
/// Keywords associated with the document
34-
/// </summary>
35-
public string? Keywords { get; set; }
32+
/// <summary>
33+
/// Keywords associated with the document
34+
/// </summary>
35+
public string? Keywords { get; set; }
3636

37-
/// <summary>
38-
/// If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted. Otherwise the name of the application that created the document.
39-
/// </summary>
40-
public string? Creator { get; set; }
37+
/// <summary>
38+
/// If the document was converted to PDF from another format, the name of the conforming product that created the original document from which it was converted. Otherwise the name of the application that created the document.
39+
/// </summary>
40+
public string? Creator { get; set; }
4141

42-
/// <summary>
43-
/// If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF.
44-
/// </summary>
45-
public string? Producer { get; set; }
42+
/// <summary>
43+
/// If the document was converted to PDF from another format, the name of the conforming product that converted it to PDF.
44+
/// </summary>
45+
public string? Producer { get; set; }
4646

47-
/// <summary>
48-
/// The date and time the document was created, in human-readable form.
49-
/// </summary>
50-
public DateTime? CreationDate { get; set; } = DateTime.Now;
47+
/// <summary>
48+
/// The date and time the document was created, in human-readable form.
49+
/// </summary>
50+
public DateTime? CreationDate { get; set; } = DateTime.Now;
5151

52-
/// <summary>
53-
/// The date and time the document was most recently modified, in human-readable form.
54-
/// </summary>
55-
public DateTime? ModDate { get; set; }
52+
/// <summary>
53+
/// The date and time the document was most recently modified, in human-readable form.
54+
/// </summary>
55+
public DateTime? ModDate { get; set; }
5656

57-
/// <summary>
58-
/// A pdf reference object that can be used to reference to this object
59-
/// </summary>
60-
public PdfReference Reference { get; }
57+
/// <summary>
58+
/// A pdf reference object that can be used to reference to this object
59+
/// </summary>
60+
public PdfReference Reference { get; }
6161

62-
/// <summary>
63-
/// Extra information that will be added to the PDF meta data
64-
/// </summary>
65-
public IDictionary<string, string> ExtraInfo { get; } = new Dictionary<string, string>();
66-
}
62+
/// <summary>
63+
/// Extra information that will be added to the PDF meta data
64+
/// </summary>
65+
public IDictionary<string, string> ExtraInfo { get; } = new Dictionary<string, string>();
6766
}

src/Synercoding.FileFormats.Pdf/Extensions/IContentContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public static TContext WrapInState<TContext>(this TContext context, Action<TCont
99
=> context.WrapInState(contentOperations, static (operations, context) => operations(context));
1010

1111
public static Task<TContext> WrapInStateAsync<TContext>(this TContext context, Func<TContext, Task> contentOperations)
12-
where TContext: IContentContext<TContext>
12+
where TContext : IContentContext<TContext>
1313
=> context.WrapInStateAsync(contentOperations, static (operations, context) => operations(context));
1414
}

src/Synercoding.FileFormats.Pdf/Extensions/IPageContentContextExtensions.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ public static IPageContentContext AddText(this IPageContentContext context, stri
8787
=> context.AddText(text, font, size, ops => { });
8888

8989
public static IPageContentContext AddText(this IPageContentContext context, string text, Font font, double size, Point location)
90-
=> context.AddText(text, font, size, location, static (location, ops) =>
91-
{
92-
ops.MoveToStartNextLine(location.X.AsRaw(Unit.Points), location.Y.AsRaw(Unit.Points));
93-
});
90+
=> context.AddText(text, font, size, location, static (location, ops) => ops.MoveToStartNextLine(location.X.AsRaw(Unit.Points), location.Y.AsRaw(Unit.Points)));
9491

9592
public static IPageContentContext AddText(this IPageContentContext context, string text, Font font, double size, Action<ITextContentContext> extraOperations)
9693
=> context.AddText(text, font, size, extraOperations, static (extraOperations, context) => extraOperations(context));
@@ -113,13 +110,9 @@ public static IPageContentContext AddText<T>(this IPageContentContext context, s
113110
for (int i = 0; i < lines.Length; i++)
114111
{
115112
if (i == 0)
116-
{
117113
context.ShowText(lines[i]);
118-
}
119114
else
120-
{
121115
context.ShowTextOnNextLine(lines[i]);
122-
}
123116
}
124117
});
125118
}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
using Synercoding.Primitives;
22

3-
namespace Synercoding.FileFormats.Pdf.Extensions
3+
namespace Synercoding.FileFormats.Pdf.Extensions;
4+
5+
/// <summary>
6+
/// Extension methods for primitives
7+
/// </summary>
8+
public static class PrimitiveExtensions
49
{
510
/// <summary>
6-
/// Extension methods for primitives
11+
/// Convert a <see cref="Rectangle"/> to a transformation matrix
712
/// </summary>
8-
public static class PrimitiveExtensions
13+
/// <param name="rectangle">The <see cref="Rectangle"/> to use</param>
14+
/// <returns>Returns a <see cref="Matrix"/> representing the provided <see cref="Rectangle"/>.</returns>
15+
public static Matrix AsPlacementMatrix(this Rectangle rectangle)
916
{
10-
/// <summary>
11-
/// Convert a <see cref="Rectangle"/> to a transformation matrix
12-
/// </summary>
13-
/// <param name="rectangle">The <see cref="Rectangle"/> to use</param>
14-
/// <returns>Returns a <see cref="Matrix"/> representing the provided <see cref="Rectangle"/>.</returns>
15-
public static Matrix AsPlacementMatrix(this Rectangle rectangle)
16-
{
17-
rectangle = rectangle.ConvertTo(Unit.Points);
18-
return new Matrix(
19-
rectangle.URX.Raw - rectangle.LLX.Raw, 0,
20-
0, rectangle.URY.Raw - rectangle.LLY.Raw,
21-
rectangle.LLX.Raw, rectangle.LLY.Raw);
22-
}
17+
rectangle = rectangle.ConvertTo(Unit.Points);
18+
return new Matrix(
19+
rectangle.URX.Raw - rectangle.LLX.Raw, 0,
20+
0, rectangle.URY.Raw - rectangle.LLY.Raw,
21+
rectangle.LLX.Raw, rectangle.LLY.Raw);
2322
}
2423
}

src/Synercoding.FileFormats.Pdf/IPath.cs

Lines changed: 0 additions & 133 deletions
This file was deleted.

src/Synercoding.FileFormats.Pdf/IShapeContext.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Synercoding.FileFormats.Pdf.LowLevel;
2-
using Synercoding.Primitives;
32

43
namespace Synercoding.FileFormats.Pdf;
54

@@ -11,7 +10,7 @@ public interface IShapeContext : IContentContext<IShapeContext>
1110
/// </summary>
1211
/// <param name="x">The X coordinate of the move</param>
1312
/// <param name="y">The Y coordinate of the move</param>
14-
/// <returns>The calling <see cref="IPath"/> to support chaining operations.</returns>
13+
/// <returns>The calling <see cref="IShapeContext"/> to support chaining operations.</returns>
1514
IShapeContext Move(double x, double y);
1615

1716

0 commit comments

Comments
 (0)