Skip to content

Commit 0549d73

Browse files
committed
#3 Adding XML docs to public methods.
1 parent f292aae commit 0549d73

File tree

5 files changed

+268
-36
lines changed

5 files changed

+268
-36
lines changed

src/Kevsoft.PDFtk/IDataField.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,53 @@
11
namespace Kevsoft.PDFtk
22
{
3+
/// <summary>
4+
/// Statistics of a single data field within the PDF.
5+
/// </summary>
36
public interface IDataField
47
{
8+
/// <summary>
9+
/// The field value.
10+
/// </summary>
511
string? FieldValue { get; }
12+
13+
/// <summary>
14+
/// The default field value.
15+
/// </summary>
616
string? FieldValueDefault { get; }
17+
18+
/// <summary>
19+
/// The field type.
20+
/// </summary>
721
string? FieldType { get; }
22+
23+
/// <summary>
24+
/// The field name.
25+
/// </summary>
826
string? FieldName { get; }
27+
28+
/// <summary>
29+
/// The field alternative description.
30+
/// </summary>
931
string? FieldNameAlt { get; }
32+
33+
/// <summary>
34+
/// The field flags.
35+
/// </summary>
1036
string? FieldFlags { get; }
37+
38+
/// <summary>
39+
/// The field justification.
40+
/// </summary>
1141
string? FieldJustification { get; }
42+
43+
/// <summary>
44+
/// The field possible values.
45+
/// </summary>
1246
string[] FieldStateOption { get; }
47+
48+
/// <summary>
49+
/// The field maximum length.
50+
/// </summary>
1351
string? FieldMaxLength { get; }
1452
}
1553
}

src/Kevsoft.PDFtk/IPDFtk.cs

Lines changed: 160 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,184 @@
44

