Convert Adobe API code to C# with Vintasoft

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Moderator: Alex

Post Reply
guillaume.corneau
Posts: 7
Joined: Wed May 20, 2020 8:11 pm

Convert Adobe API code to C# with Vintasoft

Post by guillaume.corneau »

Hi,

We currently have an Adobe plugin and we currently use Vintasoft to replace this old Plugin to new desing interface. So our customers will not need to have Adobe Pro and they will save monthy fees.

All options are currently converted but I can't find a way to convert one of them.

This is a part of code I'll need to convert

We have two parts of code, one to set some status in PDF and another one to reset status (Revert the first part)

This is the first part of code (Set status)

Code: Select all

PDPage page = PDDocAcquirePage(doc, pageNumber);         
PDEContent pdeContent = PDPageAcquirePDEContent(page, gExtensionID);
PDEPath path = createPageBolderPath(page, bolderWidth, bolderColor);
PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)path);
PDPageSetPDEContent(page, gExtensionID);
PDERelease((PDEObject)path);
PDPageReleasePDEContent(page, gExtensionID);


PDEPath JxStatusSetAction::createPageBolderPath(PDPage page, int width, QColor color) {
    PDEPath path = PDEPathCreate();
    ASFixedRect cropBox;
    PDPageGetCropBox(page, &cropBox);
    PDEPathSetPaintOp(path, kPDEStroke);
    PDEGraphicState state;
    memset(&state, 0, sizeof(PDEGraphicState));
    state.strokeColorSpec.space = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB"));
    state.strokeColorSpec.value.color[0] = ASFloatToFixed(color.redF());
    state.strokeColorSpec.value.color[1] = ASFloatToFixed(color.greenF());
    state.strokeColorSpec.value.color[2] = ASFloatToFixed(color.blueF());
    state.lineWidth = ASInt16ToFixed(width);
    state.miterLimit = fixedTen;
    state.flatness = fixedOne;
    PDEElementSetGState((PDEElement)path, &state, sizeof(PDEGraphicState));
    ASFixed pathData[5];
    pathData[0] = kPDERect;
    pathData[1] = cropBox.left;
    pathData[2] = cropBox.top;
    pathData[3] = cropBox.right - cropBox.left;
    pathData[4] = cropBox.bottom - cropBox.top;
    PDEPathSetData(path, pathData, sizeof(pathData));
    return path;
}
This is the second one (Reset status)

Code: Select all

PDPage page = PDDocAcquirePage(doc, pageNumber);

// delete all last elements which are path. for old pdflyer it might has two paths
PDEContent pdeContent = PDPageAcquirePDEContent(page, gExtensionID);
while (true) {
    int pdeNumber = PDEContentGetNumElems(pdeContent);
    if (pdeNumber == 0) break;
    PDEElement element = PDEContentGetElem (pdeContent, pdeNumber - 1);
    if (PDEObjectGetType((PDEObject)element) != kPDEPath) break;
    PDEContentRemoveElem(pdeContent, pdeNumber - 1);
}
PDPageSetPDEContent(page, gExtensionID);
PDPageReleasePDEContent(page, gExtensionID);

PDPageRelease(page);
Someone could you help me to convert it ?

Thank you
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Convert Adobe API code to C# with Vintasoft

Post by Alex »

Hello Guillaume,

Our support team helped you to convert your code. I marking this topic as solved.

Best regards, Alexander
Post Reply