groupdocs viewer dwg – Java में GroupDocs.Viewer का उपयोग करके विशिष्ट CAD ड्रॉइंग्स को रेंडर कैसे करें

Rendering specific layouts from a DWG file is a common requirement when you need to focus on a single design view, generate lightweight HTML previews, or embed a particular drawing layer into a web page. In this tutorial you’ll discover how GroupDocs.Viewer for Java makes it straightforward to render a chosen layout, convert CAD to HTML, and extract layout DWG with just a few lines of code.

GroupDocs.Viewer for Java के साथ विशिष्ट CAD ड्रॉइंग्स रेंडर करें

त्वरित उत्तर

  • DWG को HTML में रेंडर करने वाली लाइब्रेरी कौन सी है? GroupDocs.Viewer for Java.
  • क्या मैं DWG से केवल एक लेआउट रेंडर कर सकता हूँ? हाँ – HtmlViewOptions में लेआउट नाम निर्दिष्ट करें।
  • क्या विकास के लिए लाइसेंस चाहिए? परीक्षण के लिए एक मुफ्त ट्रायल काम करता है; उत्पादन के लिए स्थायी लाइसेंस आवश्यक है।
  • कौन सा Java संस्करण आवश्यक है? JDK 8 या बाद का।
  • क्या बड़े CAD फ़ाइलों में मेमोरी उपयोग समस्या है? स्ट्रीमिंग विकल्प उपयोग करें और Viewer इंस्टेंस को तुरंत बंद करें।

groupdocs viewer dwg क्या है?

GroupDocs.Viewer is a Java library that converts over 50 document and CAD formats—including DWG—into web‑friendly representations such as HTML, PNG, or JPEG. It processes files without requiring native CAD software, delivering consistent rendering across platforms.

DWG रेंडरिंग के लिए GroupDocs.Viewer क्यों उपयोग करें?

GroupDocs.Viewer supports 50+ CAD input formats and can render multi‑hundred‑page drawings while keeping memory consumption under 200 MB by streaming pages on demand. Its built‑in layout extraction lets you isolate a single view, which reduces page load time by up to 70 % compared with rendering the entire drawing.

आवश्यकताएँ

  • GroupDocs.Viewer for Java ≥ 25.2.
  • निर्भरता प्रबंधन के लिए Maven।
  • स्थानीय रूप से स्थापित JDK 8+।
  • DWG फ़ाइल संरचना (लेआउट्स, मॉडल स्पेस, पेपर स्पेस) की बुनियादी जानकारी।

DWG फ़ाइल से विशिष्ट लेआउट कैसे रेंडर करें?

Load the desired DWG file, configure the HTML rendering options, and specify the layout you want to output. By setting the layout name in HtmlViewOptions, the viewer extracts only that view and generates the corresponding HTML files. This approach simplifies preview generation and reduces processing time, and the entire workflow consists of three concise steps.

चरण 1: आउटपुट डायरेक्टरी परिभाषित करें

Create a folder where the generated HTML files will be saved.

Utils हेल्पर रेंडर की गई फ़ाइलों के लिए प्लेटफ़ॉर्म‑स्वतंत्र आउटपुट फ़ोल्डर बनाता है।

<repositories>
   <repository>
      <id>repository.groupdocs.com</id>
      <name>GroupDocs Repository</name>
      <url>https://releases.groupdocs.com/viewer/java/</url>
   </repository>
</repositories>
<dependencies>
   <dependency>
      <groupId>com.groupdocs</groupId>
      <artifactId>groupdocs-viewer</artifactId>
      <version>25.2</version>
   </dependency>
</dependencies>

व्याख्या: Utils.getOutputDirectoryPath प्लेटफ़ॉर्म‑स्वतंत्र पाथ बनाता है और यदि फ़ोल्डर मौजूद नहीं है तो उसे बनाता है।

चरण 2: रेंडर किए गए पृष्ठों के लिए नामकरण सेट करें

Path outputDirectory = Utils.getOutputDirectoryPath("YOUR_OUTPUT_DIRECTORY");

व्याख्या: {0} पृष्ठ सूचकांक से बदल दिया जाता है, जिससे आप फ़ाइलनाम टकराव के बिना कई लेआउट रेंडर कर सकते हैं।

चरण 3: HtmlViewOptions कॉन्फ़िगर करें

Tell the viewer to embed resources and to target a single layout.

Path pageFilePathFormat = outputDirectory.resolve("page_{0}.html");

व्याख्या: forEmbeddedResources इमेज और CSS को सीधे HTML में पैक करता है, जिससे प्रत्येक लेआउट के लिए एक पोर्टेबल फ़ाइल बनती है।

चरण 4: वह लेआउट चुनें जिसे आप रेंडर करना चाहते हैं

Provide the exact layout name as it appears inside the DWG file.

HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);

व्याख्या: layoutName को "Model" (या कोई भी कस्टम लेआउट) पर सेट करने से GroupDocs.Viewer अन्य सभी व्यूज़ को अनदेखा करता है।

चरण 5: लेआउट रेंडर करें और साफ़ करें

Open the viewer in a try‑with‑resources block, invoke view, and let Java close the instance automatically.

Viewer क्लास GroupDocs.Viewer के साथ दस्तावेज़ रेंडर करने का मुख्य प्रवेश बिंदु है।

viewOptions.getCadOptions().setLayoutName("Model");

व्याख्या: view कॉल चयनित लेआउट को आउटपुट फ़ोल्डर में HTML फ़ाइलों में स्ट्रीम करता है; रेंडरिंग के तुरंत बाद Viewer को डिस्पोज़ कर दिया जाता है।

