iTextSharp.text.Document.Close C# (CSharp) 메소드

Close() 공개 메소드

Closes the document.
Once all the content has been written in the body, you have to close the body. After that nothing can be written to the body anymore.
public Close ( ) : void
리턴 void
        public virtual void Close()
        {
            if (!close) {
                open = false;
                close = true;
            }
            foreach (IDocListener listener in listeners) {
                listener.Close();
            }
        }

Usage Example

예제 #1
5
        /// <summary>
        /// Extract a single page from PDF file.
        /// </summary>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="outputFile">The output file.</param>
        /// <param name="pageNumber">The specific page number.</param>
        public static void ExtractPage(string sourceFile, string outputFile, int pageNumber)
        {
            try
            {
                PdfReader reader = new PdfReader(sourceFile);
                if (pageNumber > reader.NumberOfPages)
                {
                    Console.WriteLine("This page number is out of reach.");
                    return;
                }

                Document document = new Document();
                PdfCopy pdfCopy = new PdfCopy(document, new FileStream(outputFile, FileMode.Create));
                document.Open();

                PdfImportedPage importedPage = pdfCopy.GetImportedPage(reader, pageNumber);
                pdfCopy.AddPage(importedPage);

                document.Close();
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
All Usage Examples Of iTextSharp.text.Document::Close