HOW TO

Programmatically embed fonts when exporting a map to PDF

Last Published: April 25, 2020

Summary

Instructions provided demonstrate how to programmatically embed fonts when exporting a map to PDF format.

Procedure



  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument then right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Note:
    Code in the Project's ThisDocument code module will only run in the current map document. To store the code in all map documents open the Normal.mxt ThisDocument code module instead.

  4. Copy the following code into the code module.

    Code:
    Sub exportPDF()

    Dim pMxApp As IMxApplication
    Dim pMxDoc As IMxDocument
    Dim pActiveView As IActiveView
    Dim pPageLayout As IPageLayout
    Dim pExporter As IExport
    Dim pExporter2 As IExportPDF
    Dim pPrinter As IPrinter

    Dim pRECT As tagRECT
    Dim hDc As OLE_HANDLE

    Dim pDriverBounds As IEnvelope
    Dim pVisibleBounds As IEnvelope
    Dim pPixelBounds As IEnvelope
    Dim ipPixelBounds As IEnvelope

    Dim width As Double
    Dim height As Double

    Set pMxApp = Application
    Set pMxDoc = ThisDocument
    Set pActiveView = pMxDoc.ActiveView
    Set pPageLayout = pMxDoc.PageLayout
    Set pExporter2 = New exportPDF
    Set pExporter = pExporter2

    Set pPrinter = pMxApp.Printer

    Set pVisibleBounds = New Envelope
    Set pVisibleBounds = Nothing 'set to nothing unless clip to graphic extent is checked

    Set pPixelBounds = New Envelope

    pExporter.ExportFileName = "C:\temp\PDFexport.pdf"
    pExporter.Resolution = 300

    pExporter2.EmbedFonts = True

    pPrinter.QueryPaperSize width, height

    pRECT.Left = 0
    pRECT.Top = 0
    pRECT.Right = width * pExporter.Resolution
    pRECT.bottom = height * pExporter.Resolution

    pPixelBounds.PutCoords pRECT.Left, pRECT.Top, pRECT.Right, pRECT.bottom
    pExporter.PixelBounds = pPixelBounds

    hDc = pExporter.StartExporting

    pMxDoc.ActiveView.Output hDc, pExporter.Resolution, pRECT, pVisibleBounds, Nothing

    pExporter.FinishExporting

    End Sub

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000007500

Software:
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic