is there a way to make the color not dull but pure black?
I use the following code but it's not doing anything to the color..
widget = field.create_widget(pdf.pages[0], Rect: rect, font_color: [0, 0, 0])
if field_name == 'representative'
if widget && widget[:Subtype] == :Widget
widget[:Rect] = [300, 583, 470, 608]
end
end
if field_name == 'aggrieved_party'
if widget && widget[:Subtype] == :Widget
Rails.logger.info "Adjusting aggrieved_party field widget properties"
widget[:Rect] = [120, 558, 230, 583]
end
end
if field_name == 'relationship'
if widget && widget[:Subtype] == :Widget
widget[:Rect] = [400, 558, 530, 583]
end
end
if field_name == 'name_printed'
if widget && widget[:Subtype] == :Widget
widget[:Rect] = [120, 498, 230, 520]
end
end
I want the text color to be black when I add the text entered into the form.
From your screenshot I guess that field is a single line text field? If so, then the appearance style of the text is set through field.set_default_appearance_string.
The :font_color key can only be used when creating the field itself and not for #create_widget as the appearance is part of the field and not the widget, i.e. see https://hexapdf.gettalong.org/documentation/api/HexaPDF/Type/AcroForm/Form.html#method-i-create_text_field.
Hi, thanks for your reply! Let me clarify my question. Sorry if it was unclear earlier. Here's an example from your site:
https://hexapdf.gettalong.org/examples/acro_form.html
1)
2)
Notice how 1 looks dull compared to 2. When I click on the field, the text appears black like 2, which is the color I want to print. However, even though I set the color to black, it still prints looking like 1. Is there something I am missing?
What you are seeing in screenshot 1 is the PDF viewer marking up the form fields with a background color so that it is easier to spot them. In screenshot 2 you are editing the field which presents the input box, so there is no need for the special background color anymore.
Anyway, the field text itself is written in black and this special background is usually only shown by the viewer when interacting with the PDF but not when printing it.
Have you tried different PDF viewers? And could you share the PDF in question? Then I could inspect it and see if the colors are indeed not black.
@slopeofhope81 I will close this issue. If there is still a problem, please comment and I will re-open.