0

I am using PDFlib v8 to create pages with checkboxes - after having no success using unicode text to display ✓ as a check in a textline or textFlow I opted for creating checks as checkbox fields.

The check displays however seems to be using Dingbat font by default - viewing the page on MacOS in Preview the check is very narrow and thin but in the proper x,y - however in Acrobat the check is clipped and offset to the right 10pts. Check character is bolder but partially hidden -

As last resort I will create a check as PDF or PNG and drop it in if there is no better way to control this...

alQemist
  • 362
  • 4
  • 13

1 Answers1

0

well, creating checkboxes within text is simple, you just have to take care about a few topics:

  • for checkbox glyphs use the Unicode 0x2611 etc. (see Unicode U+26xx Codepage) or for just the check Unicode 0x2713 etc. (see Unicode U+2700 Codepage) etc.
  • use a font which contains the required glyphs. (For example the Free DejaVu Sans contain the mentioned glyphs) Load this font with encoding "unicode". When you have to use fonts, which haven't this glyphs, you an use the fallbackfont feature in PDFlib, to configure an other font for picking the missing glyphs. (see PDFlib 8 Tutorial, chapter 5.4.6 "Fallback Fonts")
  • address the glyphs in PDFlib by applying the unicode values, or using character references for this (like &x2711;)

The following simple code, create a page with just one line of text, which contain the checkbox as well the check. The Checkboxes are addressed via character references. (see PDFlib 8 Tutorial, chapter 4.5.2 "Character References")

PDF_begin_page_ext(p, a4_width, a4_height, "");
PDF_fit_textline(p, "Hello ☑ ✓", 0, 50, 700,
   "fontname={DejaVuSans} encoding=unicode fontsize=20 charref textformat=utf8");
PDF_end_page_ext(p, "");

enter image description here

I opted for creating checks as checkbox fields

When you don't want to use interactive elements, I would recommend to avoid this. Interactive elements are displayed different in various PDF viewers. Some viewers just ignore them. So for static text, use text.

enjoy!

Rainer
  • 2,013
  • 1
  • 10
  • 7
  • Thanks for the recommendations - I finally opted for a vector drawing of check (mark) as a PDF - much easier than dealing with font issues.... – alQemist Dec 05 '15 at 14:09