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 ();