title: How to obtain font data to embed in a PDF?
body: <p>My MFC application creates a PDF and now I'm trying to embed fonts, the PDF created opens in Foxit, Chrome, and the Windows 8 PDF Reader but doesn't in Acrobat.</p>
  
  <p>I tried validating the pdf file with <a href="http://www.pdf-online.com/osa/validate.aspx" rel="nofollow noreferrer">this online validator</a> and it says </p>
  
  <blockquote>
    <p>The object's identity 6 doesn't match with the object's reference identity 5.</p>
    
    <p>The embedded font program 'Candara' cannot be read.</p>
  </blockquote>
  
  <p><br>
  I think the way I am embedding it's correct</p>
  
  <pre><code>3 0 obj
  &lt;&lt;/Type /Font
      /Subtype /TrueType
      /BaseFont /Candara
      /FirstChar 0
      /LastChar 255
      /Widths 4 0 R
      /FontDescriptor 5 0 R
  &gt;&gt;
  endobj
  
  5 0 obj
  &lt;&lt;
      /Type /FontDescriptor
      /FontName /Candara
      /Flags 32
      /FontBBox [-700 -500 1800 1500]
      /ItalicAngle 0
      /Ascent 12
      /Descent -4
      /CapHeight 8
      /StemV 109
      /FontFile2 6 0 R
  &gt;&gt;
  endobj
  
  6 0 obj
  &lt;&lt;
      /Length 100376
      /Length1 100376
  &gt;&gt;
  stream
      ... font bytes ...
  endstream
  endobj
  </code></pre>
  
  <p><br>
  I believe my problem it is with the font data which is obtained with</p>
  
  <pre><code>LONG ret = ::TTEmbedFont(pDC-&gt;GetSafeHdc(),
                      TTEMBED_TTCOMPRESSED, 
                      CHARSET_UNICODE,
                      &amp;ulPrivStatus,
                      &amp;ulStatus,
                      WriteEmbedProc,
                      lpvVecBytes,
                      nullptr,
                      0,
                      0,
                      nullptr);
  </code></pre>
  
  <p>I also tried using <strong>TTEMBED_RAW</strong> and <strong>TTEMBED_EMBEDEUDC</strong></p>
  
  <p><br><br>
  Sorry for the long and maybe vague explanation but I'm kinda lost, </p>
  
  <p>So <strong>Is this the right way to obtain the font data to embed? If it is, should I applied a filter to the Font file object?</strong></p>
  
  <p><strong>EDIT:</strong> I Changed my application to use <a href="https://msdn.microsoft.com/pt-br/library/windows/desktop/dd144885(v=vs.85).aspx" rel="nofollow noreferrer">GetFontData</a> which returns the bytes of the font file and according to my research it is ok to use like this, But I still can't open in Acrobat and the online validation site still gives me the same error message.</p>
  
  <p><a href="https://www.dropbox.com/s/b4cl25ua05t425h/Teste_.pdf?dl=0" rel="nofollow noreferrer">link</a> to an example PDF with my issue.</p>
  
  <p>Thanks and any help will be appreciated!</p>