Create multi sheet PDF from ARX using DSD

By Adam Nagy

We already have a blog post on doing this from .NET, but it could take a bit of time to convert the code to ARX, so here it is.
It's not doing exactly the same but close enough :)

You'll have to include acplmisc.h and make sure your project links to AcPublish_crx.lib

static void plot (AcDbDatabase *pDb) {   CString pdfPath = "C:temppdfmyPDF.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 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:temppdf");   dsdData.setLogFilePath(L"c:temppdflogdwf.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); }

Comments

7 responses to “Create multi sheet PDF from ARX using DSD”

  1. sudarshan d. Avatar
    sudarshan d.

    what does setCurrentConfig() method do?
    and why to use devicename as a parameter to this method ?
    Please explain it ?

  2. Sudarshan d. Avatar
    Sudarshan d.

    this is very slow process as acplpublishExecute metod working slowly.
    please give the solution over it

  3. Creates the configuration object that needs to be passed to acplPublishExecute()

  4. This is what the publishing through the UI is using too. Maybe try setting the BACKGROUNDPLOT to 0 to speed things up – if you have not done it already.

  5. sudarshan d. Avatar
    sudarshan d.

    thank you.

  6. hello,i using this samp example code as a test,but can’t pubulish pdf, where I am doing wrong? thank you

  7. Without any info it’s difficult to say what the problem could be.
    The best would be if you asked this question on the AutoCAD API / ObjectARX forum and provide as much info as possible:
    https://forums.autodesk.com/t5/objectarx/bd-p/34
    Thank you

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading