Skip to content

Commit 0b70cd0

Browse files
authored
Merge pull request #7 from kevbite/feature/refactor
Refactored methods in to extensions off IPDFtk
2 parents b422cc2 + aaa481b commit 0b70cd0

File tree

5 files changed

+295
-301
lines changed

5 files changed

+295
-301
lines changed

Kevsoft.PDFtk.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kevsoft/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/Kevsoft.PDFtk/IPDFtk.cs

Lines changed: 4 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,14 @@ namespace Kevsoft.PDFtk
1010
/// </summary>
1111
public interface IPDFtk
1212
{
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-
2913
/// <summary>
3014
/// Return the number of pages for a given PDF.
3115
/// </summary>
3216
/// <param name="filePath">The PDF file path.</param>
3317
/// <returns>A result with the number of pages.</returns>
34-
/// See <see cref="GetNumberOfPagesAsync(byte[])"/> to use a PDF input as a byte array.
18+
/// See <see cref="PDFtkByteArrayExtensions.GetNumberOfPagesAsync(IPDFtk, byte[])"/> to use a PDF input as a byte array.
3519
Task<IPDFtkResult<int?>> GetNumberOfPagesAsync(string filePath);
3620

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-
5321
/// <summary>
5422
/// Concatenate a list of pages into one single file and returns the output PDF as a byte array.
5523
/// </summary>
@@ -58,119 +26,35 @@ public interface IPDFtk
5826
/// <returns>A result with the PDF as a byte array with the concatenated pages.</returns>
5927
Task<IPDFtkResult<byte[]>> GetPagesAsync(string filePath, params int[] pages);
6028

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>
73-
Task<IPDFtkResult<IDataField[]>> GetDataFieldsAsync(Stream pdfFile);
74-
7529
/// <summary>
7630
/// Reads the PDF and returns the form field statistics.
7731
/// </summary>
7832
/// <param name="filePath">The PDF file path.</param>
7933
/// <returns>A result with the form field statistics</returns>
8034
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>
87-
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<byte[]> pdfFiles);
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-
35+
9636
/// <summary>
9737
/// Merges multiple PDFs into one single PDF and returns the output PDF as a byte array.
9838
/// </summary>
9939
/// <param name="filePaths">An enumeration of the PDF file paths to merge.</param>
10040
/// <returns>A result with the PDF as a byte array of the merged PDFs.</returns>
10141
Task<IPDFtkResult<byte[]>> ConcatAsync(IEnumerable<string> filePaths);
10242

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>
108-
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(byte[] pdfFile);
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-
11743
/// <summary>
11844
/// Splits a single PDF in many pages and return an enumeration of bytes representing each page a s single PDF.
11945
/// </summary>
12046
/// <param name="filePath">The PDF file path.</param>
12147
/// <returns>A result with an enumeration of byte arrays.</returns>
12248
Task<IPDFtkResult<IEnumerable<byte[]>>> SplitAsync(string filePath);
12349

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>
130-
Task<IPDFtkResult<byte[]>> StampAsync(byte[] pdfFile, byte[] stampPdfFile);
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-
14050
/// <summary>
14151
/// Applies a stamp to a PDF file.
14252
/// </summary>
14353
/// <param name="pdfFilePath">A PDF file path.</param>
14454
/// <param name="stampPdfFilePath">A PDF stamp file path.</param>
14555
/// <returns>A result with the stamped PDF file.</returns>
14656
Task<IPDFtkResult<byte[]>> StampAsync(string pdfFilePath, string stampPdfFilePath);
147-
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>
156-
Task<IPDFtkResult<byte[]>> FillFormAsync(byte[] pdfFile,
157-
IReadOnlyDictionary<string, string> fieldData,
158-
bool flatten = true,
159-
bool dropXfa = false);
160-
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,
170-
IReadOnlyDictionary<string, string> fieldData,
171-
bool flatten = true,
172-
bool dropXfa = false);
173-
57+
17458
/// <summary>
17559
/// Fill a PDF form with given data and returns the output PDF as a byte array.
17660
/// </summary>
@@ -183,26 +67,7 @@ Task<IPDFtkResult<byte[]>> FillFormAsync(string pdfFilePath,
18367
IReadOnlyDictionary<string, string> fieldData,
18468
bool flatten = true,
18569
bool dropXfa = false);
186-
187-
188-
/// <summary>
189-
/// Replaces a page in a PDF with another PDF
190-
/// </summary>
191-
/// <param name="fileBytes">A byte array of the PDF file input.</param>
192-
/// <param name="page">The page to replace</param>
193-
/// <param name="replacementFileBytes">A byte array of the PDF file to replace the page with.</param>
194-
/// <returns>A result with the PDF form filled as a byte array.</returns>
195-
Task<IPDFtkResult<byte[]>> ReplacePage(byte[] fileBytes, int page, byte[] replacementFileBytes);
196-
197-
/// <summary>
198-
/// Replaces a page in a PDF with another PDF
199-
/// </summary>
200-
/// <param name="pdfFile">A stream of the PDF file input.</param>
201-
/// <param name="page">The page to replace</param>
202-
/// <param name="replacementPdfFile">A stream of the PDF file to replace the page with.</param>
203-
/// <returns>A result with the PDF form filled as a byte array.</returns>
204-
Task<IPDFtkResult<byte[]>> ReplacePage(Stream pdfFile, int page, Stream replacementPdfFile);
205-
70+
20671
/// <summary>
20772
/// Replaces a page in a PDF with another PDF
20873
/// </summary>

0 commit comments

Comments
 (0)