Convert DXF to PDF Scaling Incorrect

Hello,
We are using ASPOSE CAD (.NET 23.3.0.0) to convert Dxf files to PDF files and something seems to be a bit off with the scaling.

After I convert the Dxf to PDF using my code (attached), I use an external tool (Bluebeam Revu 20) to take measurements directly on the PDF itself and the dimensions (length and width) aren’t matching what was originally in the Dxf file.

Here’s a screenshot of the incorrect dimensions. It should be measuring 30’ but is only measuring 27’-3 1/2" IncorrectMeasurement.png (8.2 KB)

The interesting thing is when I use your online converter (here) and take the measurements from the PDF using the same external tool (Revu Bluebeam 20), everything measures as it should. Here’s a screenshot of that. CorrectMeasurement.png (7.5 KB)

Is there any way to see what code your online converter uses so I can compare it to the code that I’m using?

Here’s some supporting files:

For completeness, here’s a screenshot of the C# conversion code that is being used in the link above:
ConversionCodeScreenshot.png (89.8 KB)

I don’t think this is a bug with ASPOSE CAD, but rather some setting I don’t have quite right in my code. Could anyone please advise?

Thank you!

@kgrems,
Hello.
Could you please try redo your measurements after export without margins, and export with different height/width options, e.g., try using image.Width, image.Height there instead of 1920 / 1080.

1 Like

@oleksii.gorokhovatskyi
Thanks for the reply. Removing the margins worked. However, setting image.Height and image.Width doesn’t work because they are “read only” properties. They cause compile errors.

How would I go about maintaining some margin around the edge of my document but also maintaining the proportions/scaling?

@kgrems,
OK, so I will try to create example that creates margins with your current size options (but without setting Margins directly).

Could you test something like this (preserving initial Margins values):

PageWidth = image.Width,
PageHeight = image.Height,

or

PageWidth = 5 * image.Width,
PageHeight = 5 * image.Height,

@kgrems,
please, try these options too:

PageWidth = 1920 + 2 * margin,
PageHeight = 1080 + 2 * margin,

@oleksii.gorokhovatskyi
This maintains the proper dimensions, but doesn’t give any margins:
PageWidth = image.Width,
PageHeight = image.Height,

This maintains the proper dimensions, but doesn’t give any margins. It just makes the page itself significantly larger:
PageWidth = 5 * image.Width,
PageHeight = 5 * image.Height,

This maintains proper dimensions, but doesn’t provide any margin. Again, it just makes the page larger:
PageWidth = 1920 + 2 * margin,
PageHeight = 1080 + 2 * margin,

@kgrems,
here is my result with these options, I believe there are margins output.pdf (75.8 KB)

var layouts = image.Layouts.KeysTyped;
const int margin = 100;
var margins = new Margins { Top = margin, Bottom = margin, Left = margin, Right = margin };

var rasterizationOptions = new CadRasterizationOptions
{
BackgroundColor = Aspose.CAD.Color.White,
PageWidth = 1920 + 2 * margin,
PageHeight = 1080 + 2 * margin,
AutomaticLayoutsScaling = true,
NoScaling = false,
Layouts = new[] { layouts.ToArray()[0] },
Margins = margins,
DrawType = CadDrawTypeMode.UseObjectColor,
};

@oleksii.gorokhovatskyi
That does preserve the margins, but now the scale isn’t correct: ScaleIncorrect.png (6.9 KB)

@kgrems,
Ok, so how to calculate those 27’ 11 1/2’’ from the PDF? As I understood, removing of margins helped. Here is file without margins output_nomargins.pdf (75.8 KB). The length of the line in this file is exactly the same as for “output.pdf” above, isn’t it?

@oleksii.gorokhovatskyi
We use an external tool called Revu Bluebeam to take measurements directly on the PDF.

No, the length of the line in the file above is not the same as “output.pdf”. The file you just attached (output_nomargins.pdf) measures correctly since there are no margins. Here’s the measurement: CorrectMeasurement.png (2.2 KB)

@kgrems,
OK, could you please try zoom instead of manual margins:

var rasterizationOptions = new CadRasterizationOptions
{
BackgroundColor = Aspose.CAD.Color.White,
PageWidth = 1920,
PageHeight = 1080,
AutomaticLayoutsScaling = true,
Layouts = new[] { layouts.ToArray()[0] },
DrawType = CadDrawTypeMode.UseObjectColor,
Zoom=0.95f
};

@oleksii.gorokhovatskyi
Got it! Measurements look good and we have “margins”. Thank you!
CorrectMeasurement.png (2.9 KB)

1 Like

@kgrems,
we were happy to help :slight_smile:

1 Like

@oleksii.gorokhovatskyi
You guys have great support! Whether it’s a bug in the library, or user error (in this case).

1 Like

@kgrems,
Thank you! I believe this is not your error, just some interesting use case that required some efforts :slight_smile:

1 Like