feat(Edit): created to handle pdf edit operations fluently
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using iText.Kernel.Colors;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Pdf.Canvas;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
@@ -16,6 +15,7 @@ namespace EnvelopeGenerator.PdfEditor
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
#region Edit PDF document
|
||||
public static TStream Edit<TStream>(this TStream inputStream, Action<PdfDocument> edit)
|
||||
where TStream : Stream, new()
|
||||
{
|
||||
@@ -36,6 +36,18 @@ namespace EnvelopeGenerator.PdfEditor
|
||||
return inputStream.Edit(edit).ToArray();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static byte[] Design(this byte[] pdfBytes, params (int pageIndex, Action<PdfCanvas> design)[] pageDesign)
|
||||
=> pdfBytes.Edit(doc =>
|
||||
{
|
||||
foreach((int pageIndex, Action<PdfCanvas> design) in pageDesign)
|
||||
{
|
||||
var page = doc.GetPage(pageIndex);
|
||||
var canvas = new PdfCanvas(page);
|
||||
design(canvas);
|
||||
}
|
||||
});
|
||||
}
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user