0

Is there a simple way to convert from dxf to pdf without opening AutoCad? I tried to do this by using AutoCad (ObjectARX) lib in c#, but with no results. The code I tried was this:

{

SaveFileDialog savedlg = new SaveFileDialog(); 
string st = savedlg.FileName;

int fileExtPos = st.LastIndexOf(".");
if (fileExtPos >= 0)
st = st.Substring(0, fileExtPos);

AcadDocument doc = AcApp.ActiveDocument;
AcadSelectionSet ss = doc.SelectionSets.Add("MySet");
ss.Select(AcSelect.acSelectionSetAll, null, null, null, null);
try
{
if (ss.Count > 0)
{ doc.Export(st, "pdf", ss);
MessageBox.Show("Saved....");
AcApp.Quit();
}
}
finally
{
ss.Delete();
}
}

It was extracted from here: Convert from dwg to pdf

I'm not sure, but it seems that this specific solution only works if you have AutoCad opened (see the AcadDocument doc = AcApp.ActiveDocument; line).

Do you know any solution better than this? Or can you see where is the error in this solution? The solution could be in any language, so if you know any other solution in any other language, let me know.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Flávio Schuindt
  • 403
  • 1
  • 7
  • 15
  • If you can right-click -> Print the file from Explorer without Autocad opening itself, you could just install PDFCreator and not have to write a single line of code (PDFCreator can be configured in order to require no interaction). – Alex Jan 08 '13 at 14:52
  • I'm writing a tool that makes all of this automatically without any kind of human interaction. The user should only choose which files he wants (.dxf files) and the output should be the pdf. I don't want right-click or something like this. Thanks! – Flávio Schuindt Jan 08 '13 at 20:36
  • Hi flavio, did you find a solution? – Flappy Jun 02 '14 at 22:00

3 Answers3

0

You can use a third-party software to do that, just search "dxf to pdf" you will find many popular dxf to pdf converters without the need of AutoCAD.

Sue Villa
  • 21
  • 3
0

I'd like to suggest you to use AutoCAD 2013.

I know that you don't want to open full AutoCAD, but stating at 2013 version, it comes with a console version, fully functional!

Before that, I used to make two apps, one in DLL to be loaded into autocad and another to start/load/process each file.

Using AutoCAD's console mode, that starts very fast, you can make a script to print PDF to execute for each file.

Caverna
  • 461
  • 9
  • 16
-1
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "PDF (*.pdf)|*.pdf";
if (DialogResult.OK == dlg.ShowDialog())
{
    renderView.Renderer.Print(dlg.FileName);
}
Rabbid76
  • 202,892
  • 27
  • 131
  • 174