PdfPageSettings constructor
PdfPageSettings([
- Size? size,
- PdfPageOrientation? orientation
Initalizes the PdfPageSettings class.
//Create a PDF document.
PdfDocument document = PdfDocument();
//Create a PDF page settings.
document.pageSettings =
PdfPageSettings(PdfPageSize.a4, PdfPageOrientation.portrait);
//Set margins.
document.pageSettings.margins.all = 50;
//Create page and draw text.
document.pages.add().graphics.drawString(
'Hello World!', PdfStandardFont(PdfFontFamily.helvetica, 12),
brush: PdfBrushes.black, bounds: Rect.fromLTWH(0, 0, 0, 0));
//Save and dispose document.
List<int> bytes = await document.save();
document.dispose();
Implementation
PdfPageSettings([Size? size, PdfPageOrientation? orientation]) {
_helper = PdfPageSettingsHelper(this);
if (size != null) {
_size = PdfSize.fromSize(size);
}
if (orientation != null) {
_orientation = orientation;
_updateSize(orientation);
}
_helper.origin = PdfPoint(0, 0);
_margins = PdfMargins();
}