Issue rendering DXF file to PDF - Issue setting custom font?

I have a problem rendering the following file to PDF
https://www.dropbox.com/s/08tl1cmskkrlyrb/native-cad-foreign-language.DXF?dl=0

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 also enclose a copy of the font file
https://www.dropbox.com/s/klcm8e8m30kkakc/ARIALUNI.TTF?dl=0

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

@russ.nichols,

Can you please share generated result along with environment detail so that we may further investigate to help you out.

This is the output file:

As you can see on the bottom left, asian text is not correctly displayed, but you can
instead see invalid characters

I am running this code on an AWS lambda image running Amazon Linux

@russ.nichols,

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 see in

that CADJAVA-467 has been 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?

@russ.nichols,

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

: CadImage cadImage = (CadImage) Image.load(path+“native-cad-foreign-language.dxf”);

you should write:

CadImage cadImage = (CadImage)Image.Load(path+“native-cad-foreign-language.dxf”, new LoadOptions() { SpecifiedEncoding = CodePages.Japanese }))

Please share feedback with us if there is still an issue.

Hello,

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?

@russ.nichols,

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.

Hello I wanted to ask if there are any updates on this fix … sounds like on the related CADNET-810 ticket

@PeteLee,

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.

Hi, I wanted to know what the java ticket is that tracks CADNET-810 and whether it was released in java’s 20.1 release.

I tried finding this CADNET ticket in Aspose.CAD for .NET 20.1 - Release Notes, but I didn’t see it, so I’m wondering if it was even released in 20.1.

Thanks.

@PeteLee,

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.

@PeteLee,

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.

The issues you have found earlier (filed as CADNET-810) have been fixed in this update.