Skip to content

Commit 2627ceb

Browse files
committed
Updating README.md
1 parent 6c30f56 commit 2627ceb

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

README.md

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ var result = await pdftk.SplitAsync(pdfBytes);
160160

161161
if(result.Success)
162162
{
163-
foreach (var pdfPage in result.Result)
163+
foreach (var (fileName, bytes) in result.Result)
164164
{
165-
// Do something with each pdfPage (byte[]).
165+
// Do something with each pdfPage.
166166
}
167167
}
168168
```
@@ -203,9 +203,83 @@ if(result.Success)
203203

204204
### Replace a Page
205205

206-
Replace a page in a PDF.
206+
Replace a page in a PDF with another PDF.
207207

208-
*Not Implemented yet.*
208+
```csharp
209+
var pdftk = new PDFtk();
210+
211+
var result = await pdftk.ReplacePage(
212+
await File.ReadAllBytesAsync("MyDocument.pdf"),
213+
page: 3,
214+
await File.ReadAllBytesAsync("replacement.pdf")
215+
);
216+
217+
if(result.Success)
218+
{
219+
// Do something with result.Result (bytes[])
220+
}
221+
```
222+
### Replace Pages
223+
224+
Replace multiple pages within a PDF with another PDF.
225+
226+
```csharp
227+
var pdftk = new PDFtk();
228+
229+
var result = await pdftk.ReplacePage(
230+
await File.ReadAllBytesAsync("MyDocument.pdf"),
231+
startPage: 3,
232+
endPage: 5,
233+
await File.ReadAllBytesAsync("replacement.pdf")
234+
);
235+
236+
if(result.Success)
237+
{
238+
// Do something with result.Result (bytes[])
239+
}
240+
```
241+
242+
### Attach files
243+
244+
Attaches files to a PDF, if `page` argument is supplied then files are attached to a given page, if `page` argument is not specified then files are attached at document level.
245+
246+
```csharp
247+
var pdftk = new PDFtk();
248+
249+
var result = await _pdFtk.AttachFiles(
250+
await File.ReadAllBytesAsync("MyDocument.pdf"),
251+
new Dictionary<string, byte[]>
252+
{
253+
["test-file1.txt"] = Encoding.ASCII.GetBytes("Hello"),
254+
["test-file2.txt"] = Encoding.ASCII.GetBytes("World")
255+
},
256+
page: 10 // Optional page to attach files
257+
);
258+
259+
if(result.Success)
260+
{
261+
// Do something with result.Result (bytes[])
262+
}
263+
```
264+
265+
### Extract Attachments
266+
267+
Extracts attachments from a PDF file.
268+
269+
```csharp
270+
var pdftk = new PDFtk();
271+
272+
var result = await _pdFtk.ExtractAttachments(
273+
await File.ReadAllBytesAsync("MyDocument.pdf"));
274+
275+
if(result.Success)
276+
{
277+
foreach (var (fileName, bytes) in result.Result)
278+
{
279+
// Do something with each attachment.
280+
}
281+
}
282+
```
209283

210284
### Compression/Decompression
211285

0 commit comments

Comments
 (0)