Using freewheel.labs.autodesk.com to auto generate preview images of DWF files on your web site
Posted on 2010-06-06 18:04 kingwangzhen 阅读(330) 评论(0) 编辑 收藏 举报http://dwf.blogs.com/beyond_the_paper/2006/09/using_dwfitcom_.html
Problem:
You have a web page containing many links to DWF files and you want to create thumbnail images for each file listed but you don’t want to open each DWF file and generate preview images manually. That could be quite time consuming. Also, you want your users to view your DWF files on Mac or Windows without your users installing any software, so they can simply click and view.
Solution:
Software Engineer and Evangelist, Brian Pene, notes that you can use freewheel.labs.autodesk.com DWF-to-PNG [dwfImage.aspx ] and Interactive DWF Viewing web service [dwf.aspx]!
Example - prefixing your <img> src tag attribute with dwfImage.aspx service and your <a> href tag attribute to use the dwf.aspx service.
We will use this following DWF file for our example: http://freewheel.labs.autodesk.com/sample/Hotel5.dwf
Using the DWF to PNG Rendering service [ http://freewheel.labs.autodesk.com/dwfImage.aspx ], the following URL will render a PNG small enough to fit on most cell phone screens. It will view the center of page 1 of the Hotel5.dwf zoomed in to a factor of 1 and generate a PNG image that is 200x200 pixels:
Below is an explanation of the parameters (in red) accepted by the DWF-to-PNG web service:
- &cx=<float> A number from 0.0 to 1.0 for the view's Center in X.
- &cy=<float> A number from 0.0 to 1.0 for the view's Center in Y.
- &scale=<float> A number in the range 1.0 to 16384.0 for the view's Scale.
- &page=<integer> An integer from 1 to "N" for the page number to view.
- &width=<integer> The horizontal size of the PNG to produce (in pixels).
- &height=<integer> The vertical size of the PNG to produce (in pixels).
- &path=<URL> An URL path to a DWF to be viewed.
If you set the url string above as the src attribute of an image tag like so:
<img src=”http://freewheel.labs.autodesk.com/dwfImage.aspx?cx=0.5&cy=0.5&scale=1&page=1&width=200&height=200&
path=http://freewheel.labs.autodesk.com/sample/Hotel5.dwf” width=”200” height=”200” border=”1”>This will result in the following image.
Using the same DWF file url, we can also prefix the href attribute of the <a> tag so we use the dwf viewing web service and then set the path= parameter to be that of the DWF file we want to view:
<a href="http://freewheel.labs.autodesk.com/dwf.aspx?path=http://freewheel.labs.autodesk.com/sample/Hotel5.dwf">[image tag here]</a>
If we set this around our image tag above, we get the following result (click the image to view the file without installing any software!):
Thanks for the info Brian!
For the latest information on Project Freewheel, see Scott Sheppard's It's Alive in the Lab blog.