Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Create check box form fields

Question

How do I create check box form fields in my PDF forms? Please provide some sample code.

Answer

Sample code for creating check box form fields in a PDF has been provided below in Delphi. If you require any further information about creating check boxes, please leave a comment.

  // Update drawing co-ordinates so that
  // they are taken from the top left
  // corner of the page.

  QP.SetOrigin(1);

  // Draw some filler text
  QP.DrawText(20, 20, 'Check Box Test:');

  // Add the first check box form field

  iDf1 := QP.NewFormField('Australian', 3);
  QP.SetFormFieldCheckStyle(iDf1, 2, 1);
  QP.SetFormFieldBounds(iDf1, 20, 60, 23, 23);
  QP.SetFormFieldBorderColor(iDf1, 0, 0, 0);

  // Add the second check box form field

  iDf2 := QP.NewFormField('Swdedish', 3);
  QP.SetFormFieldCheckStyle(iDf2, 2, 1);
  QP.SetFormFieldBounds(iDf2, 20, 120, 23, 23);
  QP.SetFormFieldBorderColor(iDf2, 0, 0, 0);

  // Optional: Pre-select one of the check boxes

  QP.SetFormFieldValue(iDf1, 'Yes');

  // Call the SetNeedAppearances function.
  // Required to display form fields in
  // PDF viewer.

  QP.SetNeedAppearances(1);

  // Save the new PDF form to disk
  QP.SaveToFile('check-boxes.pdf');

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum