Nextcloud CAD Viewer
A native Nextcloud app providing DWG and DXF file viewing capabilities based on mlightcad/cad-viewer. View your CAD drawings directly in Nextcloud without downloading or installing additional software.
๐ธ Screenshots
โจ Features
- ๐จ View DWG and DXF files directly in Nextcloud web interface
- ๐๏ธ Start page with your recent drawings and a blank drawing shortcut
- โก Fast, browser-based rendering using WebGL technology
- ๐ Interactive controls: Zoom, pan, and fit-to-view
- ๐ Layer management: Toggle layer visibility on/off
- ๐ Theme support: Dark and light mode options
- ๐ฅ๏ธ Fullscreen mode for detailed viewing
- ๐ฑ Responsive design that works on desktop and mobile
- ๐พ Save and exit from the viewer toolbar (DXF files)
- ๐ Secure integration with Nextcloud's file permissions
- ๐ผ๏ธ Preview thumbnails in the Files app for drawings you have opened
- ๐ Easy updates from upstream cad-viewer
- ๐งช Fully tested and compatible with Nextcloud 34-35
๐ Requirements
| Component | Version |
|---|---|
| Nextcloud | 34-35 |
| PHP | 8.4+ |
| Node.js | 24+ (dev. only) |
| pnpm | 10+ (dev. only) |
๐ฆ Installation
CAD Viewer is listed in the Nextcloud App Store. Install it from the release archive or from source as described below.
From a release archive
- Download the latest
cad_viewer.tar.gzfrom the releases page. - Extract it into your Nextcloud
appsdirectory:The archive already contains the built frontend assets, so no Node.js/pnpm step is needed.tar -xzf cad_viewer.tar.gz -C /path/to/nextcloud/apps chown -R www-data:www-data /path/to/nextcloud/apps/cad_viewer - Enable the app:
The DWG/DXF MIME types are registered automatically on install; the app re-detects existing CAD files, so no manual
occ app:enable cad_viewerconfig/mimetypemapping.jsonedit is required.
From source
-
Clone this repository into your Nextcloud
appsdirectory:cd /path/to/nextcloud/apps git clone https://github.com/ashcoft/nextcloud-cad-viewer.git cad_viewer -
Set proper permissions:
chown -R www-data:www-data cad_viewer -
Build the frontend assets:
cd cad_viewer pnpm install pnpm run build -
Enable the app:
occ app:enable cad_viewerOr go to Settings โ Apps, find "CAD Viewer" in the disabled apps section and click Enable.
Enabling the app registers the
.dwg/.dxfMIME types and re-detects files uploaded before the app was installed. If you need to re-run this manually:occ maintenance:repair --include-expensive
๐ Usage
Once installed, the CAD Viewer integrates seamlessly with Nextcloud:
- Navigate to any DWG or DXF file in your Nextcloud files
- Click the file, or right-click it and choose Open with CAD Viewer
- The drawing opens in the CAD Viewer
- Use the toolbar controls to:
- Zoom in/out
- Pan around the drawing
- Fit the drawing to view
- Toggle layers
- Switch between dark/light themes
- Enter fullscreen mode
Opening CAD Viewer from the Nextcloud app menu shows a start page with the drawings you worked on recently. From there you can reopen one of them or create a blank drawing: the app saves a new, empty DXF file in your home folder and opens it in the viewer.
Note: The app opens CAD drawings in its own full-page viewer rather than in the Nextcloud Viewer. The bundled Nextcloud Viewer is a Vue 2 application and cannot render the Vue 3 CAD component, so the file action navigates to
/apps/cad_viewer/viewinstead.
Supported File Formats
| Format | Extension | MIME Types |
|---|---|---|
| AutoCAD DWG | .dwg | application/acad, application/autocad_dwg, application/dwg, application/x-autocad, application/x-dwg, image/vnd.dwg |
| AutoCAD DXF | .dxf | image/vnd.dxf, application/dxf, application/x-dxf, image/x-dxf |
Saving Changes
The viewer toolbar has Save and Exit buttons. Save serialises the drawing back to its file, then Exit returns to the folder it came from.
Saving is limited to DXF: the bundled LibreDWG converter can read DWG but has no encoder, so a DWG is left read-only and the Save button is hidden. The server also refuses a save when the file changed since it was loaded, so an older browser tab cannot overwrite a newer version.
Preview Thumbnails
CAD rendering needs WebGL, so a preview cannot be produced server-side. Instead the viewer captures the rendered drawing after it finishes opening, uploads the PNG, and the app serves it back to the Files grid. Thumbnails therefore appear only for drawings that have been opened at least once; before that the generic file icon is shown.
Only users who can modify a file may set its thumbnail, and an upload is rejected when the drawing changed after it was downloaded, so the preview always matches the current version. Thumbnails are stored under the app's data directory (not in the user's files) and are removed when the drawing is deleted.
๐ ๏ธ Development
Prerequisites
- Node.js 24+
- pnpm 10+
- Nextcloud 34 development environment
- PHP 8.4+
Setup Development Environment
# Clone the repository
git clone https://github.com/ashcoft/nextcloud-cad-viewer.git
cd nextcloud-cad-viewer
# Install dependencies
pnpm installBuild Commands
# Development build with watch mode
pnpm run dev
# Production build
pnpm run build
# Type-check Vue + TypeScript sources
pnpm run check-types
# Run linter
pnpm run lint
# Fix linting issues
pnpm run lint -- --fix
# Run stylelint
pnpm run stylelint
# Run frontend (Jest) tests
pnpm test
# Run backend (PHPUnit) tests
composer test:unitThe Makefile wraps the common flows:
make dev-setup # clean, install and build the production bundle
make production-setup # clean, install and build for production
make appstore # build the installable tar.gz/zip archives
make test # run PHPUnit and Jest suites
make lint # run PHP and frontend linters๐ Updating CAD Viewer
When new versions of mlightcad/cad-viewer are released:
-
Update the dependency:
pnpm update @mlightcad/cad-viewer -
Rebuild the application:
pnpm run build -
Test thoroughly with various DWG/DXF files
-
Commit and push changes:
git add package.json pnpm-lock.yaml git commit -m "Update cad-viewer dependency" git push
The pinned @mlightcad versions and compatibility overrides live in
pnpm-workspace.yaml; review them when bumping the viewer. Note that the CAD
viewer library is bundled at build time, so a rebuild and redeploy is required
for changes to take effect.
โ๏ธ Configuration
The app works out of the box. Administrators can additionally tune the viewer under Settings โ Administration โ CAD Viewer:
| Setting | Options | Default | Description |
|---|---|---|---|
| Theme | Light / Dark | Light | Theme the viewer opens a drawing with |
| Enable file previews | Yes / No | Yes | Generate and store CAD file previews |
Both settings are app-wide. Turning previews off stops new thumbnails being stored: the viewer still renders and uploads one, but the server refuses it with a 403. Existing thumbnails stay on disk and are simply not served, so they remain until their drawing is deleted.
Autosave is not configurable: the viewer edits in memory and writes only when you press Save in its toolbar, so there is nothing to schedule.
๐ Troubleshooting
Files Not Displaying
- Verify the CAD Viewer app is enabled in Nextcloud
- Check that the file is a supported format (DWG or DXF)
- Confirm the MIME types are registered โ for manual installs see Register the DWG/DXF MIME types above. Files showing a generic icon or no Open with CAD Viewer action usually mean the mapping is missing.
- Ensure you have read permissions for the file
- Check the browser console for JavaScript errors
- Review Nextcloud logs at
nextcloud/data/nextcloud.log
Performance Issues with Large Files
- Ensure your server has sufficient RAM and CPU resources
- Consider enabling browser hardware acceleration
- For very large files, consider optimizing the DWG/DXF in AutoCAD
- Check network bandwidth between client and server
Build Errors
-
Clear node_modules and reinstall:
rm -rf node_modules pnpm install -
Ensure you're using Node.js 24+
-
Check that all dependencies are properly installed
Common Issues
| Issue | Solution |
|---|---|
| Blank viewer | Check browser console for errors, verify file permissions |
| "Open with CAD Viewer" missing | Register the DWG/DXF MIME types (see Installation) |
| Slow loading | Optimize CAD file, check server resources |
| Missing layers | Ensure CAD file layers are not frozen in source application |
| Mobile display issues | Use landscape orientation for better viewing |
๐งช Testing
Run the frontend and backend suites:
pnpm test # Jest (frontend)
composer test:unit # PHPUnit (backend)Static analysis and linting:
pnpm run check-types # vue-tsc
pnpm run lint # ESLint
pnpm run stylelint # Stylelint
composer psalm # Psalm
composer phpstan # PHPStanFor compatibility testing procedures, see COMPATIBILITY.md.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Bundled third-party components keep their own licenses, which are listed in
THIRD-PARTY-NOTICES.txt. In particular the bundled
@nextcloud/files library is AGPL-3.0-or-later (its license text ships as
COPYING.txt); that is compatible with this app's MIT license.
๐ค Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run linters and tests (
pnpm run lint && pnpm test) - Build the production assets (
pnpm run build) - Commit your changes using conventional commit messages (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please read CONTRIBUTING.md for detailed guidelines, and
AI_POLICY.md if you use AI assistance: a pull request containing
AI-assisted code, documentation or tests must disclose that, and each commit
containing AI-assisted content must carry an
Assisted-by: AGENT_NAME:MODEL_VERSION trailer.
๐ Support
- Issues & Bug Reports: GitHub Issues
- Documentation: GitHub Wiki
- Discussions: GitHub Discussions
๐ Credits
- Built with mlightcad/cad-viewer by MLightCAD
- Powered by Vue.js
- Integrated with Nextcloud
- Thanks to all contributors and the Nextcloud community
๐ Changelog
See CHANGELOG.md for version history and changes.
๐ Links
- GitHub Repository: https://github.com/ashcoft/nextcloud-cad-viewer
- Releases: https://github.com/ashcoft/nextcloud-cad-viewer/releases
- CAD Viewer (upstream): https://github.com/mlightcad/cad-viewer
- MLightCAD: https://github.com/mlightcad