HelloWorld.cs
- //
- // This code is part of Document Solutions for PDF demos.
- // Copyright (c) MESCIUS inc. All rights reserved.
- //
- using System;
- using System.IO;
- using System.Drawing;
- using GrapeCity.Documents.Pdf;
- using GrapeCity.Documents.Text;
-
- namespace DsPdfWeb.Demos
- {
- // One of the simplest ways to create a "Hello, World!" PDF with DsPdf.
- public class HelloWorld
- {
- public int CreatePDF(Stream stream)
- {
- // Create a new PDF document:
- var doc = new GcPdfDocument();
- // Add a page, get its graphics:
- var g = doc.NewPage().Graphics;
- // Draw a string on the page.
- // Notes:
- // - For simplicity, here we are using a standard PDF font
- // (the 14 standard fonts' metrics are built into DsPdf and are always available);
- // - DsPdf coordinates start at top left corner of a page, using 72 dpi by default:
- g.DrawString("Hello, World!",
- new TextFormat() { Font = StandardFonts.Times, FontSize = 12 },
- new PointF(72, 72));
- // Save the PDF:
- doc.Save(stream);
- return doc.Pages.Count;
- }
- }
- }
-