Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PDFontMetrics Not Working as Expected in Plugin

Community Beginner ,
May 08, 2024 May 08, 2024

Hi,

I'm trying to make a plugin using visual C++ (VS 2019) on Win10x64 machine. The idea is (or was) to be able to bold all numbers in the text. I thought this could be done by altering some of the PDFontMetrics members, since some change  (ie PDFontMetricsP->stemV) between bold and normal text. 

The code shows I'm just taking the PDFontMetrics and reapplying them:

				PDEFont pdeFont = PDETextGetFont((PDEText)pdeElement, kPDETextRun, i);
				CosObj cosObj;
				PDEFontGetCosObj(pdeFont, &cosObj);			
				PDFont	pf = PDFontFromCosObj(cosObj);
				PDFontMetricsP metricsP = (PDFontMetricsP)calloc(sizeof(PDFontMetrics),1);//if not used, usually end up with null pointer
				ASSize_t sizeMetrics = sizeof(PDFontMetrics);
				PDFontGetMetrics(pf, metricsP, sizeMetrics);
				PDFontSetMetrics(pf, metricsP, sizeMetrics);

And this is what it does to the pdf, which originally was TimesNewRoman:

FontMetrics.jpg

I would've expected no change to the font using the PDFontSetMetrics(), so either I've messed up; for example without the calloc, metricsP would end up usually as a null pointer. I'm no expert in C++, so do not know why calloc is needed, or if I'm using it correctly. Otherwise, an Adobe bug?

I'm not holding my breath, there seem to be no examples/samples, or even hits, when searching for PDFontMetrics, but if anyone could point me in the right direction (no pun intended), I will be very surprised and very happy.  

 

TOPICS
Acrobat SDK and JavaScript
97
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation