Skip to main content
Participant
February 16, 2021
Question

How to embed font in PDF Doc in Acrobat SDK

  • February 16, 2021
  • 1 reply
  • 827 views

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

 

This topic has been closed for replies.

1 reply

ls_rbls
Community Expert
Community Expert
February 18, 2021

I think you may need to verify if some of the font types that you're trying to embedd in that document have any type of copyright restrictions.