Posted by a ceTe Software moderator
Hello,
We did testing on our end and are able to add the label at a specified position(X=5 and Y=10). Below is the code sample used for our testing.
Please note that the DynamicPDF API adds the page element with respect to the left and top margins set to the page. Also you can add a LayoutGrid to know the positions of the page elements.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Font HeadingTextFont = Font.Helvetica;
float HeadingTextPoints = 13;
RgbColor HeadingTextColor = RgbColor.Blue;
string HeadingText = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW";
Label label = new Label(HeadingText, 5, 10, page.Dimensions.Width - 10, 20, HeadingTextFont, HeadingTextPoints, HeadingTextColor);
page.Elements.Add(new LayoutGrid());
page.Elements.Add(label);
document.Draw(@"C:\Temp\MyDocument.pdf");
Also below is the code sample to add the text at the center of the page (horizontally) using Label page element.
string HeadingText = "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW";
Label label = new Label(HeadingText, 0, 10, page.Dimensions.Body.Width, 20, HeadingTextFont, HeadingTextPoints, HeadingTextColor);
label.Align = TextAlign.Center;
If you continue facing any issues then please send over the following information to
support@dynamicpdf.com so we can look into it further.
1. Code sample which uses static data to recreate the behavior.
2. Output PDF.
3. Exact version and build number of the DynamicPDF DLL file used in the application. You can get this information in DLL references properties (Version and Description fields) in Visual Studio.
Thanks,
ceTe Software support Team