Profile Picture

Center align the diagram exported to pdf

Posted By sudarshan rudrappa 12 Years Ago
Author
Message
sudarshan rudrappa
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 9, Visits: 2
Hi,

I am exporting nevron generated image to pdf. The image is currently left aligned, but i want the image to center aligned in the pdf
I am using the following code.

DrawingView = New NDrawingView()
DrawingView.ViewLayout = CanvasLayout.Fit
Dim imageFormat As New NPdfImageFormat()
imageFormat.PageSize = New NSizeF(GetSizeInPoints("PageHeight"), GetSizeInPoints("PageWidth"))
imageFormat.Layout = PagedLayout.FitToPages

I have also attached the pdf for reference.
Please let me know how to center align the image in pdf

Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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



sudarshan rudrappa
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 9, Visits: 2
Hi,

Thanks a lot.It worked like charm.

Thanks,
Sudarshan



Similar Topics


Reading This Topic