Free Support Forum - aspose.com

Word to pdf conversion not recognizing font

Hi,

I am converting a word document which contains text formatted with the 3of9 wide true type font. The font is installed on my system and when viewing the document in word, everything is fine.

When I do the conversion however, the generated pdf contains plain text where the 3of9 wide font should have been applied.

I saved the word doc to aspose pdf xml and the text in question does seem to be annotated with the correct font


*481650-1-
$p
-
$P
*

According to the pdf documentation, I thought that as long as a true type font was installed on the system, the aspose pdf component would use it when generating the pdf?

Is there another step I need to complete to make the pdf generation use this font?

Thanks,

Stu

Dear Stu,

We have no that font. Can you please attach the font and Word document so we can test it?

Hi,

I was able to get this to work based upon the following post http://www.aspose.com/community/forums/thread/106614/embed-fonts-into-a-pdf-when-converting-doc-to-pdf.aspx

Our document generation server has the font installed, but not the machine I was viewing the pdf on, which is why I was seeing clear text when viewing the generated pdf. I did however have to tweak the code in the post above a little bit to get the embedding to work for my font. I'm including it below so that hopefully someone can take a quick look and make sure it is not doing anything dumb and if not, then it may help someone else in the future.

Aspose.Pdf.HeaderFooter hf = evenFooter ? section.EvenFooter : section.OddFooter;

foreach (Aspose.Pdf.Paragraph para in hf.Paragraphs)

{

if (para is Aspose.Pdf.Table)

{

Aspose.Pdf.Table table = (Aspose.Pdf.Table)para;

foreach (Aspose.Pdf.Row row in table.Rows)

{

foreach (Aspose.Pdf.Cell cell in row.Cells)

{

foreach (Aspose.Pdf.Paragraph cellpara in cell.Paragraphs)

{

if (cellpara is Aspose.Pdf.Text)

{

Aspose.Pdf.Text text = (Aspose.Pdf.Text)cellpara;

foreach (Aspose.Pdf.Segment seg in text.Segments)

{

if (seg.TextInfo.FontName.Equals("Code39 Wide"))

{

seg.TextInfo.IsFontEmbedded = true;

}

}

}

}

}

}

}

}

Thanks,

Stu