unidoc / unipdf

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

[BUG]: Not able to change text color of form fields in the PDF #558

Open pranavbansod opened 1 week ago

pranavbansod commented 1 week ago

Description

Unidoc version: 3.57.0 I'm trying to fill pdf form from a json. I want to change text color of the new values which are filled from the Json. Reference Code: https://github.com/unidoc/unipdf-examples/blob/master/forms/pdf_form_fill_json.go

    // NOTE: To customize certain styles try:
    // style := fieldAppearance.Style()
    // style.CheckmarkGlyph = "a22"
    // style.AutoFontSizeFraction = 0.70
    // fieldAppearance.SetStyle(style)
    //
    // or for specifying a full set of appearance styles:
    // fieldAppearance.SetStyle(annotator.AppearanceStyle{
    //     CheckmarkGlyph:       "a22",
    //     AutoFontSizeFraction: 0.70,
    //     FillColor:            model.NewPdfColorDeviceGray(0.8),
    //     BorderColor:          model.NewPdfColorDeviceRGB(1, 0, 0),
    //     BorderSize:           2.0,
    //     AllowMK:              false,
    // })

I'm trying to set FillColor of AppearanceStyle to change the color. But it is not changing. I tried using different methods to change color

model.NewPdfColorDeviceGray(0.8)
model.NewPdfColorDeviceRGB(1, 0, 0)

The above methods I used are changing border color when set to BorderColor: model.NewPdfColorDeviceRGB(1, 0, 0). But the same is not happening when I try to change text color.

Expected Behavior

It should change the text color.

Attachments

Here is the code snippet:

fieldAppearance.SetStyle(annotator.AppearanceStyle{
    CheckmarkGlyph:       "a22",
    AutoFontSizeFraction: 0.70,
    FillColor:            model.NewPdfColorDeviceGray(0.8),
    BorderColor:          model.NewPdfColorDeviceRGB(1, 0, 0),
    BorderSize:           2.0,
    AllowMK:              false,
})
github-actions[bot] commented 1 week ago

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

kellemNegasi commented 6 days ago

Hi @pranavbansod, Thank you for reporting this issue. Currently, there is no rich text support for form field values in UniPDF, which means this is a feature request. We have created a ticket for this, and we will implement it in the future. We will write an update on this issue as soon as the feature gets released.