Free Support Forum - aspose.com

Conversion of DXF to image shows no diameter sign

I try to convert a DXF file to an image which contains a diameter sign, which isn’t rendered properly (box is shown instead).

test-5668442-1.dxf.zip (383.1 KB)
(note: this is no real zip, I had to rename it for upload, just remove “.zip”)
test-5668442-1.dxf.png (44.3 KB)

In the PDF of your online converter the diameter is shown correctly, but if I’m converting to PDF it’s still a box.

test-5668442-1.dxf.pdf (141.8 KB)
test-5668442-1_output_online_converter.pdf (108.0 KB)

I thought, that I have to change the font maybe. So I tried to substitute the fonts as proposed in the developer guide (CadStyleTableObject.setPrimaryFontName()) but I can’t see any change.
How do I have to specify the font in the method - only the name like ‘Arial’ or with extension ‘Arial.ttf’?
Which are the available fonts or do I have to specify a setting in the Aspose/Java installation?

Is this the right approach for my problem anyway?

SOURCE

public static void main(String[] args) {
    String dataDir = getDataDir();
    String srcFile = dataDir + "test-5668442-1.dxf";

    // Load a CAD drawing in an instance of CadImage
    LOG.info("Loading file... ");
    try (CadImage image = (CadImage) Image.load(srcFile)) {

        // logging
        for (Object style : image.getStyles()) {
            CadStyleTableObject cadStyle = (CadStyleTableObject) style;
            LOG.info("image styles  " + cadStyle.getStyleName() + " -> " + cadStyle.getPrimaryFontName());
        }

        LOG.info("change primary font name");
        // Iterate over the items of CadStylesDictionary and set the font name
        for (Object style : image.getStyles()) {
            ((CadStyleTableObject) style).setPrimaryFontName("roman"); // also tried roman.ttf
        }

        // logging
        for (Object style : image.getStyles()) {
            CadStyleTableObject cadStyle = (CadStyleTableObject) style;
            LOG.info("image styles  " + cadStyle.getStyleName() + " -> " + cadStyle.getPrimaryFontName());
        }

        // Create an instance of CadRasterizationOptions
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
        rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
        rasterizationOptions.setPageHeight(2000);
        rasterizationOptions.setPageWidth(2000);

        // Export to PNG format
        PngOptions pngOptions = new PngOptions();
        pngOptions.setVectorRasterizationOptions(rasterizationOptions);
        image.save(srcFile + ".png", pngOptions);
    }

    LOG.info("...Finished");
}

LOGGING OUTPUT

2020-02-05 09:37:54,902 [main] INFO  test.cad.CadTest - Loading file... 
2020-02-05 09:37:57,779 [main] INFO  test.cad.CadTest - image styles  STANDARD -> monos.ttf
2020-02-05 09:37:57,779 [main] INFO  test.cad.CadTest - change primary font name
2020-02-05 09:37:57,779 [main] INFO  test.cad.CadTest - image styles  STANDARD -> roman
2020-02-05 09:38:09,014 [main] INFO  test.cad.CadTest - ...Finished

@marlov,

I have observed the issue shared by you. However, when I have tried to access the DXF zip archive, it seems to be damaged and I am unable to access that. Can you please ensure this on your end and share with us again.

see my note above: this is no real zip, I had to rename it for upload, just remove “.zip” extension

@marlov,

Thank you for the clarification. I have been able to observe the issue. An issue with ID CADNET-1020 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.