This is the output file:
s3://csdisco-devteam/test_sources/cad/native-cad-foreign-language.DXF/6a1f3641-0f21-4667-a2a7-fff2ccbad2ee.pdf
I am guessing I need to use a custom font, which I am trying using Arial Unicode MS
in the code below.
String tempFileName = FileUtilities.getTempFile( ".pdf");
// Create an instance of CadRasterizationOptions class
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageHeight(1600);
rasterizationOptions.setPageWidth(1600);
// Set the Entities type property to Entities3D.
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
rasterizationOptions.setAutomaticLayoutsScaling(true);
rasterizationOptions.setNoScaling(false);
rasterizationOptions.setContentAsBitmap(true);
// Set Layouts
rasterizationOptions.setLayouts(new String[] { "Model" });
// Set Graphics options
rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);
// Create an instance of CadRasterizationOptions and set its various properties
rasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getWhite());
// Iterate over the items of CadStyleDictionary
for (CadStyleTableObject style : (Iterable<CadStyleTableObject>)image.getStyles())
{
// Set the font name
style.setPrimaryFontName( "Arial Unicode MS");
}
// Create an instance of PDF options class
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
image.save(tempFileName, pdfOptions);
I guess what might be missing is an API to specify a custom folder where to load the fonts from
like the one other Aspose Products (Words, Slides, etc…) provide
I have worked with the file shared by you and have been able to observe the issue specified. An issue with ID CADJAVA-467 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.
I tried with the new version and got the same results.
I suspect I might have to load the document using some special options to maybe pass
the location of a font file, like I do for other Aspose products … I also see in the release notes
that some font API have been added.
Do you know how to load the referenced file and obtain the correct PDF?
I have observed your comments. I like to inform that for correct rendering of Asian characters, you have to specify codepage on image loading. For the attached sample you have to specify Japanese codepage.
instead of using following code snippet
I can see that by specifying the Japanese code-page, I get the correct PDF for this input file, but I do not know the image code-page in advance. We process arbitrary CAD files. Is there a way to determine which code-page parameter I should pass?
I have observed your comments and regret to inform that it is not possible right now. But it is in progress and we will implement this soon. For reference i have linked this thread with ticket CADNET-810 so that you may be notified when this feature will be available.
I have verified the issue status from our issue tracking system and like to share that the issue has been marked as resolved and its fix is likely to be included in upcoming Aspose.CAD for .NET 20.1. We will share updates with you as soon as the product will be made available online.
I like to share that the concerned ticket was resolved in previous release. However, we were unable to include that in release notes. You may try using latest version to date and it will work. From our side, we are going to include the notification of this issue in upcoming version with example too.
We have now made codepage detection automatic for DWG and DXF. However, it is possible to override it:
using (CadImage cadImage = (CadImage)Image.Load(GetPath(fileName), new LoadOptions() { SpecifiedEncoding = CodePages.Japanese,
SpecifiedMifEncoding =
MifCodePages.Japanese,
RecoverMalformedCifMif = false}))
{
//do export or something else with cadImage
}
SpecifiedEncoding sets encoding used to read text data from non-Unicode DXF and DWG formats. By default, it is auto-detected.
SpecifiedMifEncoding sets encoding used to read MIF-encoded symobls of CJK encodings (M+nXXXX format). By default, it is auto-detected.
RecoverMalformedCifMif defines whether CIF (U+XXXX) and MIF-encoded characters will be decoded if they do not have proper AutoCAD formatting (AutoCAD precedes these symbols with backslash). By default, they are decoded.