When converting a DWG file to PDF, OLE and images were not exported correctly.
test_file.zip (79.1 KB)
When converting a DWG file to PDF, if OLE objects and images are not exporting correctly, it may be due to limitations in the conversion process. Here are several steps you can take to troubleshoot and potentially resolve the issue:
-
Check Layer Visibility: Ensure that the layers containing the OLE objects and images are visible in the DWG file before conversion.
-
Use Specific Layouts: If your DWG file has multiple layouts, specify the layout you want to export. You can do this by setting the
Layouts
property in theCadRasterizationOptions
. -
Adjust Rasterization Options: Make sure to set the
CadRasterizationOptions
correctly, including the page width and height, to ensure that all elements are captured during the export. -
Update Aspose.CAD: Ensure you are using the latest version of Aspose.CAD, as updates may include fixes for known issues related to OLE and image exports.
Here’s a sample code snippet to specify a layout and set rasterization options:
String srcFile = "path/to/your/file.dwg";
CadImage cadImage = (CadImage) Image.load(srcFile);
// Create rasterization options
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setLayouts(new String[] {"YourLayoutName"}); // Specify your layout
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
// Create PDF options
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
// Save to PDF
cadImage.save("output.pdf", pdfOptions);
If the issue persists, consider consulting the Aspose documentation or community forums for specific guidance on handling OLE objects and images in DWG files.
Hello,
we can confirm the issue unfortunately. We have created CADJAVA-12034 to investigate and fix it. It could be helpful if you attach the initial raster image in its original size and format for this DWG.
missingImage.png (23.6 KB)
Hello.
Thank you for your reply. Here are the pictures and DWG-related files.
I saw other articles saying that currently, OLE elements are not supported for export. Is that true?
test_file.zip (310.9 KB)
There are two separate issues here.
We have limited support for OLE: only for some types of images as embedded OLE entities. For this particular case we have support and I can see OLE image after export of the first initial file with Aspose.CAD for .NET 25.9. So we will inspect what is wrong now in Java product and fix it there.
The situation is different with raster image. We can not see directly what is wrong with first file but we guess there was a raster file in indexed colors that caused error in export internally. So we need to verify this and that’s why I asked for the initial file - we wanted to preserve your first DWG file without changes as now it is set up to refer that original (probably indexed) image in its size.
Your latest example uses another file, the export seems to be fine with Aspose.CAD for Java 25.9, please find the attached result.
test_file2.dwg_java_.pdf (207.7 KB)
@oleksii.gorokhovatskyi ,
Ok. This is the source file.
The version of aspose.cad I’m using is 25.7. Currently, I still can’t export the pictures.
test_file.zip (111.0 KB)
@xhhhhhh,
Thank you for all details. I can export the latest file with image using Aspose.CAD for Java 25.7, please see resut attached. Please note that the raster image entity in DWG refers to image by path ..\..\Snipaste_2025-09-17_16-02-12.png
, so you need to have image file in correct place.
test_file.dwg_java_.pdf (81.4 KB)
@oleksii.gorokhovatskyi ,
Thank you for your explanation. At present, it seems that only the issue of the OLE element remains.