How to Split CAD Drawings into Tiles with GroupDocs Viewer

If you’re wondering how to split CAD files into smaller, more manageable pieces, you’ve come to the right place. In this tutorial we’ll walk through the exact steps needed to split large CAD drawings into tiles using GroupDocs Viewer for Java. By the end you’ll have a ready‑to‑use solution that improves rendering speed, reduces memory consumption, and makes it easier to display drawings in web or mobile applications.

Split CAD Drawings with GroupDocs.Viewer for Java

Quick Answers

  • What does “splitting CAD” achieve? It breaks a massive drawing into smaller images (tiles) that load faster and consume less memory.
  • Which format is used for the tiles? PNG files are generated by default, but other formats are supported via Viewer options.
  • Do I need a license? A free trial works for development; a paid license is required for production.
  • Can I change the tile size? Yes – adjust the tileWidth and tileHeight calculations to suit your needs.
  • Is this approach thread‑safe? Rendering each tile in its own Viewer instance with try‑with‑resources is safe for concurrent execution.

What is “how to split CAD”?

Splitting CAD refers to dividing a single, often huge, CAD drawing into multiple rectangular sections (tiles). Each tile is rendered independently, allowing you to load only the portions a user actually needs—perfect for web maps, document portals, and mobile viewers.

Why use GroupDocs Viewer for Java?

GroupDocs Viewer provides out‑of‑the‑box support for over 100 file formats, including DWG, DXF, and DWF. Its tile API lets you specify exact coordinates, so you can render exactly the area you care about without processing the whole file first. This saves CPU cycles, reduces bandwidth, and delivers a smoother user experience.

Prerequisites

  • Libraries: GroupDocs.Viewer for Java ≥ 25.2.
  • JDK: Any recent Java Development Kit (Java 8+).
  • IDE: IntelliJ IDEA, Eclipse, or another Java‑compatible IDE.
  • Build Tool: Maven (other build tools work as long as the dependency is added).

Setting Up GroupDocs.Viewer for Java

Add the GroupDocs repository and dependency to your pom.xml:

<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>

License Acquisition

GroupDocs.Viewer offers a free trial license for evaluation:

Basic Initialization

Create a simple Viewer instance to verify that the library loads correctly:

import com.groupdocs.viewer.Viewer;

public class ViewerSetup {
    public static void main(String[] args) {
        try (Viewer viewer = new Viewer("path/to/your/drawing.dwg")) {
            // Your rendering code goes here.
        }
    }
}

Step‑by‑Step Guide to Split CAD Drawings into Tiles

Step 1: Define the Output Directory

We’ll store each tile as a separate PNG file. Using a utility method keeps the path logic clean and reusable.

import java.nio.file.Path;

Path outputDirectory = Utils.getOutputDirectoryPath("SplitDrawingIntoTiles");
Path pageFilePathFormat = outputDirectory.resolve("page_{0}.png");

Step 2: Configure View Options

Set the rendering format to PNG and tell the viewer not to preload every page (which saves memory).

import com.groupdocs.viewer.options.PngViewOptions;
import com.groupdocs.viewer.options.ViewInfoOptions;

PngViewOptions viewOptions = new PngViewOptions(pageFilePathFormat);
ViewInfoOptions viewInfoOptions = ViewInfoOptions.forPngView(false);

Step 3: Calculate Tile Dimensions

First we obtain the drawing’s original width and height, then split it into four equal quadrants.

import com.groupdocs.viewer.results.ViewInfo;
import com.groupdocs.viewer.options.Tile;

ViewInfo viewInfo = new Viewer("path/to/your/drawing.dwg").getViewer().getViewInfo(viewInfoOptions);
int width = viewInfo.getPages().get(0).getWidth();
int height = viewInfo.getPages().get(0).getHeight();

// Each tile is a quarter of the total size.
int tileWidth = width / 2;
int tileHeight = height / 2;

Tile[] tiles = {
    new Tile(0, 0, tileWidth, tileHeight),
    new Tile(tileWidth, 0, tileWidth, tileHeight),
    new Tile(0, tileHeight, tileWidth, tileHeight),
    new Tile(tileWidth, tileHeight, tileWidth, tileHeight)
};

Step 4: Render and Save the Tiles

Add the calculated tiles to the rendering options and let the Viewer generate the PNG files.

viewOptions.getCadOptions().getTiles().addAll(java.util.Arrays.asList(tiles));

try (Viewer viewer = new Viewer("path/to/your/drawing.dwg")) {
    viewer.view(viewOptions);
}

Troubleshooting Tips

  • Build path – Ensure the GroupDocs JAR files are on the classpath.
  • Permissions – The output folder must be writable by the Java process.
  • Exceptions – If you see ViewerException, double‑check that the DWG file isn’t corrupted and that the correct license is applied.

Common Use Cases for Splitting CAD Tiles

  1. Web Mapping – Load only the visible portion of a floor plan as a user pans/zooms.
  2. Document Management – Store each tile separately for faster preview generation.
  3. Mobile Viewing – Reduce bandwidth by downloading just the tiles needed for the current screen.

Performance Considerations

  • Tile Size – Larger tiles mean fewer files but slower rendering; find a balance based on your UI needs.
  • Memory Monitoring – Use Java’s profiling tools (e.g., VisualVM) to watch heap usage when processing very large drawings.
  • Resource Cleanup – The try‑with‑resources pattern shown above automatically releases native resources.

Frequently Asked Questions

Q: Can I split other file types (PDF, images) into tiles using the same approach?
A: Yes. GroupDocs Viewer supports many formats; you just need to use the corresponding options class (e.g., PdfViewOptions).

Q: How do I change the output image quality?
A: Adjust viewOptions.setResolution(int dpi) or set compression settings on the PngOptions object.

Q: My application runs out of memory on very large DWG files—what can I do?
A: Reduce tile dimensions, increase the JVM heap (-Xmx), or render tiles sequentially in separate Viewer instances.

Q: Is it possible to render tiles asynchronously?
A: Absolutely. Wrap each tile rendering call in a CompletableFuture or use an executor service to parallelize the workload.

Q: Do I need a separate license for each tile?
A: No. A single valid GroupDocs Viewer license covers all rendering operations within your application.

Resources


Last Updated: 2026-04-01
Tested With: GroupDocs.Viewer 25.2 for Java
Author: GroupDocs