#pragma message("Import AutoCAD API")
#import "C:\\Program Files\\Common Files\\Autodesk Shared\\acax17enu.tlb"\
rename_namespace("ACAD"), auto_rename
#import "progid:udc.apiwrapper" rename_namespace("UDC")
void PrintAdobePDFToJPEG( CString sFilePath )
{
LONG nBACKGROUNDPLOT, nFILEDIA, nCMDDIA;
float fAppVer = 0.f;
UDC::IUDCPtr pUDC(__uuidof(UDC::APIWrapper));
UDC::IUDCPrinterPtr itfPrinter = pUDC->Printers["Universal Document Converter"];
UDC::IProfilePtr itfProfile = itfPrinter->Profile;
itfProfile->Load("C:\\Program Files\\Universal Document Converter\\UDC Profiles\\Drawing to PDF.xml");
itfProfile->OutputLocation->Mode = UDC::LM_PREDEFINED;
itfProfile->OutputLocation->FolderPath = L"C:\\Out";
itfProfile->PostProcessing->Mode = UDC::PP_OPEN_FOLDER;
ACAD::IAcadApplicationPtr objACADApp(L"AutoCAD.Application");
ACAD::IAcadDocumentPtr itfDrawing;
ACAD::IAcadLayoutPtr itfLayout;
ACAD::IAcadPaperSpacePtr itfActiveSpace;
sscanf_s( objACADApp->Version, "%f", &fAppVer );
itfDrawing = objACADApp->Documents->Open( (LPCTSTR)sFilePath, false );
if( itfDrawing->ActiveSpace == 0 )
{
itfActiveSpace = itfDrawing->PaperSpace;
itfLayout = itfActiveSpace->Layout;
}
else
{
itfActiveSpace = itfDrawing->ModelSpace;
itfLayout = itfActiveSpace->Layout;
}
itfLayout->PlotType = ACAD::acExtents;
itfLayout->UseStandardScale = true;
itfLayout->StandardScale = ACAD::acScaleToFit;
itfLayout->CenterPlot = true;
if( fAppVer >= 16.1f )
{
nBACKGROUNDPLOT = itfDrawing->GetVariable("BACKGROUNDPLOT");
nFILEDIA = itfDrawing->GetVariable("FILEDIA");
nCMDDIA = itfDrawing->GetVariable("CMDDIA");
itfDrawing->SetVariable("BACKGROUNDPLOT", 0L);
itfDrawing->SetVariable("FILEDIA", 0L);
itfDrawing->SetVariable("CMDDIA", 0L);
}
itfDrawing->Plot->QuietErrorMode = true;
itfDrawing->Plot->PlotToDevice("Universal Document Converter");
if( fAppVer >= 16.1f )
{
itfDrawing->SetVariable("BACKGROUNDPLOT", nBACKGROUNDPLOT);
itfDrawing->SetVariable("FILEDIA", nFILEDIA);
itfDrawing->SetVariable("CMDDIA", nCMDDIA);
}
itfDrawing->Close(false);
objACADApp->Quit();
}
|