I am using the EddiesElectronics PDF web example to try to figure out how to make a PDF. Most of it works as expected, but trying to right justify a date has me baffled. My code is
var d As DateTime = DateTime.Now
var dayString As String = d.ToString(locale.Current, DateTime.FormatStyles.Full, DateTime.FormatStyles.Medium)
var b As double = Session.Document.Graphics.TextWidth(dayString)
Session.Document.Graphics.DrawText(dayString, Session.Document.Graphics.Width - x - round(Session.Document.Graphics.TextWidth(dayString)), y)
where x is the left offset from the margin and y is the height. I added the b double for troubleshooting.
In my app, b always comes out 0, even if I hard code a string value instead of the dayString variable. When I pasted this code into the EE example and substituted hard values for x and y, it works properly. I figure I am either missing something in the setup of the PDF document or my app is using too much memory for this function. Any suggestions would be greatly appreciated.