How can I save a Word document as a PDF *without* any embedded fonts?

9

I have Microsoft Word 2010 and I am trying to use it to create a PDF document with a catch. I do NOT want any of the fonts used embedded. However, all the save options I have tried result in "Embedded Subset" fonts. Is there any way to save as PDF without embedding ANY fonts?

slipsec

Posted 2013-06-14T21:23:37.130

Reputation: 191

1What are you currently using to create these PDFs? PDFs are basically meant to be printed electronic documents and more or less immutable. Also, what are you reading them with that you don't want the fonts actually printed onto the document? What are you using them for? – Austin T French – 2013-06-15T01:02:41.930

I am testing conversion to other image formats (e.g. tiff), and need to test scenarios where the fonts were NOT embedded to be sure they are mapped to something that doesn't throw off alignment and spacing. It's easy enough to generate a word doc that includes all installed system fonts, but I want to save/export as a pdf without the fonts being embedded. – slipsec – 2013-06-17T12:45:51.030

Answers

0

[System.Reflection.Assembly]::LoadFrom("C:\path\to\itextsharp.dll")
#by default fonts are NOT embedded
#[iTextSharp.text.FontFactory]::DefaultEmbedding -eq false

$doc = New-Object iTextSharp.text.Document
$fileStream = New-Object IO.FileStream("C:\foo\test\allFonts2.pdf", [System.IO.FileMode]::Create)
[iTextSharp.text.pdf.PdfWriter]::GetInstance($doc, $filestream)

#iTextSharp provides a class to work with fonts, but first we have to register them:
[iTextSharp.text.FontFactory]::RegisterDirectories()

#Phrase is the smallest bit of text that will understand a newline if needed.  it is a chunk[] and paragraph is a phrase[]
$phrase = new-object iTextSharp.text.Phrase 
$paragraph = New-Object iTextSharp.text.Paragraph

#Different fonts for mapping tests
$fN = [iTextSharp.text.Font]::NORMAL
$fB = [iTextSharp.text.Font]::BOLD
$fI = [iTextSharp.text.Font]::ITALIC
$fBI = [iTextSharp.text.Font]::BOLDITALIC

#Sample string
$string = "The quick brown fox jumps over the lazy dog 1234567890 ?.,:;!@#$%^&*()`"'`n"
#something I know maps nicely (I love fixed width fonts!)
$consolas = [iTextSharp.text.FontFactory]::GetFont("consolas", 9)

#create all the nesting needed.
[iTextSharp.text.FontFactory]::RegisteredFamilies | %{

    $chunk = new-object iTextSharp.text.Chunk("`n$_`n", $consolas)
    $phrase.Add($chunk) | out-null

    $a = [iTextSharp.text.FontFactory]::GetFont($_, 9, $fN)
    "adding font: $_"
    $chunk = new-object iTextSharp.text.Chunk($string, $a)
    $phrase.Add($chunk) | out-null

    $b = [iTextSharp.text.FontFactory]::GetFont($_, 9, $fB)
    $chunk = new-object iTextSharp.text.Chunk($string, $b) 
    $phrase.Add($chunk) | out-null

    $c = [iTextSharp.text.FontFactory]::GetFont($_, 9, $fI)
    $chunk = new-object iTextSharp.text.Chunk($string, $c) 
    $phrase.Add($chunk) | out-null

    $d = [iTextSharp.text.FontFactory]::GetFont($_, 9, $fBI)
    $chunk = new-object iTextSharp.text.Chunk($string, $d) 
    $phrase.Add($chunk) | out-null
}

$paragraph.add($phrase) | out-null
$doc.Open()
$doc.add($paragraph) | out-null
$doc.close()

slipsec

Posted 2013-06-14T21:23:37.130

Reputation: 191

Can you explain, what is it? – turbanoff – 2015-10-01T20:21:07.113

@turbanoff Looks like Powershell with the itextsharp PDF library (for .NET). – Bob – 2016-05-13T06:02:21.213

