Pdf

I try to save a draft as pdf using the following code in c#

 

draft.SaveAs(newName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

 

Where newName is the name of the draft with the extention pdf. This is what the documentation tells me. Saving a draft as dwg works fine this way.

 

The message I get:

 

'c:\ ..\file name.dft' could not be saved because of a file translation error.

 

Any ideas?

 

P.S.: I work on Vista.

 

Posted by: Diederik Zaaijer
Post date: 5/2/2007 8:31:29 AM

5 REPLIES

RE: Pdf

The SaveAs is smoke-and-mirrors. All they're actually doing is printing to the "Solid Edge Velocity PS Printer 2.0". If that printer is not installed or is renamed, you will get that error.

 

Go to your printers and make sure that you have a printer named "Solid Edge Velocity PS Printer 2.0". If I rename mine, I get the exact same error.

 

Posted by: Jason Newell
Post date: 5/2/2007 2:25:03 PM

RE: Pdf

I am afraid that the printer is named that way ("Solid Edge Velocity PS Printer 2.0"). I checked.

 

If I do it through SE it does work perfectly. If I try using the interop assemblies it fails with the error posted previously.

 

I suspect that Vista is somehow preventing it to work.

 

Hmm tested it a few minutes ago on XP and this gives me the same problem.

 

 

Posted by: Diederik Zaaijer
Post date: 5/3/2007 5:14:48 AM

RE: Pdf

One thing to remember if you suspect it's a .NET issue is that you can test your code via Excel VBA. Open up Excel and go to Tools -> Macro -> Visual Basic Editor and double click "ThisWorkbook". That will bring up a VBA editor window that you can paste this code into and try.

 

 

Sub VBASaveAsPDF()

Dim objApp

Dim objDoc

Set objApp = GetObject(, "SolidEdge.Application")

Set objDoc = objApp.ActiveDocument

objDoc.SaveAs ("C:\test.pdf")

End Sub

 

 

Posted by: Jason Newell
Post date: 5/3/2007 7:54:28 PM

RE: Pdf

I tried using VBA and indeed it worked fine. So I thought to be smart and build a little COM dll using VB that I called from my .NET assembly.

 

It failed again!

 

I am almost out of options.

 

I also tried draft.PrintOut(...) using a 'PDF printer'. It worked but it gave an unrecognized PDF file error when I tried to open the result with Acrobat Reader.

 

Posted by: Diederik Zaaijer
Post date: 5/9/2007 11:26:26 PM

RE: Pdf

I also tried draft.PrintOut(...) using a 'PDF printer'. It worked but it gave an unrecognized PDF file error when I tried to open the result with Acrobat Reader.

I noticed that when I print from other applications to the "Solid Edge Velocity PS Printer 2.0", it actually wants to save the file as a .prn file (Printer Text File).

 

So in Solid Edge, if I print to the "Solid Edge Velocity PS Printer 2.0", and save it as a "C:\file.prn" (instead of a .pdf extension), then I can actually open the .prn file in Adbobe Reader (or Adobe Illustrator). I'm not sure if this the 'PDF printer' you are referring to above.

 

You can try printing to "Adobe PDF" if you have that installed, or install "Cute PDF" a free option.

 

I am running into a few problems when printing using c# scripting:

1) How do I specify a printer? (short of making it my windows default printer)

2) can I define a print area using a code (I would like the print area to be to the exact height and width of the current view without added white space)

3) Can I specify using code the file name and suppress all dialog prompts asking me for file names?

 

What I really need is export the file as a .PDF, but I need to be able to specify the print area and increase the line width. Using the SaveCopyAs method, I can't seem to specify the print area, and end up with a lot of white space (when I need the drawing to fill the image). But I'm unable to accomplish this using scripting. Any pointers on how to go about this?

 

 

 

Posted by: Denver Steiner
Post date: 11/11/2010 1:50:58 AM