admin 发表于 2024-3-14 20:30:19

[每日一码] 通过ARX使用DSD创建多页PDF

static void plot (AcDbDatabase *pDb)
{
CString pdfPath = "C:\\temp\\pdf\\myPDF.pdf";
CString deviceName =L"DWG To PDF.pc3";
Acad::ErrorStatus es = Acad::eOk;

const TCHAR *docName;
es = pDb->getFilename(docName);   

AcDbLayoutManager *layoutManager =
    acdbHostApplicationServices()->layoutManager();
AcDbDictionary *layoutDict = NULL;
es = pDb->getLayoutDictionary(layoutDict, AcDb::OpenMode::kForRead);

// Start collecting info for the DSD data
AcPlDSDEntries dsdEntries;
AcDbDictionaryIterator *layoutIterator = layoutDict->newIterator();

// If we only want to plot paper spaces and not the model layout
AcDbObjectId msId = acdbSymUtil()->blockModelSpaceId(pDb);

for (; layoutIterator && !layoutIterator->done(); layoutIterator->next())
{
    AcDbObjectPointer<AcDbLayout> layout(
      layoutIterator->objectId(), AcDb::OpenMode::kForRead);

    if (layout->getBlockTableRecordId() == msId)
      continue;

    const ACHAR *layoutName;
    layout->getLayoutName(layoutName);

    AcPlDSDEntry dsdEntry;
    dsdEntry.setLayout(layoutName);
    dsdEntry.setDwgName(docName);
    dsdEntry.setTitle(layoutName);
    dsdEntries.append(dsdEntry);   
}

delete layoutIterator;
layoutDict->close();

AcPlDSDData dsdData;
dsdData.setDSDEntries(dsdEntries);

dsdData.setProjectPath(L"c:\\temp\\pdf\\");
dsdData.setLogFilePath(L"c:\\temp\\pdf\\logdwf.log");
dsdData.setSheetType(AcPlDSDEntry::SheetType::kMultiPDF);
dsdData.setNoOfCopies(1);
dsdData.setDestinationName(pdfPath);
dsdData.setPromptForDwfName(false);
dsdData.setSheetSetName(L"PublisherSet");

AcPlPlotConfig *plotConfig;
acplPlotConfigManager->setCurrentConfig(plotConfig, deviceName);   

// We need this for acplPublishExecute
acedArxLoad(L"AcPublish.arx");

acplPublishExecute(dsdData, plotConfig, false);
}
页: [1]
查看完整版本: [每日一码] 通过ARX使用DSD创建多页PDF