feat(pdf): add overload for Page to apply design across all pages
- Introduced Page(Action<PdfPage>) method to apply design logic to every page in the document - Simplified Background method by replacing per-page iteration with new Page overload - Improved readability and maintainability by removing duplicate page loop logic
This commit is contained in:
parent
6f31d7b1d0
commit
7cae9a5291
@ -69,7 +69,15 @@ namespace EnvelopeGenerator.PdfEditor
|
||||
{
|
||||
var page = doc.GetPage(pageIndex);
|
||||
design(doc.GetPage(pageIndex));
|
||||
});
|
||||
});
|
||||
|
||||
public Pdf<TInputStream, TOutputStream> Page(Action<PdfPage> design)
|
||||
{
|
||||
for (int i = 1; i <= _doc.GetNumberOfPages(); i++)
|
||||
Page(i, design);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pdf<TInputStream, TOutputStream> Design(int pageIndex, Action<PdfCanvas> design)
|
||||
=> Document(doc =>
|
||||
@ -84,14 +92,11 @@ namespace EnvelopeGenerator.PdfEditor
|
||||
where TSignature : ISignature
|
||||
{
|
||||
// once per page
|
||||
var pageIndexes = signatures.Select(signature => signature.Page).Distinct().OrderBy(index => index);
|
||||
foreach(var pageIndex in pageIndexes)
|
||||
Page(page =>
|
||||
{
|
||||
var page = _doc.GetPage(pageIndex);
|
||||
Rectangle pageSize = page.GetPageSize();
|
||||
var canvas = new PdfCanvas(page);
|
||||
canvas.ConcatMatrix(1, 0, 0, -1, 0, pageSize.GetHeight());
|
||||
}
|
||||
canvas.ConcatMatrix(1, 0, 0, -1, 0, page.GetPageSize().GetHeight());
|
||||
});
|
||||
|
||||
foreach (var signature in signatures)
|
||||
Page(signature.Page, page =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user