Skip to content

Commit 5fd1c62

Browse files
committed
Committing the changes for the sample
1 parent ebc5236 commit 5fd1c62

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

CreatePDF/PdfViewerViewModel.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Syncfusion.Pdf;
22
using Syncfusion.Pdf.Graphics;
33
using System.ComponentModel;
4+
using System.IO;
45

56

67
namespace CreatePDF
@@ -38,28 +39,35 @@ public PdfViewerViewModel()
3839
//Set the created PDF stream to pdfDocumentStream for loading it in PDF Viewer
3940
pdfDocumentStream = CreatePDF();
4041
}
41-
private MemoryStream CreatePDF()
42+
private Stream CreatePDF()
4243
{
43-
//Create a new PDF document.
44+
// Create a new PDF document.
4445
PdfDocument document = new PdfDocument();
45-
//Add a page to the document.
46+
47+
// Add a page to the document.
4648
PdfPage page = document.Pages.Add();
47-
//Create PDF graphics for the page.
49+
50+
// Create PDF graphics for the page.
4851
PdfGraphics graphics = page.Graphics;
4952

50-
//Set the standard font.
53+
// Set the standard font.
5154
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
52-
//Draw the text.
55+
// Draw the text.
5356
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0));
5457

55-
//Creating the stream object.
58+
// Creating the stream object.
5659
MemoryStream stream = new MemoryStream();
57-
//Save the document into memory stream.
60+
61+
// Save the document into memory stream.
5862
document.Save(stream);
59-
//Close the document.
63+
64+
// Close the document.
6065
document.Close(true);
6166

62-
return stream;
67+
if (stream.CanSeek)
68+
stream.Position = 0;
69+
70+
return stream;
6371

6472
}
6573
/// <summary>

0 commit comments

Comments
 (0)