सामान्य समस्याएँ और समाधान

  • लेआउट नहीं मिला – DWG को CAD एडिटर में खोलकर लेआउट नाम सत्यापित करें; वर्तनी और केस बिल्कुल मिलना चाहिए।
  • मेमोरी समाप्ति त्रुटियाँViewer.setMemoryLimit सक्षम करें या फ़ाइल को छोटे हिस्सों में प्रोसेस करें।
  • इमेज गायब – सुनिश्चित करें कि forEmbeddedResources सेट है; अन्यथा बाहरी इमेज फ़ाइलें अलग से उत्पन्न हो सकती हैं।

अक्सर पूछे जाने वाले प्रश्न

Q: GroupDocs.Viewer for Java क्या है?
A: यह एक सर्वर‑साइड लाइब्रेरी है जो 50 से अधिक दस्तावेज़ और CAD फ़ॉर्मैट्स—जिसमें DWG भी शामिल है—को HTML, PNG, या JPEG में बदलती है, बिना स्थापित Office या CAD सॉफ़्टवेयर की आवश्यकता के।

Q: GroupDocs.Viewer के लिए अस्थायी लाइसेंस कैसे प्राप्त करूँ?
A: GroupDocs’ purchase page पर जाएँ और विकास एवं परीक्षण के लिए एक मुफ्त अस्थायी लाइसेंस का अनुरोध करें।

Q: क्या GroupDocs.Viewer बहुत बड़े DWG फ़ाइलों को कुशलता से संभाल सकता है?
A: हाँ, यह पृष्ठों को स्ट्रीम करता है और कई सौ पृष्ठों वाले ड्रॉइंग्स को रेंडर कर सकता है जबकि मेमोरी उपयोग 200 MB से कम रखता है, बशर्ते आप प्रत्येक ऑपरेशन के बाद Viewer इंस्टेंस को बंद करें।

Q: क्या DWG लेआउट को सीधे PDF में बदलना संभव है, न कि HTML में?
A: बिल्कुल – HtmlViewOptions को PdfViewOptions से बदलें और वही लेआउट नाम निर्दिष्ट करें ताकि PDF आउटपुट प्राप्त हो सके।

Q: लेआउट एक्सट्रैक्शन के अधिक उदाहरण कहाँ मिल सकते हैं?
A: आधिकारिक दस्तावेज़ीकरण और API रेफ़रेंस में बैच प्रोसेसिंग और कस्टम रेंडरिंग पाइपलाइन के लिए अतिरिक्त कोड स्निपेट्स शामिल हैं।

व्यावहारिक अनुप्रयोग

  1. आर्किटेक्चरल प्रस्तुतियाँ – क्लाइंट मीटिंग के लिए आवश्यक फ़्लोर‑प्लान लेआउट ही दिखाएँ।
  2. मैन्युफैक्चरिंग रिव्यूज़ – पूर्ण असेंबली लोड किए बिना टॉलरेंस पर चर्चा करने के लिए एक कंपोनेंट व्यू को अलग करें।
  3. ई‑लर्निंग मॉड्यूल – स्पष्ट निर्देश के लिए वेब‑आधारित ट्यूटोरियल में एकल CAD व्यू एम्बेड करें।
  4. डॉक्यूमेंट मैनेजमेंट इंटीग्रेशन – DWG फ़ाइलों को कंटेंट रिपॉज़िटरी में अपलोड करते समय लेआउट‑विशिष्ट प्रीव्यूज़ को स्वचालित रूप से एक्सट्रैक्ट करें।
  5. कस्टम रिपोर्टिंग – एकल ड्रॉइंग व्यू पर केंद्रित HTML रिपोर्ट बनाएं, जिससे फ़ाइल आकार और लोड समय कम हो।

प्रदर्शन टिप्स

  • Viewer इंस्टेंस को पुन: उपयोग करें कई फ़ाइलों के लिए जब संभव हो; यह आंतरिक संसाधनों को कैश करता है और बाद के रेंडर को तेज़ बनाता है।
  • स्ट्रीमिंग सक्षम करें Viewer.setRenderMode(RenderMode.Stream) कॉल करके ताकि मेमोरी फुटप्रिंट कम रहे।
  • आउटपुट HTML को gzip के साथ वेब सर्वर पर संपीड़ित करें ताकि क्लाइंट‑साइड लोड समय और बेहतर हो।

निष्कर्ष

You now have a complete, production‑ready approach for rendering a specific layout from a DWG file using GroupDocs.Viewer for Java. By targeting a single layout you reduce rendering time, lower memory consumption, and produce clean HTML that can be embedded anywhere—from web portals to internal dashboards.

अगले कदम

  • विभिन्न लेआउट नाम जैसे "Top View" या "Section A" रेंडर करके देखें कि आउटपुट कैसे बदलता है।
  • यदि आपको उसी लेआउट का PDF संस्करण चाहिए तो PdfViewOptions का अन्वेषण करें।
  • इस तकनीक को GroupDocs.Annotation के साथ मिलाकर रेंडर किए गए HTML में वॉटरमार्क या टिप्पणी जोड़ें।

Last Updated: 2026-06-20
Tested With: GroupDocs.Viewer for Java 25.2
Author: GroupDocs

संसाधन

try (Viewer viewer = new Viewer(TestFiles.SAMPLE_DWG_WITH_LAYOUTS_AND_LAYERS)) {
    viewer.view(viewOptions);
}

संबंधित ट्यूटोरियल