unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.55k stars 250 forks source link

[FEATURE] : Not able to provide different colour to different form field in the PDF. #563

Open sukhendu321 opened 1 month ago

sukhendu321 commented 1 month ago

Unidoc version: v3.61.0

fieldAppearance := annotator.FieldAppearance{OnlyIfMissing: true, RegenerateTextFields: true}

// specify a full set of appearance styles
fieldAppearance.SetStyle(annotator.AppearanceStyle{
    AutoFontSizeFraction: 0.70,
    FillColor:            model.NewPdfColorDeviceRGB(1, 1, 1),
    BorderColor:          model.NewPdfColorDeviceRGB(0, 0, 0),
    BorderSize:           2.0,
    AllowMK:              false,
    TextColor:            model.NewPdfColorDeviceRGB(0.5, 0.8, 0.8), // text color as normalized RGB values
})

// Populate the form data with appearance.
pdfReader.AcroForm.FillWithAppearance(fieldData, fieldAppearance)

@kellemNegasi i am trying to change different fieldData with different colour but it is changing all the fieldData colours. Expected behaviour is to change specific fields with specific colour

kellemNegasi commented 1 month ago

Hi @sukhendu321 currently there is no API for setting text color to text fields individually during filling or flattening. Setting separete text color for each text field is only possible when creating the form. Can you check this example https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_with_text_color.go ?

sukhendu321 commented 1 month ago

hey @kellemNegasi thanks for the reply Could you please let us know if there are any plans to incorporate this feature in future updates?

Looking forward to your feedback.