Applications can set a document to plot to a file by calling AcPlPlotEngine::beginDocument() with the bPlotToFile argument set to true and pFileName containing a fully qualified file name. In order to plot to a file, the selected device must support that capability.
The following code shows plotting to a file, with plot progress dialog code omitted for clarity:
AcPlPlotEngine* pEngine = NULL;
if(Acad::eOk==AcPlPlotFactory::createPublishEngine(pEngine))
{
...
es = pEngine->beginPlot(pPlotProgDlg);
AcPlPlotPageInfo pageInfo;
AcPlPlotInfo plotInfo;
plotInfo.setLayout(layoutId);
AcPlPlotInfoValidator validator;
es = validator.validate(plotInfo);
const char *szDocName=acDocManager->curDocument()->fileName();
// Set bPlotToFile parameter to true.
es = pEngine->beginDocument(plotInfo, szDocName,
NULL, 1, true, m_csFilename);
es = pEngine->beginPage(pageInfo, plotInfo, true);
es = pEngine->beginGenerateGraphics();
es = pEngine->endGenerateGraphics();
es = pEngine->endPage();
es = pEngine->endDocument();
es = pEngine->endPlot();
// Destroy the engine.
pEngine->destroy();
pEngine = NULL;
else
// Ensure the engine is not already busy...
AfxMessageBox("Plot Engine is Busy...");
}