. Net open-source PDF class library itextsharp Test

Source: Internet
Author: User

PDF is a popular and hateful file format, but its application is becoming more and more popular. Although the current Office 2007 and later versions support PDF, there are still few free options for generating PDF documents on Microsoft's development platform.

Itextsharp is an open-source project on the mature. NET platform. Its address is http://sourceforge.net/projects/itextsharp /.

According to its official instructions, it is widely supported, such as PDF, XML, and image waiting. After testing, it is found that the PDF file generated is1.4IsAcrobat Reader 5.x.

Today, in order to generate a PDF file, I found this class library and conducted a test. I was disappointed with the results. Release the test results and hope to communicate with you. Maybe I have not used them correctly.

The generated PDF file is as follows:

Setting the attributes of a PDF file is perfectly supported:

In the figure above, you may see the sentenceNot support ChineseHaha, that is the miserable result of my test:The document content does not support Chinese Characters!

The following is the test code:

Using itextsharp. text; using itextsharp.text.pdf; document = new document (); try {// Step 2: // We create a writer that listens to the document // and directs a PDF-stream to a file using writer. getinstance (document, new filestream ("chap0101.pdf", filemode. openorcreate); // Step 3: We open the document. open (); // Step 4: we add a paragraph to the document. addauthor ("3?? Cat? "); Document. addcreationdate (); document. addcreator (" deltacat "); document. addsubject (" DOTNET make? Use? Itextsharp class? Library? Create?? PDF??? Example? Child? "); Document. addtitle (" here? PDF? 3?? Cat? Create? Jian ?,? Hey? Hey? "); Document. add (new paragraph ("Hello World"); document. add (new paragraph ("-------------------------------"); document. add (new paragraph (New chunk ("not support Chinese", new font (5, 30, 2, new basecolor (223);} catch (incluentexception de) {console. error. writeline (de. message);} catch (ioexception IOE) {console. error. writeline (IOE. message);} // Step 5: We close the documentdocument. 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.