Free Support Forum - aspose.com

How to create a simple pdf page "Hello World" in windows application

Hi,

I am a new user in Aspose.pdf. I want to create a simple pdf page in window applications. The page contents for ex. "Hello World" with different font

Thanks in advance

- Loi -

Thanks for considering Aspose.

Here is the sample for you.

====================================================

private void Page_Load(object sender, System.EventArgs e)
{

//Create pdf document
Pdf pdf = new Pdf();

//Add a section into the pdf document
Section sec1 = pdf.Sections.Add();

//Add a text paragraph into the section
Aspose.Pdf.Text t1 = new Aspose.Pdf.Text("Hello World");

Aspose.Pdf.Text t2 = new Aspose.Pdf.Text("Hello World");

t1.TextInfo.FontName = "Arial";
sec1.Paragraphs.Add(t1);

t2.TextInfo.FontName = "Symbol";

sec1.Paragraphs.Add(t2);

MemoryStream dstStream = new MemoryStream();
pdf.Save(dstStream);

Response.Clear();
Response.ContentType = "application/pdf";
Response.BinaryWrite(dstStream.ToArray());
dstStream.Close();
Response.End();

}
==========================================================

When using a kind of Font, please be sure it is installed on your OS correctly.