getClientSize method
Get the PDF page size reduced by page margins and page template dimensions.
//Create a new PDF documentation
PdfDocument document = PdfDocument();
//Create a new PDF page
PdfPage page = document.pages.add();
//Gets the page client size
Size clientSize = page.getClientSize();
//Draw the text to the page
page.graphics.drawString(
'Hello World!!!', PdfStandardFont(PdfFontFamily.helvetica, 27),
brush: PdfBrushes.darkBlue,
bounds: Rect.fromLTWH(400, 600, clientSize.width, clientSize.height));
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Implementation
Size getClientSize() {
return _helper.isLoadedPage
? size
: PdfSectionHelper.getHelper(_helper.section!)
.getActualBounds(this, true)
.size
.size;
}