I’m converting a DWG to PDF, but I’m getting an exception.
class com.aspose.cad.cadexceptions.ImageLoadException: Drawing loading failed: ‘MS949’ is not a supported encoding —> class com.aspose.cad.internal.Exceptions.ArgumentException: ‘MS949’ is not a supported encoding
@hyunseop_shin
The exception you are encountering, class com.aspose.cad.cadexceptions.ImageLoadException: Drawing loading failed: 'MS949' is not a supported encoding
, indicates that the encoding ‘MS949’ is not supported by the Aspose.CAD library during the conversion process from DWG to PDF.
To resolve this issue, you can try the following steps:
-
Check Font Availability: Ensure that the fonts used in your DWG file are available on the machine where the conversion is taking place. If a specific font is missing, it can lead to encoding issues.
-
Substitute Fonts: If the required font is not available, you can substitute it with a different font that is supported. You can use the CadImage.Styles
property to access the styles in your CAD drawing and specify an available font name.
Here is a code snippet demonstrating how to change the font of all styles in a CAD drawing:
CadImage cadImage = (CadImage) Image.load("input.dwg");
CadStylesDictionary styles = cadImage.getStyles();
for (CadStyleTableObject style : styles) {
style.setPrimaryFontName("AvailableFontName"); // Replace with a valid font name
}
cadImage.save("output.pdf");
-
Use Supported Encodings: If your DWG file uses unsupported encodings, consider converting the file to a format that uses supported encodings before performing the conversion to PDF.
-
Update Aspose.CAD Library: Ensure that you are using the latest version of the Aspose.CAD library, as updates may include support for additional encodings or improvements in handling existing ones.
If the problem persists after trying these solutions, consider reaching out to Aspose support for further assistance.
Sources:
[1]: Convert Auto CAD Files to PDF JPEG PNG in C# .NET - Aspose Documentation
[2]: Converting CAD Drawings to PDF and Raster Image Formats
@hyunseop_shin,
Hi,
please attach the initial DWG file here so we can reproduce the problem.