Как встроить шрифты в многопоточную функцию?
Приведенная ниже функция является многопоточной функцией, которая добавляет круговой фолио на каждую страницу.
При одновременном доступе к этой функции производительность значительно снижается, поскольку потоки не могут одновременно обращаться к шрифту.
Мы используем новейшую библиотеку APDFL15.0.4PlusP4m
Есть ли обходное решение или встроенная функция для поддержки этого?
int pdf_node:: CircleFolio(PDPage *pdPage ,int currentPage, ASFixedRect
*pageTrimBox,char strSessionId[])
{
ASInt32 err = 0;
PDEContent pdeContent = NULL;
ASPathName path;
char strErrMsgExcep[UTL_K_MAX_ERROR_MESSAGE_LENGTH + 1];
char buf[256];
int ret;
ASFixedMatrix textMatrix;
PDEText pdeText = NULL;
PDEPath pdePath = NULL;
PDEGraphicState gState;
PDEFont strFont = NULL;
TSTBUG(1,"Before font ");
strFont = CreateNEmbedFont("Helvetica","Type1");
TSTBUG(1,"After Font");
//strFont = CreateNEmbedFont("Helvetica","Type0");
char strPAGENUMBER[5]; // upto 9999 pages
ASFixedPoint center;
ASFixed radius;
PDEPath circle;
PDDocSaveParamsRec SaveParams;
DURING
// TSTBUG(1,"STEP1 ");
pdeContent = PDPageAcquirePDEContent(*pdPage, 0);
center.h = (pageTrimBox->right - pageTrimBox->left)/2; //HORIZONTAL ALIGNMENT
center.v = pageTrimBox->bottom + FloatToASFixed(72*0.25); // VERTICAL ALIGNMENT
radius = FloatToASFixed(9.94); // Value in "pts"
circle = DrawCircle(*pdPage, center, radius, 1, 255,0, 0);
PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)circle);
// TSTBUG(1,"STEP2 ");
memset(&textMatrix, 0, sizeof(textMatrix));
pdeText = PDETextCreate();
pdePath = PDEPathCreate();
PDEPathSetPaintOp(pdePath, kPDEStroke);
//gState = SetGraphicState(ASInt32ToFixed(1),FloatToASFixed((float)255/255), FloatToASFixed((float)0/255), FloatToASFixed((float)0/255));
//CMYK changes
gState = SetGraphicStateCMYK(ASInt32ToFixed(1),60, 40, 40, 100);
PDEElementSetGState((PDEElement) pdePath, &gState, sizeof (PDEGraphicState));
textMatrix.a = Int16ToFixed(8);
textMatrix.d = Int16ToFixed(7);
TSTBUG1(1, "currentPage inside circlefolio is =>%d<= \n",currentPage);
sprintf(strPAGENUMBER,"%d",currentPage+1);
if(currentPage < 10)
{
textMatrix.h = (pageTrimBox->right - pageTrimBox->left)/2 - FloatToASFixed(3.0);
}
if(currentPage >= 10 && currentPage < 100)
{
textMatrix.h = (pageTrimBox->right - pageTrimBox->left)/2 - FloatToASFixed(4.5);
}
else if(currentPage >= 100 && currentPage < 1000)
{
textMatrix.h = (pageTrimBox->right - pageTrimBox->left)/2 - FloatToASFixed(7.0);
}
else if(currentPage >= 1000 && currentPage < 10000)
{
textMatrix.h = (pageTrimBox->right - pageTrimBox->left)/2 - FloatToASFixed(9.70);
}
textMatrix.v = pageTrimBox->bottom + FloatToASFixed(72*.225);
PDETextAdd(pdeText,kPDETextRun,0,(Uns8 *)strPAGENUMBER,strlen(strPAGENUMBER),strFont,&gState,sizeof(gState),NULL, 0,&textMatrix,NULL);
PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement) pdeText);
if(pdeText) PDERelease((PDEObject) pdeText);
PDPageSetPDEContentCanRaise(*pdPage , NULL);
PDPageReleasePDEContent(*pdPage, NULL);
// TSTBUG(1,"STEP3 ");
HANDLER
AdobeExceptionHandling(strSessionId, "CircleFolio", strErrMsgExcep);
sprintf(strWriteLogBuff, "Error: Could Not Complete CircleFolio!!");
WriteLog(strWriteLogBuff, LOG_ERROR_LEVEL, strTempBuff);
return PDFASSEMBLY_FAILURE;
END_HANDLER
// TSTBUG(1,"STEP4 ");
return (0);
}
0 ответов
Вы пытались связаться со службой поддержки моей компании (tech_support@datalogics.com)? Если нет, то это будет первым шагом для получения помощи по вашей проблеме с использованием библиотеки PDF.