Free Support Forum - aspose.com

Position of the exported region

Hello there,
I am trying to convert a DXF to PDF with AsposeCAD for .NET, ver 21.4.0. I want to convert a layout to PDF, but my issue is that the exported region is not centered in the PDF created with Aspose.
How can I set the position of the exported region?

Here is the zip archive with the DXF, the PDF from Aspose, and a desired PDF.
forum_request.zip (233.9 KB)

@subGm

Can you please share the sample code that you have used on your end so that I may investigate that on my end to help you further.

Hello, here is my code

using (CadImage image = (CadImage)Image.Load(sourceFilePath))
			{
				CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
				rasterizationOptions.UnitType = UnitType.Millimeter;
				
				//A3
				rasterizationOptions.PageWidth = 420;
				rasterizationOptions.PageHeight = 297;

				rasterizationOptions.Layouts = new string[] {"Layout1" };

				rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;

				PdfOptions pdfOptions = new PdfOptions();

				pdfOptions.VectorRasterizationOptions = rasterizationOptions;

				string fileName = Path.GetFileName(sourceFilePath);
				string outputDir = Path.GetDirectoryName(sourceFilePath);
				string outputFileName = fileName.Replace(".dxf", ".pdf");
				string savePDFfilePath = outputDir + @"\" + outputFileName;
				image.Save(savePDFfilePath, pdfOptions);
			}

@subGm

Please try using following sample code on your end.

    public static void TestPDFExport()
    {
        String sourceFilePath = @"/Users/mudassirkhan/Downloads/forum_request/";
        using (CadImage image = (CadImage)Image.Load(sourceFilePath+ "A3_PAPER.dxf"))
        {
            CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
            rasterizationOptions.UnitType = UnitType.Millimeter;

            //A3
            rasterizationOptions.PageWidth = 1600;
            rasterizationOptions.PageHeight = 1600;

            rasterizationOptions.Layouts = new string[] { "Layout1" };

            rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;

            PdfOptions pdfOptions = new PdfOptions();

            pdfOptions.VectorRasterizationOptions = rasterizationOptions;

            string fileName = Path.GetFileName(sourceFilePath);
            string outputDir = Path.GetDirectoryName(sourceFilePath);
            string outputFileName = "2.pdf";
            string savePDFfilePath = outputDir + @"/" + outputFileName;
            image.Save(savePDFfilePath, pdfOptions);
        }


    }

generated.pdf (205.3 KB)

Thanks for your reply.

In your code, the only difference is on page width and height, that are bigger than the ones on my end.

Is it possible to export a PDF with the same width and height of the layout of the DXF?
Or, at least, is it possible to export a PDF with the same aspect ratio of the layout of the DXF?

@subGm

You may try that on your end but you still need to have a considerable size to avoid truncating of information in output.