3

It is possible to remove all the fonts forming xml document type WordML.

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Word.Document"?>
    <w:wordDocument xml:space="preserve" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
     <w:body>

      <w:tbl>
       <w:tblPr>
        <w:tblW w:w="9570" w:type="dxa"></w:tblW>
         <w:tblBorders> <w:top w:val="nil" /><w:left w:val="nil" /><w:bottom w:val="nil" /><w:right w:val="nil" />
         </w:tblBorders>
       </w:tblPr>

    <w:tr>
     <w:tc>
    <w:tcPr><w:tcW w:w="4785" w:type="dxa" /></w:tcPr>  <w:p></w:p>  </w:tc>
     <w:tc>  
    <w:tcPr><w:tcW w:w="4785" w:type="dxa" /></w:tcPr>  <w:p></w:p>  </w:tc>
    </w:tr>   

     <w:tr>    
         <w:tc>
          <w:tcPr><w:tcW w:w="0" w:type="auto" /></w:tcPr>  <w:p><w:pPr><w:jc w:val="right" /></w:pPr>
       <w:r><w:t>Company: </w:t></w:r> 
      </w:p>
     </w:tc>   

        <w:tc>
          <w:tcPr><w:tcW w:w="0" w:type="auto" />
           <w:tcBorders>      <w:top w:val="single" w:sz="2" w:color="0070C0" />    <w:left w:val="single" w:sz="2" w:color="0070C0" /> <w:bottom w:val="single" w:sz="2" w:color="0070C0" /> <w:right w:val="single" w:sz="2" w:color="0070C0" />
           </w:tcBorders>
          </w:tcPr>
         <w:p><w:pPr><w:jc w:val="left" /></w:pPr><w:r><w:t></w:t></w:r></w:p>
        </w:tc>      
       </w:tr>       
      </w:tbl>
     </w:body>
    </w:wordDocument>

But, even if you delete all the styles and fonts of the original document, Word will assign during the opening of the document style by default. Also, at least one font will be in the Acrobat document when you open it, as if you did not act.

Office WordML XML File, Word load default style:

Office WordML XML File

After save as PDF in Acrobat view one font

Acrobat document font prop

A good solution is to choose at least one font that will still be in the pdf file and use it.

Way 2: Removing Unused Styles from Word

enter image description here

Sub DeleteUnusedStyles()
    Dim oStyle As Style
    For Each oStyle In ActiveDocument.Styles
        ‘Only check out non-built-in styles
        If oStyle.BuiltIn = False Then
            With ActiveDocument.Content.Find
                .ClearFormatting
                .Style = oStyle.NameLocal
                .Execute FindText:=””, Format:=True
                If .Found = False Then oStyle.Delete
            End With
        End If
    Next oStyle
End Sub 

See Format Fonts for Text Field Default Values

Style almost always includes the font and font size used for the determination of other sizes. Paragraph, line spacing, and so on ... If you need a different style mechanics generate the document itself. Including substitute fonts. If the final PDF document then use the built-in Adobe JavaScript. Or Adobe LiveCycle Designer ES and XDP XML.

Font at Adobe LiveCycle Designer XDP XML

Using Acrobat JavaScript in Forms: Importing and Exporting Form Data

XML Forms Architecture PDF!

STTR

Posted 2013-06-14T21:23:37.130

Reputation: 6 180

Won't this remove the style settings themselves not the embedded fonts? I want to retain the style, but remove the embedded fonts to force a "guess" for mapping by the conversion software I'm trying to test. – slipsec – 2013-06-17T12:47:16.770

@slipsec May be need create PDF manualy? – STTR – 2013-06-17T14:16:10.947

@slipsec, You might need to use a paid third party component to achieve this. – Adam – 2013-06-18T10:13:47.237

used iText, will post when I have it finished. – slipsec – 2013-06-18T15:55:46.147