List of Java API

Using CADViewer through the Java API

Methods and actions within CADViewer can be activated via the Java API. HTML code can be set up to trigger Java Script functions which in turn call the Java API to do actions in the viewer.
The latest version of the API is compiled via JavaScript, please use the following link.

Sample API subset to show Action Toolbar Functions:

Java APIDescriptions
ZoomIn()Zoom In
ZoomOut()Zoom Out
ZoomWindow()Zoom Window
ZoomRect()Zoom Window  Deprecated  Use ZoomWindow()
ZoomExtents()Zoom Extents
ZoomExtends()Zoom Extents   Deprecated  Use ZoomExtents()
ZoomInOut()Mouse up to zoom in and mouse down to zoom out
Pan()Pan
Print()Print
OpenFile()Open locally or remotely a new Drawing
OpenFile('demo.dwf')Open 'demo.dwf' file
CopyFile()Copy the current file to local disk
CopyFile(String scriptURL)Example : CopyFile('http://www.xyz/cgi-bin/saveDrawing.cgi?p1=v1&p2=v2&...&pn='). Copy the current drawing to server. CADViewer will fill the last parameter value with the content of the drawing. See open/save redline file for usages
RedlineSaveFile(String scriptURL, String layerName)Example: RedlineSaveFile('http://www.xyz/cgi-bin/saveDrawing.cgi?p1=v1&p2=v2&...&pn=','redlinelayer'). Save the redline as layer 'redlinelayer' with the drawing to the server. CADViewer will fill the last parameter value with the content of the drawingSee open/save redline file for usages
RedlineOpenFile()Open redline file. See open/save redline file for usages
RedlineOpenFile(String fileURL)Example: RedlineOpenFile('http://www.xyz/redlines/demo.red'). Open a redline file located on the server. See open/save redline file for usages
RedlineSaveFile()Save redline file to either local machine or server. See open/save redline file for usages
RedlineSaveFile(String fileName)Example : RedlineSaveFile('c:\temp\demo.red'). Save redline objects to a file on the local machine. See open/save redline file for usages
GetNamedView(String namedView)Display the named view
Measure()Turn on Measurement Feature
UrlOnOff()Turn URL links on/off
GetViews()Display all the named views
BWBackground()Display drawing in black and white
ShowLayers()Display the list of all layers
ShowAbout()Display viewer information and drawing information
GetPreviousScreen()Display the previous screen
GetNextScreen()Display the next screen
MultiplePrint()Print the drawing in the list
TextSearch()Search text on the drawing
ShowAbout()Show viewer and drawing information
RedlineSelect()Turn on redline tool to select redlines objects inside a rectangle created by click and drag
RedlineSelectObject()Turn on redline tool to select a redline by click on it
RedlineLine()Turn on redline tool to draw a line
RedlineRectangle()Turn on redline tool to draw a rectangle
RedlineCircle()Turn on redline tool to draw a circle
RedlineTriangle()Turn on redline tool to draw a triangle
RedlineEllipse()Turn on redline tool to draw an ellipse
RedlineHexagon()Turn on redline tool to draw a hexagon
RedlineCloud()Turn on redline tool to draw a cirlar cloud
RedlinePolyline()Turn on redline tool to draw a polyline
RedlinePolylineArrow()Turn on redline tool to draw a polyline with an arrow at either ends
RedlineFreehand()Turn on redline tool to enable a freehand draw
RedlineText()Turn on redline tool to draw a text string
RedlineHighlight()Turn on redline tool to draw a highlighted rectangle
RedlineThickness()Turn on redline tool to change line thickness
RedlineDelete()Turn on redline tool to delete a redline object
RedlineDeleteAll()Turn on redline tool to delete all redline objects
RedlineUndo()Turn on redline tool to undo redline
RedlineRedo()Turn on redline tool to redo redline
Rotate(String parameter)Valid parameter:90+,mirrorx,mirroy,reset

Example of Open file button



<html>
<form>
<input type=button value="Open File" OnClick="javascript:OpenFile()"<
</form>
<applet code="ViewerApplet.class" archive="obfu.jar"
name=cv width=100% height=100% MAYSCRIPT>
<param name="name" value="demo.dwf">

...
...
...
</applet>
<script language=javascript>
{
  function OpenFile()
  {
     document.applets[0].OpenFile();
  }

....
....
....
}
</script>
</html>

Example using API

demoAPI.html