Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

354
Vistas
Fill PDF AcroForm text field with boldface text using HexaPdf

I have a seemingly simple question, but I can't find the answer. I have a pre-existing pdf form. Filling in the form manually, one of its text fields shows its value in boldface type. When using HexaPdf to fill this field, the text should also appear in boldface, but it appears in regular type.

I fill the field with

doc.acro_form.field_by_name('text1').field_value = @record.value

To get this to be shown in boldface, I have tried the following, to no avail:

doc.acro_form.field_by_name('text1').set_default_appearance_string(font: 'Helvetica-Bold', font_size: 0)

This gets the error message "The requested font 'Helvetica-Bold' in variant 'none' couldn't be found".

Then I tried:

doc.acro_form.field_by_name('text1').set_default_appearance_string(font: 'Helvetica', variant: :bold, font_size: 0)

This gets: "unknown keyword: variant".

The configured fonts for the document are:

{"Times"=>[:none, :bold, :italic, :bold_italic], "Helvetica"=>[:none, :bold, :italic, :bold_italic], "Courier"=>[:none, :bold, :italic, :bold_italic], "Symbol"=>[:none], "ZapfDingbats"=>[:none]}

So Helvetica with variant :bold should be available.

Could someone please let me know the correct syntax? Thanks in advance!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I got this answer from @gettalong on github:

"It is indeed an issue as there is no way to do this currently with that method - I will fix it for the next release. You can use the following work-around until then:"

name = doc.acro_form.default_resources.add_font(doc.fonts.add('Helvetica', variant: :bold).pdf_object)
doc.acro_form.field_by_name('text1')[:DA] = "0 g /#{name} 0 Tf"

Thank you very much!

over 4 years ago · Santiago Trujillo Denunciar

0

With the HexaPDF 0.18.0 release this is now directly possible by using the font_options argument for #set_default_appearance_string. No more work-arounds needed!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda