Htmlviewer not displaying any data

Hello:

I am testing out the pdfdocument feature in a test xojo webapp. The problem I’m having is that for whatever reason, no text is appearing within the htmlviewer. the htmlviewer is within a webcontainer. Any thoughts? Here’s my code:

var d As New PDFDocument
var myTitle As String = "My PDF Title"
var pdf As New WebFile
var g As Graphics = d.Graphics

g.FontName = PDFDocument.StandardFontNames.Helvetica
g.FontSize = 16
g.DrawText(myTitle, 50, 50)

pdf.MIMEType = "application/pdf"
pdf.ForceDownload = False
pdf.Filename = "SamplePDF.pdf"
pdf.Data = d.ToData

HTMLViewer.LoadURL(pdf.URL)

This code is within the Opening event of the webcontainer.

I’m certain that I am overlooking the obvious.

Try making pdf a property of the container. It will be going out of scope where it is.