Hi, you can center a diagram in a PDF using the page margins of the PDF image format:
float docWidth = diagramControl.Document.Width;
float docHeight = diagramControl.Document.Height;
NSizeF pageSize = new NSizeF(842, 595); // The size of A4 format in landscape mode
pdfImageFormat.PageSize = pageSize;
float pageRatio = pageSize.Width / pageSize.Height;
float docRatio = docWidth / docHeight;
if (docRatio < pageRatio)
pdfImageFormat.PageMargins = new NMarginsF((pageSize.Width * (pageRatio - docRatio)) / (2 * pageRatio), 0, 0, 0);
else
pdfImageFormat.PageMargins = new NMarginsF(0, (pageSize.Height * (docRatio - pageRatio)) / (2 * docRatio), 0, 0);
Best Regards,
Nevron Support Team