Search code examples
fontsoffice-interoppostscript

Substituted fonts and Word Automation


I have a word document that uses a nonstandard font. It's not embedded but is installed on the machine in question. In Word 2010, when I print that to a post script file while specifying a certain printer driver (HP Color LaserJet 2800 Series PS), that font gets embedded (subset) just fine. That's if I do it from the Word application itself.

If I try to do it programmatically using msword::_Document::Printout and specifying the same printer driver, the font in question gets subsituted with something else. I know the same printer driver is being used in both cases. The .ps files generated for both methods list the printer drivers name at the top. Is there some reason going through automation this way would substitute the font but going through the app itself does not?

CComVariant vIgnore; 
vIgnore.vt = VT_ERROR;
vIgnore.scode = DISP_E_PARAMNOTFOUND;

CComVariant vFalse = false;
CComVariant vTrue = true;
CComVariant vOutputFile(m_csTempOutputFile);
CComVariant vOneCopy((int)1);  

 ...
 ....

 m_piApp->SetActivePrinter( (LPCTSTR) csPrinterName); 

 m_Doc.PrintOut(
        &vFalse,//Background, return control while printing? FALSE
        &vFalse,//Append, append output to existing file? FALSE, overwrite file
        &vIgnore,//Range, the page range
        &vOutputFile,//OutputFileName, name of printtofile file
        &vIgnore,//From, starting page (ignored)
        &vIgnore,//To, ending page (ignored)
        &vIgnore,//Item, what content to print, DEFAULT
        &vOneCopy,//Copies, number of
        &vIgnore,//Pages, page range
        &vIgnore,//PageType, even only, odd only, etc
        &vTrue,//PrintToFile, TRUE
        &vIgnore,//Collate,
        &vIgnore,//ActivePrinterMacGX, (mac feature only)
        &vIgnore,//ManualDuplexPrint,
        &vIgnore,//PrintZoomColumn, (printing several pages on one page)
        &vIgnore,//PrintZoomRow,
        &vIgnore,//PrintZoomPaperWidth,
        &vIgnore);//PrintZoomPaperHeight,

Solution

  • On some of my systems where I see this, a reboot of the server fixed my issue. It seems sometimes after installing a true type font, you need to reboot the server.

    And indeed, on some of my systems, after rebooting, I did see the font get embedded. Why doing the same thing through the Word app didn't need a reboot but going through automation did - I have no idea.

    http://www.idautomation.com/kb/ttf-printing.html