55
namespace Kevsoft.PDFtk
66
{
7+
/// <summary>
8+
/// The main <c>IPDFtk</c> interface.
9+
/// Contains all methods for performing the PDFtk functions.
10+
/// </summary>
711
public interface IPDFtk
812
{
9-
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(byte[] pdfFileBytes);
10-
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(Stream pdfFileStream);
13+
/// <summary>
14+
/// Return the number of pages for a given PDF.
15+
/// </summary>
16+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
17+
/// <returns>A result with the number of pages.</returns>
18+
/// See <see cref="GetNumberOfPagesAsync(Stream)"/> to use a PDF input as a stream or <see cref="GetNumberOfPagesAsync(string)"/> to use a PDF file path.
19+
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(byte[] pdfFile);
20+
21+
/// <summary>
22+
/// Return the number of pages for a given PDF.
23+
/// </summary>
24+
/// <param name="pdfFile">A stream containing the PDF file input.</param>
25+
/// <returns>A result with the number of pages.</returns>
26+
/// See <see cref="GetNumberOfPagesAsync(byte[])"/> to use a PDF input as a byte array or <see cref="GetNumberOfPagesAsync(string)"/> to use a PDF file path.
27+
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(Stream pdfFile);
28+
29+
/// <summary>
30+
/// Return the number of pages for a given PDF.
31+
/// </summary>
32+
/// <param name="filePath">The PDF file path.</param>
33+
/// <returns>A result with the number of pages.</returns>
34+
/// See <see cref="GetNumberOfPagesAsync(byte[])"/> to use a PDF input as a byte array.
1135
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(string filePath);
12-
Task<IPDFtkResult<byte[]>> GetPagesAsync(byte[] pdfFileBytes, params int[] pages);
13-
Task<IPDFtkResult<byte[]>> GetPagesAsync(Stream pdfFileBytes, params int[] pages);
14-
Task<IPDFtkResult<byte[]>> GetPagesAsync(string inputFile, params int[] pages);
15-
Task<IPDFtkResult<IDataField[]>> GetDataFieldsAsync(byte[] pdfFileBytes);
36+
37+
/// <summary>
38+
/// Concatenate a list of pages into one single file and returns the output PDF as a byte array.
39+
/// </summary>
40+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
41+
/// <param name="pages">The pages to concatenate.</param>
42+
/// <returns>A result with the PDF as a byte array with the concatenated pages.</returns>
43+
Task<IPDFtkResult<byte[]>> GetPagesAsync(byte[] pdfFile, params int[] pages);
44+
45+
/// <summary>
46+
/// Concatenate a list of pages into one single file and returns the output PDF as a byte array.
47+
/// </summary>
48+
/// <param name="pdfFile">A stream of the PDF file input.</param>
49+
/// <param name="pages">The pages to concatenate.</param>
50+
/// <returns>A result with the PDF as a byte array with the concatenated pages.</returns>
51+
Task<IPDFtkResult<byte[]>> GetPagesAsync(Stream pdfFile, params int[] pages);
52+
53+
/// <summary>
54+
/// Concatenate a list of pages into one single file and returns the output PDF as a byte array.
55+
/// </summary>
56+
/// <param name="filePath">The PDF file path.</param>
57+
/// <param name="pages">The pages to concatenate.</param>
58+
/// <returns>A result with the PDF as a byte array with the concatenated pages.</returns>
59+
Task<IPDFtkResult<byte[]>> GetPagesAsync(string filePath, params int[] pages);
60+
61+
/// <summary>
62+
/// Reads the PDF and returns the form field statistics.
63+
/// </summary>
64+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
65+
/// <returns>A result with the form field statistics</returns>
66+
Task<IPDFtkResult<IDataField[]>> GetDataFieldsAsync(byte[] pdfFile);
67+
68+
/// <summary>
69+
/// Reads the PDF and returns the form field statistics.
70+
/// </summary>
71+
/// <param name="pdfFile">A stream of the PDF file input.</param>
72+
/// <returns>A result with the form field statistics</returns>
1673
Task<IPDFtkResult<IDataField[]>> GetDataFieldsAsync(Stream pdfFile);
74+
75+
/// <summary>
76+
/// Reads the PDF and returns the form field statistics.
77+
/// </summary>
78+
/// <param name="filePath">The PDF file path.</param>
79+
/// <returns>A result with the form field statistics</returns>
1780
Task<IPDFtkResult<IDataField[]>> GetDataFieldsAsync(string filePath);
81+
82+
/// <summary>
83+
/// Merges multiple PDFs into one single PDF and returns the output PDF as a byte array.
84+
/// </summary>
85+
/// <param name="pdfFiles">An enumeration of bytes of the PDF files to merge.</param>
86+
/// <returns>A result with the PDF as a byte array of the merged PDFs.</returns>
1887
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<byte[]> pdfFiles);
19-
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<Stream> pdfStreams);
88+
89+
/// <summary>
90+
/// Merges multiple PDFs into one single PDF and returns the output PDF as a byte array.
91+
/// </summary>
92+
/// <param name="pdfFiles">An enumeration of streams of the PDF files to merge.</param>
93+
/// <returns>A result with the PDF as a byte array of the merged PDFs.</returns>
94+
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<Stream> pdfFiles);
95+
96+
/// <summary>
97+
/// Merges multiple PDFs into one single PDF and returns the output PDF as a byte array.
98+
/// </summary>
99+
/// <param name="filePaths">An enumeration of the PDF file paths to merge.</param>
100+
/// <returns>A result with the PDF as a byte array of the merged PDFs.</returns>
20101
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<string> filePaths);
102+
103+
/// <summary>
104+
/// Splits a single PDF in many pages and return an enumeration of bytes representing each page a s single PDF.
105+
/// </summary>
106+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
107+
/// <returns>A result with an enumeration of byte arrays.</returns>
21108
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(byte[] pdfFile);
22-
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(Stream stream);
109+
110+
/// <summary>
111+
/// Splits a single PDF in many pages and return an enumeration of bytes representing each page a s single PDF.
112+
/// </summary>
113+
/// <param name="pdfFile">A stream of the PDF file input.</param>
114+
/// <returns>A result with an enumeration of byte arrays.</returns>
115+
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(Stream pdfFile);
116+
117+
/// <summary>
118+
/// Splits a single PDF in many pages and return an enumeration of bytes representing each page a s single PDF.
119+
/// </summary>
120+
/// <param name="filePath">The PDF file path.</param>
121+
/// <returns>A result with an enumeration of byte arrays.</returns>
23122
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(string filePath);
123+
124+
/// <summary>
125+
/// Applies a stamp to a PDF file.
126+
/// </summary>
127+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
128+
/// <param name="stampPdfFile">A byte array of the PDF stamp to apply.</param>
129+
/// <returns>A result with the stamped PDF file.</returns>
24130
Task<IPDFtkResult<byte[]>> StampAsync(byte[] pdfFile, byte[] stampPdfFile);
25-
Task<IPDFtkResult<byte[]>> StampAsync(Stream pdfFileStream, Stream stampPdfFileStream);
131+
132+
/// <summary>
133+
/// Applies a stamp to a PDF file.
134+
/// </summary>
135+
/// <param name="pdfFile">A stream of the PDF file input.</param>
136+
/// <param name="stampPdfFile">A stream of the PDF stamp to apply.</param>
137+
/// <returns>A result with the stamped PDF file.</returns>
138+
Task<IPDFtkResult<byte[]>> StampAsync(Stream pdfFile, Stream stampPdfFile);
139+
140+
/// <summary>
141+
/// Applies a stamp to a PDF file.
142+
/// </summary>
143+
/// <param name="pdfFilePath">A PDF file path.</param>
144+
/// <param name="stampPdfFilePath">A PDF stamp file path.</param>
145+
/// <returns>A result with the stamped PDF file.</returns>
26146
Task<IPDFtkResult<byte[]>> StampAsync(string pdfFilePath, string stampPdfFilePath);
27147

