Skip to main content

Example

Version: 7.0

Example

DynamicPDF WebCache Example​

The ability to email dynamically generated PDF documents saved in the web cache is shown in the example below. The email functionality is accomplished using the FireMail for .NET product.

The example creates a Hello World PDF, draws to WebCache, then creates a simple email and attaches the PDF to the email created. 

Dim MyDocument As Document = New Document()
Dim MyPage As ceTe.DynamicPDF.Page = New ceTe.DynamicPDF.Page()
MyPage.Elements.Add(New ceTe.DynamicPDF.PageElements.Label("Hello World",0,0,100,100))
MyDocument.Pages.Add(MyPage)

Dim MyWebCacheItem As WebCacheItem = MyDocument.DrawToWebCache("Test.pdf")

Dim ptMessage As PlainTextMessage = New PlainTextMessage("from@test.com","to@test.com","Mail with PDF Attachment"," Files Attached")
ptMessage.Attachments.Add(MyWebCacheItem.FilePath)
ptMessage.Send("SmtpServer")
Document document = new Document();
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page();
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Hello World", 0, 0, 100, 100));
document.Pages.Add(page);

WebCacheItem webCacheItem = document.DrawToWebCache("Test.pdf");

PlainTextMessage ptMessage = new PlainTextMessage("from@test.com", "to@test.com", "Mail with PDF Attachment", " Files Attached");
ptMessage.Attachments.Add(webCacheItem.FilePath);
ptMessage.Send("SmtpServer");