HelloWorld.vb
  1. ''
  2. '' This code is part of Document Solutions for PDF demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports GrapeCity.Documents.Pdf
  8. Imports GrapeCity.Documents.Text
  9.  
  10. '' One of the simplest ways to create a "Hello, World!" PDF.
  11. Public Class HelloWorld
  12. Sub CreatePDF(ByVal stream As Stream)
  13. '' Create a new PDF document:
  14. Dim doc = New GcPdfDocument()
  15. '' Add a page, get its graphics:
  16. Dim g = doc.NewPage().Graphics
  17. '' Draw a string on the page.
  18. '' Notes:
  19. '' - For simplicity, here we are using a standard PDF font
  20. '' (the 14 standard fonts' metrics are built into DsPdf and are always available);
  21. '' - DsPdf coordinates start at top left corner of a page, using 72 dpi by default:
  22. g.DrawString(
  23. "Hello, World, from DsPdf and VB.NET!",
  24. New TextFormat With {
  25. .Font = StandardFonts.Times,
  26. .FontSize = 12
  27. },
  28. New PointF(72, 72))
  29. '' Save the PDF
  30. doc.Save(stream)
  31. End Sub
  32. End Class
  33.