Question regarding GroupDocs.Conversion for .NET

When converting a DWG file to PDF, the print settings from the first page were applied to all sheets, and the sheet-specific print settings were not reflected.
How can I resolve this issue?

Example:
Sheet 1 page orientation: Portrait
Sheet 2 page orientation: Landscape

Upon conversion to PDF, all sheets were converted with Portrait orientation.

However, when converting from an Excel file, the sheet-specific print settings were correctly reflected in the resulting PDF.

The version being used is GroupDocs.Conversion for .NET Framework 26.1.0.

I have attached the source code, input files, and output files associated with this issue for your review.

・Input files
DWG → test.dwg
Excel → test.xlsx

・Output files
DWG → dwg-converted-to.pdf
Excel → xlsx-converted-to.pdf

ConvertDwgToPdf.zip (357.3 KB)

@KenichiYamamoto,

Thanks for the detailed report, and for including the source files and code — that made this quick to confirm.

We reproduced it. Converting your test.dwg gives two portrait A4 pages, while the DWG itself clearly defines VIEW0250 as 210×297 and VIEW0261 as 297×210. So the per-layout plot settings aren’t being applied. What happens instead is that one page size is picked for the whole drawing, from the active layout, and every layout is then rendered onto it. That’s also why your file came out portrait throughout — VIEW0250 is the active layout in it. The XLSX path handles this per sheet, which is why you saw the difference.

We’ve logged it as CONVERSIONNET-8426. As soon as our development team has an update, we’ll share it here.

In the meantime there is a workaround. PdfConvertOptions.SizeSettings does reach the CAD renderer, so you can convert each layout on its own with its correct paper size and merge the results afterwards:

var layouts = new[]
{
    (Name: "VIEW0250", WidthMm: 210f, HeightMm: 297f),
    (Name: "VIEW0261", WidthMm: 297f, HeightMm: 210f)
};

const float MmToPt = 72f / 25.4f;

foreach (var layout in layouts)
{
    var options = new PdfConvertOptions
    {
        SizeSettings = new PageSizeOptions
        {
            PageSize = PageSize.Custom,
            PageWidth = layout.WidthMm * MmToPt,
            PageHeight = layout.HeightMm * MmToPt
        }
    };

    using (var converter = new Converter(inputFileDwg,
               loadContext => new CadLoadOptions { LayoutNames = new[] { layout.Name } }))
    {
        converter.Convert($"{layout.Name}.pdf", options);
    }
}

That gives you one correctly-sized PDF per layout, which you can then join into a single document. We checked the output on your file and both pages come out as expected, portrait then landscape, with the drawings filling their sheets.

Note the sizes are in points, hence the millimetre conversion.

Thank you for the quick response.
I will check it.

@KenichiYamamoto

Perfect. We’ll post an update here once our development team has looked into the issue.

As you suggested, I tried specifying the paper size using PdfConvertOptions.SizeSettings.
While the paper size and orientation were set correctly, the output content for the objects in the second layout of the input file (test.dwg)—specifically VIEW0261.pdf—differed from the expected result.

Please refer to Sheet ① in the attached file for details on the issue.

・Input file
test.dwg

・Output files
VIEW0250.pdf
VIEW0261.pdf

ConvertDwgToPdf.zip (446.7 KB)

@KenichiYamamoto

Thanks for the detailed follow-up, and for the AutoCAD preview alongside the output — that made the difference easy to spot.

The cause is the combination of SizeSettings and OrientationSettings. For VIEW0261 you pass the paper size as 210×297 and then set OrientationSettings to Landscape. The drawing gets rendered onto the portrait size you asked for, and the page is flipped to landscape afterwards, so the content keeps its portrait scale and ends up oversized and pushed off the sheet. That’s exactly what your Sheet 1 screenshot shows.

The fix is to drop OrientationSettings and bake the rotation into the size instead. When the layout plots rotated, swap width and height before converting:

bool rotated = layout.PaperRotation == PlotRotation.Degrees90
            || layout.PaperRotation == PlotRotation.Degrees270;

double widthMm  = rotated ? layout.PaperHeight : layout.PaperWidth;
double heightMm = rotated ? layout.PaperWidth  : layout.PaperHeight;

var options = new PdfConvertOptions
{
    SizeSettings = new PageSizeOptions
    {
        PageSize = PageSize.Custom,
        PageWidth = MmToPt(widthMm),
        PageHeight = MmToPt(heightMm)
    }
};

So VIEW0261 gets 297×210 mm directly, and no orientation override. We tried the same conversion on your test.dwg and the result matches your AutoCAD print preview — landscape sheet, drawing filling the page, nothing clipped.

One other thing worth mentioning: the thick dashed cross and the banner across the top of your PDF are the evaluation watermark, not part of your drawing. They’ll disappear once a license is applied. You can request a temporary license here (Temporary License - Purchase - groupdocs.com) if you’d like to evaluate without them.

The underlying issue is still tracked as CONVERSIONNET-8426, and we’ll update this thread once there’s progress on it.