public void BuildFontFile2(Bytes.Buffer ttfStream) { PdfStream stream = new PdfStream(ttfStream); // as the stream was closed within the PdfStream constructor, we have to recreate it using (var input = (Bytes.Buffer)stream.ExtractBody(true)) { ttf = new TTFParser().ParseEmbedded(input); if (!IsEmbeddingPermitted(ttf)) { throw new IOException("This font does not permit embedding"); } if (fontDescriptor == null) { fontDescriptor = CreateFontDescriptor(ttf); } } stream.Header[PdfName.Length1] = PdfInteger.Get(ttf.OriginalDataSize); fontDescriptor.FontFile2 = new FontFile(document, stream); }