C # generate PDF

Source: Internet
Author: User

Using system;
Using system. Collections. Generic;
Using system. text;
Using system. IO;
Using system. collections;
//
Using itextsharp; // download this DLL.
Using itextsharp. text;
Using itextsharp.text.pdf;

Namespace generator Generator
{
Class Program
{

Static void main (string [] ARGs)
{
Document document = new document ();
Using writer. getinstance (document, new filestream ("E: // test1.pdf", filemode. Create ));
// The generated signature file is test1.pdf.
Document. open ();
Basefont bfchinese = basefont. createfont ("C: \ Windows \ fonts \ simsun. TTC, 1", basefont. identity_h, basefont. not_embedded );
// Alignment: cell. horizontalalignment = element. align_center; cell. verticalignment = element. align_middle;
// Underline: Chunk chunk1 = new chunk ("this text is underlined", fontfactory. getfont (fontfactory. Helvetica, 12, Font. Underline ));
// Strikethrough: Chunk chunk2 = new chunk ("this font is of Type italic | strikethru", fontfactory. getfont (fontfactory. helvetica, 12, Font. italic | font. strikethru ));
Font fontchinese = new font (bfchinese, 14, Font. Underline, color. Red );
// Font fontchinese = new font (bfchinese, 12, Font. Normal, new color (0, 0, 0); // black
// Font fontchinese = new font (bfchinese, 12, Font. Normal, new color (0,255, 0); // green
Document. Add (new paragraph ("Hello, world", fontchinese ));
// Add textbox1 to PDF
Itextsharp. Text. Image JPEG = itextsharp. Text. image. getinstance ("01.jpg ");
Document. Add (JPEG );
// Returns the image 01.jpg to the left-side navigation pane.
Document. Close ();
}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.