Rendering OBJ files

Wavefront 3D Object Files (.obj) are 3D format images developed by Wavefront Technologies for the Advanced Visualizer (TAV) software. It contains text descriptions of vertexes, texture vertices and texture mapping (UV-position).

How to convert OBJ files

Convert OBJ to HTML

To convert OBJ files to HTML with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.obj")){
        HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("output.html");
//      options.setCadOptions(CadOptions.forRenderingByScaleFactor(0.7f)); // Render image and reduce it by 30%
//      options.setCadOptions(CadOptions.forRenderingByWidthAndHeight(400, 400)); // Render image and set output size to 400x400
//      options.setCadOptions(CadOptions.forRenderingByWidth(500)); // Render image, fix width by 500 px and recalculate height
//      options.setCadOptions(CadOptions.forRenderingByHeight(500)); // Render image, fix height by 500 px and recalculate width

        viewer.view(options);
    }

The following screenshot shows the output HTML file opened in a browser.

Convert OBJ to JPG

To convert OBJ files to JPG with GroupDocs.Viewer for Java use following code: 

    try (Viewer viewer = new Viewer("sample.obj")) {
        JpgViewOptions options = new JpgViewOptions("output.jpg");
//      options.setCadOptions(CadOptions.forRenderingByScaleFactor(0.7f)); // Render image and reduce it by 30%
//      options.setCadOptions(CadOptions.forRenderingByWidthAndHeight(400, 400)); // Render image and set output size to 400x400
//      options.setCadOptions(CadOptions.forRenderingByWidth(500)); // Render image, fix width by 500 px and recalculate height
//      options.setCadOptions(CadOptions.forRenderingByHeight(500)); // Render image, fix height by 500 px and recalculate width
    
        viewer.view(options);
    }

The following screenshot shows the output JPG file opened in a Windows Photo Viewer application.

Convert OBJ to PNG

To convert PLT/HPG files to PNG with GroupDocs.Viewer for Java use following code: 

    try (Viewer viewer = new Viewer("sample.obj")) {
        PngViewOptions options = new PngViewOptions("output.png");
//      options.setCadOptions(CadOptions.forRenderingByScaleFactor(0.7f)); // Render image and reduce it by 30%
//      options.setCadOptions(CadOptions.forRenderingByWidthAndHeight(400, 400)); // Render image and set output size to 400x400
//      options.setCadOptions(CadOptions.forRenderingByWidth(500)); // Render image, fix width by 500 px and recalculate height
//      options.setCadOptions(CadOptions.forRenderingByHeight(500)); // Render image, fix height by 500 px and recalculate width

        viewer.view(options);
    }

The following screenshot shows the output PNG file opened in a Windows Photo Viewer application.

Convert OBJ to PDF

To convert OBJ files to PDF with GroupDocs.Viewer for Java use following code: 

    try (Viewer viewer = new Viewer("sample.obj")) {
        PdfViewOptions options = new PdfViewOptions("output.pdf");
//      options.setCadOptions(CadOptions.forRenderingByScaleFactor(0.7f)); // Render image and reduce it by 30%
//      options.setCadOptions(CadOptions.forRenderingByWidthAndHeight(400, 400)); // Render image and set output size to 400x400
//      options.setCadOptions(CadOptions.forRenderingByWidth(500)); // Render image, fix width by 500 px and recalculate height
//      options.setCadOptions(CadOptions.forRenderingByHeight(500)); // Render image, fix height by 500 px and recalculate width

        viewer.view(options);
    }

The following screenshot shows the output PDF file opened in an Acrobat Reader.