With PDF for WinRT class library you can create PDF documents in code and save them out to a stream. The following code snippet shows how to create a simple document and load it into C1PdfViewer without having to save it into isolated storage or put on the Web:
To write the code in Visual Basic:
Visual Basic |
Copy Code
|
---|---|
Public Sub New() InitializeComponent() ' create new C1PdfDocument Dim doc As New C1PdfDocument() ' add some content to PDF doc.DrawString("Hello World!", New Font("Arial", 14), Colors.Black, doc.PageRectangle) ' save PDF to memory stream Dim ms As New MemoryStream() doc.Save(ms) ' load PDF from stream ms.Seek(0, SeekOrigin.Begin) c1PdfViewer1.LoadDocument(ms) End Sub |
To write the code in C#:
C# |
Copy Code
|
---|---|
public MainPage() { InitializeComponent(); // create new C1PdfDocument C1PdfDocument doc = new C1PdfDocument(); // add some content to PDF doc.DrawString("Hello World!", new Font("Arial", 14), Colors.Black, doc.PageRectangle); // save PDF to memory stream MemoryStream ms = new MemoryStream(); doc.Save(ms); // load PDF from stream ms.Seek(0, SeekOrigin.Begin); c1PdfViewer1.LoadDocument(ms); } |