{oapdf_gg}
Office software is closely linked to the PDF,the PDF is also must have to control!      Set home Page  Add to Favorites  
You are here:Home > PDF Application > PDF Development
PDF Development
Using C# language the whole PDF document Strategy Guide Graphic
Finishing by: Date:2009-04-17 20:59:48 Popularity: Tags:

Part II Other Document Format

Chapter VII XML and (X) HTML

this chapter introduces how to use iText to generate XLM documents and controls (X) HTML document, but we are not interested in them, it only introduced in this chapter will be referred to XML to PDF.

in the first chapter, we step 5 to produce a PDF file, an XML document in order to convert the PDF file, just rewrite the paragraphs 3 and 4 Step 5 Step automatic processing by the parser.

//Step 3:Create a resolver and set the document handler:

iTextHandler h = new iTextHandler (document);

//step 4, conversion of the document:

h.Parse ( "Chap0701.xml ");

sample code, see sample code 0702

Chapter VIII RTF document

RTF package

RTF package is based on the expansion pack by iText, iText In addition to allow the generation of PDF documents can also be output RTF file, in addition to the package in RTF does not support the features, most features PDF documents can be used.

create a RTF document

create an RTF document and create a PDF document is the same as are the basic step 5, the only difference is that Step 2 instead of RtfWriter with PdfWriter, see sample code 0801.

Step 1 to create a instance of the iTextSharp.text.Document object:

Document document = new Document ();

Step 2 of RtfWriter create a document will be written into the document output stream of your choice:

RtfWriter.getInstance (document, new FileStream ( "Chap0801.rtf"), FileMode.Create);

Step 3 Open the document:

document.Open ();

Step 4 Add content to the document

document.Add (new Paragraph ( "Hello World "));

Step 5 Close document

document.Close ();

on how to create and add other objects in the document, please refer to the contents of other chapters.

characteristics do not support

  • watermark Reader
  • parameters
  • encryption
  • embedded fonts
  • block spacing indented paragraphs
  • right right indent
  • list no dot symbols
  • list
  • nested forms
  • In addition to JPEG and PNG image of the other

RTF in expansion of the header and footer

RTF can not

write a new page in the beginning before the setHeader method to change the header or footer files, there are two ways to solve this problem.

  • use of "Chapters", add a new "chapter" to the document before using the setHeader or setFooter, you can be in different "Chapters" in using a different header or footer, see the sample code 0802.
  • use RtfHeaderFooters category. Allows you to set up these four header or footer, and specify which page appears. Chapter Of course you can combine to create four different header or footer, see the sample code 0803.

u use RtfHeaderFooters type

Step 1 to create a RtfHeaderFooters category:

RtfHeaderFooters headers = new RtfHeaderFooters ();

Step 2 Add HeaderFooter object

headers.Add (RtfHeaderFooters.LEFT_PAGES, new HeaderFooter (new Phrase ( "This header is only on left hand pages ")));

headers.Add (RtfHeaderFooters.RIGHT_PAGES, new HeaderFooter (new Phrase ( "This header is only on right hand pages ")));

Step 3 the same as the use of the use of header footer RtfHeaderFooters

document.Header = headers;

constant RtfHeaderFooters.add (...) to use:

  • FIRST_PAGE: in the first page of your document to use the header or footer. You will use rtfWriter.HasTitlePage = true to complete
  • LEFT_PAGES: of all the left side of page using the header or footer
  • RIGHT_PAGES: all have the right to use the page header or footer
  • ALL_PAGES: all the pages are using the header or footer, only and FIRST_PAGE will only be meaningful if used in combination.

there is one thing very important:If you use LEFT_PAGES or to set up RIGHT_PAGES header or footer, and then use ALL_PAGES, both headers and footers will not work.

Form 0804 results, see the sample code.

there isArticle InformationsComment Information
Category column

Site Help | Site Map | Feedback |
OAPDF.COM Copyright 2009 V1.1