//Loads an existing PDF document. final PdfDocument document = PdfDocument(inputBytes: File('input.pdf').readAsBytesSync()); //Get the loaded form field by index. final PdfField field = document.form.fields[0]; if (field is PdfTextBoxField) { //Modify the back color. field.backColor = PdfColor(255, 0, 0); //Modify the border color. field.borderColor = PdfColor(0, 255, 0); //Modify the text color. field.foreColor = PdfColor(0, 0, 255); } //Disable default appearance. document.form.setDefaultAppearance(false); //Save the PDF document. File('output.pdf').writeAsBytesSync(await document.save()); //Dispose the document. document.dispose(); |