Friday, March 3, 2006

How to install a printer from a DWF

I have though about sharing this tip about "Printer Connector" a long time. I've got some emails from those wondering how it could be done after Shaan Hurley, Autodesk posted about a solution I made a few years ago at the company I work for. Now I got reminded again reading about Internal Facilities Management application by Scott Sheppard, Autodesk. I assisted Brian Mathews and Brian Pene at their class at Autodesk University 2005 in Florida and I really recommend you to take a look at the available class materials you can find on Scott's blog. Actually Brian was one of those wondering how I had solved installing the printers from a DWF hyperlink. Nice to see that it's used at Autodesk too. Now to the solution that is really simple but useful.

Start with a DWG drawing of the facility and add a block that represents a printer or plotter. Add a hyperlink on the block that links to a html file on a location available for all users. Use the name of the printer and maybe size and type as description. The content of the html file is here. Just change the server name and the printer name in the code. Now Plot or Publish the drawing to DWF. If you have several levels and buildings you can create a main html page that links to these DWF files. The DWF files can also be embedded into a html page and add some simple instructions that they should click on a printer etc.
<html>
<head>
</head>
<p><font face="Verdana">Printer connection...</font></p>
<SCRIPT LANGUAGE="VBScript">
<!--
on error resume next
Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\SERVERNAME\PRINTERNAME"
msg="Do you want " & PrinterPath & " to be Default printer?"
answ=msgbox(msg,vbYesNoCancel,"Add Printer")
If answ=vbYes then
  WshNetwork.AddWindowsPrinterConnection PrinterPath
  WshNetwork.SetDefaultPrinter PrinterPath
elseif answ=vbNo then
  WshNetwork.AddWindowsPrinterConnection PrinterPath
end if
history.back()
-->
</SCRIPT>
</html>
See this html code or check in the DWF Viewer Help.
<script language="vbscript">
<!--
on error resume next
if not IsObject(CreateObject("AdView.AdViewer")) then msgbox "You need the DWF Viewer!" & vbNewLine & vbNewLine & "Please contact the IT department."
function ShowPrinters
EView.Viewer.HighlightLinks = not EView.Viewer.HighlightLinks
end function
-->
</script>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Printer Connector</title>
<style type="text/css">
a:link {color: #FFFFFF}
a:visited {color: #FFFFFF}
a:hover {color: #FF0000}
a:active {color: #FFFFFF}
</style>
</head>

<body bgcolor="#4083A8" topmargin="0">

<OBJECT
id=Eview
codeBase="file:///server/dwfviewer/installer/DwfViewerSetup.cab"
classid=clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF
width=100%
height=92% border="2" vspace="4">
<param name="_cx" value="38788">
<param name="_cy" value="25056">
<param name="BackColor" value="7895160">
<param name="EmbedDoc" value="0">
<param name="Src" value="Printers.dwf?NotifyMissingFonts = false">
<param name="ViewerParams" value="?NotifyMissingFonts = false">
</OBJECT>

<script language="vbscript">
<!--
; If multipage DWF's are used navigate to the page named "Level 8"
EView.Viewer.Page = "Level 8"
-->
</script>

<font face="Verdana" color="#FFFFFF" size="2">
<i>Click on the
<a title="Flash the printers" href="vbscript:ShowPrinters">printer</a> you want to have installed.
</i></font><br>
<font face="Verdana" size="1"><font color="#FFFFFF">Send mail to
<a href="mailto:HelpDesk%20IT?subject=Printer Connector">HelpDesk IT</a> or
the </font>
<a href="mailto:info@jtbworld.com?subject=Printer Connector">
Author</a><font color="#FFFFFF">
with questions or comments about Printer Connector.</font></font>
</body>

</html>

I recommend that you activate usage of single click to follow hyperlinks or include instructions to hold down CTRL + Click.

I hope you get the idea. Feel free to use it, have fun and impress on your management and users and IT. Feel free to contact me if you got any questions or post a comment.

9 comments:

  1. Restored comments

    Armando Marrero said...

    I tried to install printers using DWF example file but was unsuccessful
    Did the hyperlink to the network printer as mentioned (using the content for html file)
    Did hyperlink directly to network printer (\\network\printername)
    Nothing worked the hyperlink in the first case brings the htlm file and in the second
    Brings a blank outlook page
    What am I doing wrong?
    After I create the file with the content how I convert it to html, I tried doing a save as in word
    But did not work. Do I merge both files you show in the example or just the first file?
    Any help would be appreciated.

    Armando Marrero
    amarrero@csagroup.com
    June 09, 2006
    JTB World said...

    To create the html file you can use Notepad. That is probable the reason.
    July 04, 2006

    ReplyDelete
  2. I'm trying to install a printer using this method, but it is not working for me. The script runs great, but it does not actually install the printer. Do any special permissions need to be set?

    ReplyDelete
  3. Try to create a VBS file and run it and see if it works. If this works then it is something with the permissions on the HTML/web that needs to be resolved.

    ReplyDelete
  4. I was able to create a Facilities utility that installs printers, locate people etc.
    We have different locations in North, South and Central America, I’m wondering if it’s possible to add a real live clock that indicates the local time to a dwf file.
    We have a multy page DWF, one page per location that contains layout with people printer etc. I would like embed add a real live clock to each location that would indicate there local time. I could add the clocks hyperlink’s but it would be much better if it was embedded within the DWF.

    ReplyDelete
  5. Armando, I have no idea how to embed something like a live clock in a DWF. I doubt it is possible.

    ReplyDelete
  6. Hi,

    How did you insert hyperlink to the dwf file? I really need to know. Please help. What are the parameters _cx & _cy that you supplied??

    ReplyDelete
  7. The hyperlinks are created in AutoCAD in the DWG.
    As to the parameters I don't know.

    ReplyDelete
  8. Thanks Jimmy.

    Do you know something that could read a dfx file and convert it into image? I want to read a dxf file and display it in a web page. And then place some objects (hyperlinks) over the image at mouse click. Any help??? I can't get any way to display the dxf file over a web page. All help I get is for windows forms (.net). :(

    ReplyDelete
  9. There is probably some API around to convert DXF files to images otherwise you need to open it in AutoCAD and save/plot as image.

    ReplyDelete