How to embed font in PDF Doc in Acrobat SDK
Hello,
We are developing new plugin and we are listing all the fonts available in the document by iterating all the pages. We need to make embed font if the font is not embedded in the document.
I am using below code to do this and i am unable to embed the font.
void EmbeddingFont(CString fontname)
{
PDEFont pdeFont = NULL;
PDEFontAttrs pdeFontAttrs;
PDSysFont sysFont; ASUns32 fontCreateFlags;
memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs));
char pszPath[250];
for (int i = 0; i < fontname.GetLength(); i++)
pszPath[i] = fontname.operator[](i);
pdeFontAttrs.name = ASAtomFromString(pszPath);
sysFont = PDFindSysFont(&pdeFontAttrs, sizeof(pdeFontAttrs), 0);
PDSysFontGetAttrs(sysFont, &pdeFontAttrs, sizeof(pdeFontAttrs));
if ((pdeFontAttrs.protection & kPDEFontNoEditableEmbedding) == 0) {
fontCreateFlags = kPDEFontCreateEmbedded ;
}
else if ((pdeFontAttrs.protection & kPDEFontNoEmbedding) == 0) {
fontCreateFlags = kPDEFontCreateEmbedded | kPDEFontWillSubset;
}
else { fontCreateFlags = kPDEFontDoNotEmbed; }
pdeFont = PDEFontCreateFromSysFont(sysFont, fontCreateFlags);
PDEFontEmbedNow(pdeFont, PDDocGetCosDoc(pdDoc));
PDDoc pdDoc = AVDocGetPDDoc(AVAppGetActiveDoc());
SavePDFDocument(pdDoc, L"C:\\Users\\vlakkenahalli\\Desktop\\test-5.pdf");
}
PDEFontCreateFromSysFont this API not returning the PDEFont to embed, is there any mistake in the code or do i need to follow any other approach.
Thank you
Chaya
