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


#1

I have a problem rendering the following file to PDF

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


#2

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


#3

@russ.nichols,

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


#4

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


#5

@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.


#6

I see in
https://docs.aspose.com/display/cadjava/Aspose.CAD+for+Java+19.5+-+Release+Notes
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?


#7

@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.


#8

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?


#9

@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.