Using PDFNet virtual dirver to convert DWF/DWG and other formats to PDF

Q: I’m using PDFNet in an attempt to convert DWF and DWG files to PDF.

Now, everything is working great for the DWF files. PDFNet is opening them in an application that will display them and sending them off to the PDFNet print driver. It’s working perfectly.

When it comes to the DWG files, it hangs for a while and ends up throwing the error below. I have two different applications on my machine that can open and display DWG files. There is an association between the DWG file and one of the applications (meaning I can simply double click on a DWG file and it opens in the proper application). What am I missing? Is this task not possible to accomplish with this file type? If I’m just missing something can you please let me know what it is and if possible give me a code example?

I have looked at and am basing my code off of the Convert sample project.

A:

To print custom file formats via virtual printer driver, the associated application needs to support the command verb “print”.

A quick way to test this is right clicking the file to show the context menu and see if “Print” is one of the options.

If the print verb is not present, then PDFNet cannot use the perform the conversion.

Assuming that your associated application supports command line printing, you can manually add the print verb through modifying the registry.

-Under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.dwg\UserChoice

-look for value of “Progid”, this could be under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE

-Under this entry, you are looking for the “Shell” key. Add the “Print” key, with “command” and data as the command-line code to perform print.

For example, if you set your default program to open .dwg with notepad….

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.dwg\UserChoice

Ø Progid REG_SZ Applications\NOTEPAD.EXE

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\notepad.exe\shell

Ø Add key “print”

Ø Under “print”, add key “command”

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\notepad.exe\shell\print\command

Ø set default value to the command line code for printing

Ø (Default) REG_EXPAND_SZ %SystemRoot%\system32\NOTEPAD.EXE /p %1

Resources on setting command verbs
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144171(v=vs.85).aspx#customize_verb_static

After you made your changes to the registry, try to print from the context menu with the “print” command.

If that works successfully, PDFNet should also be able to convert the file.