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.