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

How to set the Font Size and Type in a Drop-Down Form Field?

Question

Calls to set the font type and size for a Drop-Down field are ignored. Can you test and provide an example of working code for setting the font type and/or font size of such a form field?

Also, according to http://www.quickpdflibrary.com/help/quickpdf/AddFormFieldSub.php the AddFormFieldSub() function is supposed to return a temporary field index that can then be used to set properties for the sub-element that was just added. However, while I'm able to add elements to the Drop-Down using that call, the temporary index returned is always zero. How can I get access to the element in order to set its properties. Can different elements in a Drop-Down have different font colors?

Thanks!

Answer

The font size and font type of a drop-down form field can indeed be set. I've included some Delphi sample code below that demonstrates how:

var
  i: Integer;
  FormField: Integer;
  FontIndex: Integer;
  FontSize: Extended;
  FormFonts: TStrings;
begin
  FormFonts := TStringList.Create;

  //Reading Form fonts
  for i := 1 to PDFLibrary.GetFormFontCount do
    FormFonts.Add(PDFLibrary.GetFormFontName(i));

  //Show available Form fonts in some ListBox
  ListBox1.Items.AddStrings(FormFonts);

  FontIndex := FormFonts.Count; //for example last font from available
  FontSize := 16;
  FormField := 1; //for example first field

  PDFLibrary.SetFormFieldFont(FormField, FontIndex);
  PDFLibrary.SetFormFieldTextSize(FormField, FontSize);

  FormFonts.Free;
end;

With regards to the AddFormFieldSub function, this will not work with items in a drop-down-list form field because different elements in a drop-down-list cannot have different font types or colors, so a temporary form field index is not necessary.


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