We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

DWF to PDF generation resulting in error for a specific file

Dear Team,

I have a DWF file from our client for which PDF generation is failing.
I am using Aspose.CAD version 22.3 from Java family. I have attached that problematic file here.TESTDOC.zip (164 Bytes)

I get following error while conversion:

com.aspose.cad.cadexceptions.ImageLoadException: Image loading failed: Cannot read 19 bytes from the stream.
at com.aspose.cad.Image.a(Unknown Source) ~[aspose-cad-22.3.jar:22.3]
at com.aspose.cad.Image.load(Unknown Source) ~[aspose-cad-22.3.jar:22.3]
.
.

Could you please help me to resolve this issue?
Please find below my code:

.
try(Image cadImage = Image.load(file.getAbsolutePath())) {
// Create an instance of CadRasterizationOptions class
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(cadImage.getWidth());
rasterizationOptions.setPageHeight(cadImage.getHeight());
rasterizationOptions.setAutomaticLayoutsScaling(true);
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);

        rasterizationOptions.setNoScaling(false);
        // Set Graphics options
        rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
        rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
        rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);

        RasterizationQuality quality = new RasterizationQuality();
        quality.setTextThicknessNormalization(true);
        rasterizationOptions.setQuality(quality);
        // Create an instance of PDF options class
        PdfOptions pdfOptions = new PdfOptions();
        pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
        // Export to PDF by calling the Save method
        cadImage.save(pdfFile.getAbsolutePath(), pdfOptions);

.

Regards,
Aniket

@aniketvk,
Hello. This is not valid DWF file. It contains just “TEST DOC” text inside. It is not possible to open it as DWF.

Hello @Oleksii.Gorokhovatskyi

Sorry for rushing and sending this file without checking first.
Thanks for your reply.

Regards,
Aniket

1 Like