pt Edition | Original: English
Switch to English →
• By Will

HTML 5 integration procedures for DWGs display on Web

1.The CAD drawing displayed in the web browser is actually ocf file generated from CAD drawing, the ocf file needs to be sent to the front end, so H5 version control can analyze and display the ocf file. 2.Supported browsers: mainstream browsers such as Chrome, Firefox, Edge, 360, QQ, etc. IE browser is not supported. 3.Sample codes must be deployed in the server, local html cannot upload or display ocf file, please refer to the codes in the “Sample codes”folder. 4.The first step is to initialize the display control  

Property

Type

Required

Description

wrapid

String

true

Drawing container DOM ID(Width and Height are needed to set container)

language

String

false

Language Settings,available options 'zh'(Simplified Chinese)/'en'(English)/'ko'(Korean),default 'zh

apiHost

String

false

API domain name, requests need to be sent to this domain name if Convert to PDF and Save As function are needed

toolbarHideItems

Object

false

Set menu items to be hidden

 

 

 

  5.The second step is to open default CAD drawing ocf file, arraybuffer is binary system data of ocf file, the render function can render and display ocf file.  

Property

Type

Required

Description

type

string

true

type of rendered data, only “ocf”is currently supported

bufferData

arraybuffer

true

arraybuffer format binary system data object

fileId

String

true

Unique identifier for the current drawing, pdf conversion and version conversion will need this parameter

defaultViewport

Boolean

false

default false:Viewport is full drawing when opening the drawing; true: the default viewport when saving the drawing

  6.Clicking the layout function from front end and switching to other layout will trigger layout switch event, with obj.globalName, we get layout name, If the back end return all ocf files corresponding to layout, we can directly get corresponding ocf with layout name. If only the ocf of default layout is returned, after switching the layout, please refer to the annotated codes below, send requests to back end and wait for the back end to return ocf file link of the current layout.