Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Exporting FormField Fonts
  FAQ FAQ  Forum Search   Register Register  Login Login

Exporting FormField Fonts

 Post Reply Post Reply
Author
Message
connerdk View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Nov 14
Location: Denmark
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote connerdk Quote  Post ReplyReply Direct Link To This Post Topic: Exporting FormField Fonts
    Posted: 07 Nov 14 at 10:52AM
Hi, i am using Debenu QuickPDF Library v9.16, but have testet this with v11.12 and i still have same issue.

I have a PDF with text form fields and needs to fill text with string for a certain codepage e.g. codepage 1250 and insert letter Ł. I finally got it to render correct, but when saving it to a file all standard ascii letters are shown as dots when opened in adobe reader and only the speciel letters like Ł can be read.

If i use GetInstalledFontsByCodePage function and just render with the first suggested font it actually works, but it is "arabic typesettings" font which is not very readable, when trying to use another more common font like "Helvetica" or "Arial" it does not work.

Also if i omit SetFormFieldFont and only use SetFormFieldStandardFont(4) // Helvetica on the form field, then it seems to write the file correct but then i can not display the speciel letters when rendering in QuickPDF.


      FQPDF.FindFonts; // Neccessary?

      slFontNames := TStringList.Create;
      slFontNames.CommaText := FQPDF.GetInstalledFontsByCodePage(FCodePage, 0);
      if slFontNames.Count > 0 then
      begin
        iPreferredFontIndex := -1;
        for i := 0 to slFontNames.Count - 1 do
        begin
          if (slFontNames = 'Helvetica') or
             (slFontNames = 'MS Sans Serif') or
             (slFontNames = 'Arial')
          then
          begin
            iPreferredFontIndex := i;
            break;
          end;
        end;

        if iPreferredFontIndex > -1 then
          sFontName := slFontNames[iPreferredFontIndex] + ' {' + IntToStr(FCodePage) + '}'
        else
          sFontName := slFontNames[0] + ' {' + IntToStr(FCodePage) + '}';
        iFontID := FQPDF.AddTrueTypeFont(sFontName ,1);
        FQPDF.SelectFont(iFontId);
      end
      else
      begin
        iFontID := FQPDF.AddStandardFont(integer(SF_Helvetica));
        FQPDF.SelectFont(iFontID);
        sFontName := FQPDF.FontName;
      end;
      slFontNames.Free;

      bFound := false;
      for i := 1 to FQPDF.GetFormFontCount do
      begin
        if sFontName = FQPDF.GetFormFontName(i) then
        begin
          FFormFieldFontID := i;
          bFound := true;
          break;
        end;
      end;

      if not bFound then
        FFormFieldFontID := FQPDF.AddFormFont(iFontID);

  // Following is done for every field
     FQPDF.SetFormFieldStandardFont(oFormField.Fields.Id, integer(SF_Helvetica)); 
     FQPDF.SetFormFieldFont(oFormField.Fields.Id, FFormFieldFontID);

Best regards
Rune
Back to Top
connerdk View Drop Down
Beginner
Beginner
Avatar

Joined: 07 Nov 14
Location: Denmark
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote connerdk Quote  Post ReplyReply Direct Link To This Post Posted: 07 Nov 14 at 1:48PM
FQPDF.AddTrueTypeFont('Garbage-string' ,1);
returns non-zero value even though i dont have a font called 'Garbage-string'
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 19 Nov 14 at 11:10AM
Conner,

First off I would suggest not using CodePages but instead set all strings as Unicode encoding.

Existing fonts in a PDF file may often only contain a subset of the characters of that font.  

re : SetFormFieldStandardFont(4)

This is a built in PDF font that that is supported by default by all PDF renderers / viewers.  Unfortunately there are only 229 or so charaters in this font so most Unicode characters are not included in the font.

re : Arabic -  We have very limited support for Arabic in the current versions of Debenu Quick PDF Library.

re : FQPDF.AddTrueTypeFont('Garbage-string' ,1);

A PDF library always needs to return the closest matching font to the font requested so that at least some characters are drawn.

In Debenu Quick PDF library 11.12 can you try using something like the following


            // Arial Unicode MS contains most characters
      
            // Create a dynamically subsetted font with Option 4. 
            int fid1 = QP.AddTrueTypeSubsettedFont("Arial Unicode MS", "", 4);
            QP.SelectFont(fid1);

            int ffid1 = QP.AddFormFont(fid1);

            // formfieldId must be a valid formfield ID.  ie.  between 1 and QP.FormFieldCount()
            QP.SetFormFieldValue(formfieldId, "ФЫВАABCDEF123456")

            // Test drawing on the page.
            QP.SetOrigin(1);
            QP.DrawText(50, 50, "ФЫВА  ABCDEF123456");

Andrew
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store