Page Size not honored

I’m converting sets of .dwg files to PDF, then adding a page at the end.
I’m setting the Page Height and Page Width to 1600. Most drawings are converting properly however some come in with page size of 14370 which makes the additional page at 1600 x 1600 unreadable.

Here’s the code I’m using :

using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(id))
{

               CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

            rasterizationOptions.PageSize = new SizeF(1600, 1600);

            rasterizationOptions.AutomaticLayoutsScaling = true;

            rasterizationOptions.NoScaling = false;

              PdfOptions pdfOptions = new PdfOptions();

            pdfOptions.VectorRasterizationOptions = rasterizationOptions;

            image.Save(ms, pdfOptions);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
        }

Are there settings i need to ensure the pdf page is no larger than the 1600 x 1600 ?

Thanks.
Dave

@dwgpackless,
could you please attach one file you have trouble with, so we can reproduce the issue?

88754.zip (317.8 KB)
Here’s a zip of the .dwg file and the resulting pdf

Also I’m using 19.5.0.0 of Aspose.CAD.dll

@dwgpackless,
I hope this code snippet is useful for you. It sets specific size of the canvas for export (in this case - A4). You may put your own values in mm and inches to export into same size always.

bool currentUnitIsMetric = false;
double currentUnitCoefficient = 1.0;
DefineUnitSystem(cadImage.UnitType, out currentUnitIsMetric, out currentUnitCoefficient);

 if (currentUnitIsMetric)
 {
                    double metersCoeff = 1 / 1000.0;

                    double scaleFactor = metersCoeff / currentUnitCoefficient;

                    rasterizationOptions.PageWidth = (float)(210 * scaleFactor);
                    rasterizationOptions.PageHeight = (float)(297 * scaleFactor);
                    rasterizationOptions.UnitType = UnitType.Millimeter;
}
else
{
                    rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient);
                    rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient);
                    rasterizationOptions.UnitType = UnitType.Inch;
}

 private static void DefineUnitSystem(UnitType unitType, out bool isMetric, out double coefficient)
        {
            isMetric = false;
            coefficient = 1.0;

            switch (unitType)
            {
                case UnitType.Parsec:
                    coefficient = 3.0857 * 10000000000000000.0;
                    isMetric = true;
                    break;
                case UnitType.LightYear:
                    coefficient = 9.4607 * 1000000000000000.0;
                    isMetric = true;
                    break;
                case UnitType.AstronomicalUnit:
                    coefficient = 1.4960 * 100000000000.0;
                    isMetric = true;
                    break;
                case UnitType.Gigameter:
                    coefficient = 1000000000.0;
                    isMetric = true;
                    break;
                case UnitType.Kilometer:
                    coefficient = 1000.0;
                    isMetric = true;
                    break;
                case UnitType.Decameter:
                    isMetric = true;
                    coefficient = 10.0;
                    break;
                case UnitType.Hectometer:
                    isMetric = true;
                    coefficient = 100.0;
                    break;
                case UnitType.Meter:
                    isMetric = true;
                    coefficient = 1.0;
                    break;
                case UnitType.Centimenter:
                    isMetric = true;
                    coefficient = 0.01;
                    break;
                case UnitType.Decimeter:
                    isMetric = true;
                    coefficient = 0.1;
                    break;
                case UnitType.Millimeter:
                    isMetric = true;
                    coefficient = 0.001;
                    break;
                case UnitType.Micrometer:
                    isMetric = true;
                    coefficient = 0.000001;
                    break;
                case UnitType.Nanometer:
                    isMetric = true;
                    coefficient = 0.000000001;
                    break;
                case UnitType.Angstrom:
                    isMetric = true;
                    coefficient = 0.0000000001;
                    break;
                case UnitType.Inch:
                    coefficient = 1.0;
                    break;
                case UnitType.MicroInch:
                    coefficient = 0.000001;
                    break;
                case UnitType.Mil:
                    coefficient = 0.001;
                    break;
                case UnitType.Foot:
                    coefficient = 12.0;
                    break;
                case UnitType.Yard:
                    coefficient = 36.0;
                    break;
                case UnitType.Mile:
                    coefficient = 63360.0;
                    break;
            }
        }

Good News:

I added the code and it did seem to handle the scaling issues I was having.

Bad News:

I ran about 20 drawings thru and about half render a single page as I needed. The other half render a page that looks correct and an additional page with some fragment of the drawing.

For example one file had a single dimension line on the first page, and the correctly rendered drawing on the second page.

Another had the correctly rendered drawing on the first page and a fragment of the title block on the second page.

Another had the correctly rendered drawing on page one and page two.

I also got the latest version 22.1 from your web site (I had 19.5) and tried again with the same results.

So I’m thinking that this product is not reliable enough in its output to do what I need.

I’ll keep looking for another solution.

Dave

Good News:

I added the code and it did seem to handle the scaling issues I was having.

Bad News:

I ran about 20 drawings thru and about half render a single page as I needed. The other half render a page that looks correct and an additional page with some fragment of the drawing.

For example one file had a single dimension line on the first page, and the correctly rendered drawing on the second page.

Another had the correctly rendered drawing on the first page and a fragment of the title block on the second page.

Another had the correctly rendered drawing on page one and page two.

I also got the latest version 22.1 from your web site (I had 19.5) and tried again with the same results.

So I’m thinking that this product is not reliable enough in its output to do what I need.

I’ll keep looking for another solution.

Dave

~WRD0002.jpg (357 Bytes)

@dwgpackless,
could you please share these files and code snippet you used for the analysis on our side?

AXCode (2).zip (7.5 MB)

There’s 3 files one converts correctly the other 2 do not.
These aren’t representative, each file that failed was different , the main commonality was they all had one good page and one page that was a partial fragment of the good page.

@dwgpackless,
I have created CADNET-8571 issue to investigate and solve this problem. Not it seems that it occurs for DWG R13 format and third file (86793) is in DWG 2018 and is fine.

The issues you have found earlier (filed as CADNET-8571) have been fixed in this Aspose.CAD for .NET 22.3 update. This message was posted using Bugs notification tool by Oleksii.Gorokhovatskyi