New PDF documents can be created from scratch using the PdfDocument class and save it into a stream, and the stream can be loaded into PdfViewer. So that, saving the document in the disk can be avoided.
Add PdfViewer to the MainPage of the application.
Add a method named “CreateNewPDF” with return type Stream in the code behind of the MainPage. In this method create a PdfDocument instance, set its page size, add a new page to it, and draw the string “Hello World!” on the page. Now, save this PdfDocument instance to a stream and return this stream.
The previous example illustrates drawing a simple string on a single page PDF. Refer to the following documentation for creating PDF with more pages and different types of contents such as text, images, tables and more.
In the constructor of the MainPage, call the CreateNewPDF method and load the acquired stream into the PdfViewer.
This page will automatically be redirected to the sign-in page in 10 seconds.