libharu:HPDFAnnotation#set_icon

#!/usr/bin/env ruby

require "hpdf"

pdf  = HPDFDoc.new
page = pdf.add_page

y = 0
[HPDFDoc::HPDF_ANNOT_ICON_COMMENT,
 HPDFDoc::HPDF_ANNOT_ICON_KEY,
 HPDFDoc::HPDF_ANNOT_ICON_NOTE,
 HPDFDoc::HPDF_ANNOT_ICON_HELP,
 HPDFDoc::HPDF_ANNOT_ICON_NEW_PARAGRAPH,
 HPDFDoc::HPDF_ANNOT_ICON_PARAGRAPH,
 HPDFDoc::HPDF_ANNOT_ICON_INSERT
].each do |x|
  a = page.create_text_annot(0, y, 100, y + 100, "foo", pdf.get_current_encoder)
  a.set_icon(x)
  y += 100
end

pdf.save_to_file(File.basename($0, ".rb") + ".pdf")