Convert DXF file into PDF using Aspose.CAD for .NET

    License license = new License();
    license.SetLicense(HttpContext.Current.Server.MapPath("/Aspose.CAD.lic"));

    using (CadImage cadImage = (CadImage) Image.Load(CadFile))
    {
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions
        {
            Layouts = new string[] {"Model"},
            PageWidth = (float) (isA3 ? 420 : 297),
            PageHeight = (float) (isA3 ? 297 : 210),
            UnitType = UnitType.Millimeter,
            AutomaticLayoutsScaling = true,
            PageSize = new SizeF(isA3 ? 420 : 297, isA3 ? 297 : 210)
        };

        PdfOptions pdfOptions = new PdfOptions
        {
            VectorRasterizationOptions = rasterizationOptions
        };

        cadImage.Save(PDFFile, pdfOptions);
    }

SECT1.zip (69.4 KB)

This is the full error message

Aspose.CAD.CadExceptions.ImageLoadException
HResult=0x80131500
Message=Image loading failed.
Source=
StackTrace:

Inner Exception 1:
ImageLoadException: Unable to read Dwf content

@robparmenter,

I have worked with the DWF file shared by you and have been able to observe the issue. An issue with ID CADNET-696 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.

@ [mudassir.fayyaz],

Is there any luck with the investigation of CADNET-692 ticket ID? I am eagerly waiting for a response on this issue.

@Gkrao,

I regret to share that the issue specified is not yet resolved because issue is added recently in our issue tracking system. Actually, in Aspose.CAD forum the issues are selected for investigation on first come first serve basis. Also the first priority for scheduling and resolution is given to paid Enterprise and priority support customers. Then Aspose.CAD normal or free support customers issues are scheduled and resolved on first come and first come serve basis. I will share the further information with you as soon as the issue will be resolved.

Dear Mudassir,

To say that I am appalled at Aspose’s service would be an understatement.

I contacted your company and they told me the only way to get support for the product was through this forum or I could choose to pay for it to get the support quicker.

I have never experienced a company that supplied defective products and then wanted you to pay for help in getting it to work. This has to be the most appalling service by a company ever.

Its obvious that this defect has been in the product for some time - long before I purchased it - and they are still advertising that it is capable on the sales blurb when it is clearly not.

Additionally I have asked for a workaround (eg using and older version or something) and all I get is a stock cut-and-paste reply that “we have observed and will get back to you”. No suggestions and definitely no ETA.

Considering that some customers have been reporting on this forum that they have been experiencing this issue for 12 months its unlikely to be resolved soon it would seem.

Can you let me know how long I will have to wait or any possible workarounds. If not I will have to abandon this software and request a refund.

Rob

@robparmenter,

Please accept our sincere apologies for the caused inconvenience. We have investigated the issues associated in this thread on our end and are very much hopeful to fix the issues in upcoming Aspose.CAD 18.12 that will be available for download by mid of December. Unfortunately, the previously available version also failed to load the associated files. We will really appreciate your patience in this regard till the issues gets resolved.

Is there any luck with the investigation of CADNET-692 ticket ID? It’s already 21 days over and are you guys able to provide some resolution on my issue?

@Gkrao

I have observed the issues status from our issue tracking system and like to share that we are going to share special hotfix for Aspose.CAD for .NET 18.8.1 by tomorrow that shall include the fix for CADNET-696 along with other issues. The issue CADNET-692 is still unresolved and we request for your patience till the time the issue gets resolved.

@Gkrao,

We have shared the hotfix Aspose.CAD for .NET 18.8.1 for your convenience that contain the fix for CADNET-696. We appreciate your patience in this regard.

@ [mudassir.fayyaz],

I have downloaded the latest dll ([Aspose.CAD for .NET 18.8.]) & found that the issue related to CADNET-692 is still not resolved in the latest hotfix.

@Gkrao,

As I shared with you earlier that we have fixed CADNET-696 in hotfix. The issue CADNET-692 is still unresolved and we will share the good news with you as soon as the issue will be fixed.

Dear Mudassir,

Hotfix 18.8.1.0 does seem to solve the previous issue but I’m still unable to get it to work.

The documentation on your website on how to convert Dwf is out of date and does not function due to renaming/refactoring. For example DwfRasterizationOptions no longer appears in Aspose.CAD.ImageOptions so I have been trying with CadRasterizationOptions instead.

I have been using the following code:

    public void ConvertDwfToPDF(string CadFile, string PdfFile, bool isA3 = true)
    {
        License license = new License();
        license.SetLicense(HttpContext.Current.Server.MapPath("/Aspose.CAD.lic"));

        using (Aspose.CAD.FileFormats.Dwf.DwfImage cadImage = (Aspose.CAD.FileFormats.Dwf.DwfImage) Image.Load(CadFile))
        {
            CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions
            {
                Layouts = new string[] {"Model"},
                PageWidth = (float) (isA3 ? 420 : 297),
                PageHeight = (float) (isA3 ? 297 : 210),
                UnitType = UnitType.Millimeter,
                AutomaticLayoutsScaling = true
            };

            PdfOptions pdfOptions = new PdfOptions
            {
                VectorRasterizationOptions = rasterizationOptions
            };

            cadImage.Save(PdfFile, pdfOptions);

        }
    }

however when you hit the save command it comes up with the error:

