Skip to Content

Guidelines to placing text with the Datalogics Unicode APIs

Estimated Reading Time: 2 Minutes

The Datalogics build of APDFL includes additional APIs to facilitate setting Unicode text. These APIs are demonstrated in the Unicode sample program in the APDFL/CPlusPlus/Sample_Source folder:

  1. PDETextAddASText()
  2. PDETextGetASText()
  3. PDEFontCheckASTextIsRepresentable()

Working with Unicode Text

  1. Obtain a NULL-terminated string in a valid Unicode encoding form (UTF-8, UTF-16, UTF-32). Make sure you know how your compiler will interpret the string with regards to byte ordering and NULL termination. Also look at the description of the UnicodeText sample program provided with Adobe PDF Library.
  2. Locate a PDSysFont using PDFindSysFont(), passing the font name in PDEFontAttrs.name. We recommend that you pass "Type0" in PDEFontAttrs.type.
  3. Create a PDSysEncoding of "Identity-H" or "Identity-V" using PDSysEncodingCreateFromCMapName(). These are the only supported encodings for use with the Unicode APIs. This value can be created once and reused when creating other PDEFonts.
  4. Create a PDEFont using PDEFontCreateFromSysFontAndEncoding(), passing in the PDSysFont, PDSysEncoding, the same font name used with PDFindSysFont(). Also pass the union of the following flags:
    1. kPDEFontCreateEmbedded
    2. kPDEFontCreateSubset
    3. kPDEFontCreateToUnicode
    4. kPDEFontEncodeByGID.
  5. Create an ASText from the string obtained in step 1, using ASTextFromUnicode(). Pass the appropriate ASUnicodeFormat parameter for the string.
  6. Verify that the string can be represented in the created font. If you know that glyphs for every character in the string are present in the font, or that missing glyphs in the output are not an issue, you can skip this step. If verification is necessary, use the Datalogics Unicode API PDEFontCheckASTextIsRepresentable(). Note that there is no method to check whether the string is representable without first creating the PDEFont.
  7. Call PDETextAddASText() with the PDEFont and the ASText. The other parameters are exactly as used withPDETextAdd().
  8. Add the PDEText element to the content and set the content on the page as normal.
  9. When all content has been set, make calls to these three APIs:
    1. PDEFontCreateWidthsNow()
    2. PDEFontCreateToUnicodeNow()
    3. PDEFontSubsetNow() or PDEFontEmbedNow()

Note that some text must have been placed, or these calls will cause an error.

Guidelines to placing text with the Datalogics Unicode APIs
  • COMMENT