148+
/// <summary>
149+
/// Fill a PDF form with given data and returns the output PDF as a byte array.
150+
/// </summary>
151+
/// <param name="pdfFile">A byte array of the PDF file input.</param>
152+
/// <param name="fieldData">A key value pair of form field name to value.</param>
153+
/// <param name="flatten">If the final PDF should be flattened.</param>
154+
/// <param name="dropXfa">If the XFA data should be omitted from final PDF.</param>
155+
/// <returns>A result with the PDF form filled as a byte array.</returns>
28156
Task<IPDFtkResult<byte[]>> FillFormAsync(byte[] pdfFile,
29157
IReadOnlyDictionary<string, string> fieldData,
30-
bool flatten,
31-
bool dropXfa);
158+
bool flatten = true,
159+
bool dropXfa = false);
32160

33-
Task<IPDFtkResult<byte[]>> FillFormAsync(Stream stream,
161+
/// <summary>
162+
/// Fill a PDF form with given data and returns the output PDF as a byte array.
163+
/// </summary>
164+
/// <param name="pdfFile">A stream of the PDF file input.</param>
165+
/// <param name="fieldData">A key value pair of form field name to value.</param>
166+
/// <param name="flatten">If the final PDF should be flattened.</param>
167+
/// <param name="dropXfa">If the XFA data should be omitted from final PDF.</param>
168+
/// <returns>A result with the PDF form filled as a byte array.</returns>
169+
Task<IPDFtkResult<byte[]>> FillFormAsync(Stream pdfFile,
34170
IReadOnlyDictionary<string, string> fieldData,
35-
bool flatten,
36-
bool dropXfa);
171+
bool flatten = true,
172+
bool dropXfa = false);
37173

174+
/// <summary>
175+
/// Fill a PDF form with given data and returns the output PDF as a byte array.
176+
/// </summary>
177+
/// <param name="pdfFilePath">A PDF file path.</param>
178+
/// <param name="fieldData">A key value pair of form field name to value.</param>
179+
/// <param name="flatten">If the final PDF should be flattened.</param>
180+
/// <param name="dropXfa">If the XFA data should be omitted from final PDF.</param>
181+
/// <returns>A result with the PDF form filled as a byte array.</returns>
38182
Task<IPDFtkResult<byte[]>> FillFormAsync(string pdfFilePath,
39183
IReadOnlyDictionary<string, string> fieldData,
40-
bool flatten,
41-
bool dropXfa);
184+
bool flatten = true,
185+
bool dropXfa = false);
42186
}
43187
}

src/Kevsoft.PDFtk/IPDFtkResult.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
namespace Kevsoft.PDFtk
22
{
3+
/// <summary>
4+
/// The result of a PDFtk execution.
5+
/// </summary>
6+
/// <typeparam name="TResult">The enclosed result type.</typeparam>
37
public interface IPDFtkResult<out TResult>
48
{
9+
/// <summary>
10+
/// The standard output captured when PDFtk was executed.
11+
/// </summary>
512
string StandardOutput { get; }
13+
/// <summary>
14+
/// The standard error captured when PDFtk was executed.
15+
/// </summary>
616
string StandardError { get; }
17+
/// <summary>
18+
/// The result of the execution.
19+
/// </summary>
720
TResult Result { get; }
21+
/// <summary>
22+
/// The exit code of the execution of PDFtk.
23+
/// </summary>
824
int ExitCode { get; }
25+
/// <summary>
26+
/// Success flag of the execution of PDFtk.
27+
/// </summary>
928
bool Success { get; }
1029
}
1130
}

src/Kevsoft.PDFtk/Kevsoft.PDFtk.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<PropertyGroup>
88
<IncludeSymbols>true</IncludeSymbols>
99
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
10+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1011
</PropertyGroup>
11-
12+
1213
<PropertyGroup>
1314
<Title>Kevsoft.PDFtk</Title>
1415
<AssemblyName>Kevsoft.PDFtk</AssemblyName>
@@ -24,6 +25,10 @@
2425
<Copyright>Copyright © Kevsoft 2021</Copyright>
2526
</PropertyGroup>
2627

28+
<PropertyGroup>
29+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
30+
</PropertyGroup>
31+
2732
<PropertyGroup>
2833
<PackageTags>PDFtk;pdf</PackageTags>
2934
<PackageLicenseExpression>MIT</PackageLicenseExpression>

0 commit comments

Comments
 (0)