lib/fillable-pdf-th.rb in fillable-pdf-th-1.0.3 vs lib/fillable-pdf-th.rb in fillable-pdf-th-1.0.4

- old
+ new

@@ -28,16 +28,32 @@ @pdf_doc = PDF_DOCUMENT.new @pdf_reader, @pdf_writer @pdf_form = PDF_ACRO_FORM.getAcroForm(@pdf_doc, true) @size = 12.00 set_font @form_fields = @pdf_form.getFormFields + + @checkbox_style = { + 'check' => PDF_FORM_FIELD.TYPE_CHECK, + 'circle' => PDF_FORM_FIELD.TYPE_CIRCLE, + 'cross' => PDF_FORM_FIELD.TYPE_CROSS, + 'diamond' => PDF_FORM_FIELD.TYPE_DIAMOND, + 'square' => PDF_FORM_FIELD.TYPE_SQUARE, + 'star' => PDF_FORM_FIELD.TYPE_STAR + } + set_checkbox_style end ## # Set font in PDF file # def set_font(font_path=FONT) @pdf_font = PDF_FONT_FACTORY.createFont(font_path, PDF_FONT_ENCODE.IDENTITY_H) + end + + def set_checkbox_style(mark_style='check') + fields.each do |key, value| + pdf_field(key).setCheckType(@checkbox_style[mark_style] || @checkbox_style['check'] ) if field_type(key).eql?('/Btn') + end end def set_size(size=@size) @size = size.to_f end