String text = 'Essential Studio is a software package that provides state-of-the-art solutions for startups and enterprises. It includes more than 1,700 components and frameworks for WinForms, WPF, ASP.NET (Web Forms, MVC, Core), UWP, WinUI, Xamarin, Flutter, Blazor, JavaScript, Angular, Vue, and React that make developers’ work easier.'; //Load existing document. PdfDocument doc = PdfDocument(inputBytes: File('path/input.pdf').readAsBytesSync()); //Get existing page. PdfPage page = doc.pages[0]; //Initialize coordinates. double margin = 40; double paragraphStartY = 35; double pageWidth = page.getClientSize().width; double pageHeight = page.getClientSize().height; //Create PdfStringFormat instance with a suitable line space. PdfStringFormat format = PdfStringFormat(lineSpacing: 2); //Draw text on the existing page. doc.pages[0].graphics.drawString( text, PdfStandardFont(PdfFontFamily.helvetica, 12), format: format, bounds: Rect.fromLTWH( margin, margin + paragraphStartY, pageWidth - (margin * 2), pageHeight - (margin * 2) - paragraphStartY)); final List<int> bytes = doc.save(); File('path/output.pdf').writeAsBytes(bytes); //Dispose the document instance. doc.dispose();
|