Aspose.CAD.CadExceptions.ImageSaveException: ‘Image saving failed.’
InvalidOperationException: Layer Model not exists

On the cadImage.Save line.

Any suggestions on how to fix?

SECT1.zip (69.4 KB)

Please disregard. Stupid mistake on my part. I just realised the Layouts = new string[] {“Model”} that is used from your demo is actually asking for a specific layer in the dwf called “Model”. I had assumed it was something to do with Aspose.
Removing that line made it work.
:wink:

@robparmenter,

I have observed your comments. We are glad to know that things started working on your end. Please feel free to contact us if there is any issue.

Dear Aspose,

There are still major errors in version 8.1.1.0

Attached are a set of plans for a house in dwf format. HousePlans.zip (1.0 MB)

Each of the pages opens fine in any dwf viewer or other program. Even Acrobat converts them perfectly however Aspose.Cad does the following:

  1. 18-12-11 0244 - sect1.dwf - converts almost perfectly - there is a little extra white space around the edges but it is fairly acceptable

  2. 18-12-11 1552 - flr1.dwf - Will not convert at all - Won’t open the file

  3. 18-12-11 1905 - flrcov1.dwf - converts almost perfectly

  4. 18-12-11 2984 - elect1.dwf - the “Legend” in the top right corner comes out as completely black with text unreadable

  5. 18-12-11 5579 - notes.dwf - Will not convert at all - Won’t open the file

  6. 18-12-11 5884 - int2.dwf - converts well except for the two “Notes” boxes that are completely black and unreadable. Additionally there is a lot of white space around the actual drawing.

  7. 18-12-11 6240 - int1.dwf - “Notes” field completely black. Additionally there is a lot of white space around the actual drawing.

  8. 18-12-11 7264 - elev2.dwf - opens file but fails to produce image

  9. 18-12-11 7610 - elev1.dwf - All the solid fills have been twisted by the encoder. Seems you have a top and bottom point reversed in your code. Additionally it opens with a lot of white space around the image.

  10. 18-12-11 9644 - site.dwf - Notes boxes are all black and a small amount of white space on Left Side.

  11. 18-12-11 9970 - sect2.dwf - File will not open

Attached is the resulting PDF’s in a single pdf file: OutputPDF from AsposeCAD.zip (5.6 MB)

The code I am using is as follows:

using (Aspose.CAD.FileFormats.Dwf.DwfImage cadImage = (Aspose.CAD.FileFormats.Dwf.DwfImage) Image.Load(CadFile))
{
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions
{
PageWidth = isA3 ? 420 : 297,
PageHeight = isA3 ? 297 : 210,
UnitType = UnitType.Millimeter,
AutomaticLayoutsScaling = true,
CenterDrawing = true
};

                //PageWidth = isA3 ? 420 : 297,
                //PageHeight = isA3 ? 297 : 210,


                PdfOptions pdfOptions = new PdfOptions
                {
                    VectorRasterizationOptions = rasterizationOptions
                };

                cadImage.Save(PdfFile, pdfOptions);

            }

Can you have a look and let me know if I am doing something wrong if the issue is still with your software?

@robparmenter,

I have observed your comments. Can you please provide the working sample code that may reproduce issue on our end. I am unable to use the shared sample code in present form since it is using custom calls for Pagewidth and other parameters.

Sorry that was a typo on my part it was Aspose.CAD for .NET 18.8.1

    public static void ConvertDwfToPDF(string CadFile, string PdfFile, bool isA3 = true)
    {
        License license = new License();
        license.SetLicense(HttpContext.Current.Server.MapPath("/Aspose.CAD.lic"));


        using (Aspose.CAD.FileFormats.Dwf.DwfImage cadImage = (Aspose.CAD.FileFormats.Dwf.DwfImage) Image.Load(CadFile))
        {
            CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions
            {
                PageWidth = isA3 ? 420 : 297,
                PageHeight = isA3 ? 297 : 210,
                UnitType = UnitType.Millimeter,
                AutomaticLayoutsScaling = true,
                CenterDrawing = true
            };

            PdfOptions pdfOptions = new PdfOptions
            {
                VectorRasterizationOptions = rasterizationOptions
            };

            cadImage.Save(PdfFile, pdfOptions);

        }

    }

@robparmenter,

I have worked with source files and sample code shared by you and have been able to observe issues. I have added them in our issue tracking system respectively.

CADNET-720 - flr1.dwf - Will not convert at all - Won’t open the file

CADNET-721 - elect1.dwf - the “Legend” in the top right corner comes out as completely black with text unreadable

CADNET-720 - notes.dwf - Will not convert at all - Won’t open the file

CADNET-722 - int2.dwf - converts well except for the two “Notes” boxes that are completely black and unreadable. Additionally there is a lot of white space around the actual drawing.

CADNET-723 - int1.dwf - “Notes” field completely black. Additionally there is a lot of white space around the actual drawing.

CADNET-720 - elev2.dwf - opens file but fails to produce image

CADNET-724 - elev1.dwf - All the solid fills have been twisted by the encoder. Seems you have a top and bottom point reversed in your code. Additionally it opens with a lot of white space around the image.

CADNET-725 - site.dwf - Notes boxes are all black and a small amount of white space on Left Side.

CADNET-720 - sect2.dwf - File will not open

This thread has been linked with these issues so that you may be automatically notified once the issues will be resolved.