We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

[Java] Converting DWG byte[] to PDF

Is it possible to convert a byte[] (byte array) DWG content to PDF?

The examples only shows the Image.load method using a String path to the file. I saw there is a Image.load that receives a InputStream, but I got a error when I used it.


Aspose.CAD offers to load DWG from stream. You can convert byte array to Memory stream and load that using Aspose.CAD.

 Stream stream = new MemoryStream(byteArray);
            using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(memoryStream))
                var pdfOptions = new PdfOptions();
                var dwfRasterizationOptions = new CadRasterizationOptions();
                pdfOptions.VectorRasterizationOptions = dwfRasterizationOptions;
                dwfRasterizationOptions.CenterDrawing = true;
                dwfRasterizationOptions.PageHeight = 500;
                dwfRasterizationOptions.PageWidth = 500;
                dwfRasterizationOptions.Layouts = new string[] { "Model" };
                // export
                string outPath = fileName + ".pdf";
                image.Save(outPath, pdfOptions);

Thanks. It works.