createTemplate method
Creates a template from the page content.
//Loads an existing PDF document and create the template
PdfTemplate template =
PdfDocument(inputBytes: File('input.pdf').readAsBytesSync())
.pages[0]
.createTemplate();
//Create a new PDF documentation
PdfDocument document = PdfDocument();
//Sets the page settings margin
document.pageSettings.setMargins(2);
//Create a new PDF page
PdfPage page = document.pages.add();
//Draw the Pdf template by using created template
page.graphics.drawPdfTemplate(
template, Offset(20, 0), Size(page.size.width / 2, page.size.height));
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Implementation
PdfTemplate createTemplate() {
return _helper._getContent();
}