當前位置: 首頁>>代碼示例>>C#>>正文


C# Document.AddSubject方法代碼示例

本文整理匯總了C#中iTextSharp.text.Document.AddSubject方法的典型用法代碼示例。如果您正苦於以下問題:C# Document.AddSubject方法的具體用法?C# Document.AddSubject怎麽用?C# Document.AddSubject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.Document的用法示例。


在下文中一共展示了Document.AddSubject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: btnCreateReport_Click

        private void btnCreateReport_Click(object sender, EventArgs e)
        {
            // _______________________________________________________1_______________________________________________________
            // Setting pagetype, margins and encryption
            iTextSharp.text.Rectangle pageType = iTextSharp.text.PageSize.A4;
            float marginLeft = 72;
            float marginRight = 36;
            float marginTop = 60;
            float marginBottom = 50;
            String reportName = "Test.pdf";

            Document report = new Document(pageType, marginLeft, marginRight, marginTop, marginBottom);
            PdfWriter writer = PdfWriter.GetInstance(report, new FileStream(reportName, FileMode.Create));
            //writer.SetEncryption(PdfWriter.STRENGTH40BITS, "Good", "Bad", PdfWriter.ALLOW_COPY);
            report.Open();

            // _______________________________________________________2_______________________________________________________
            // Setting Document properties(Meta data)
            // 1. Title
            // 2. Subject
            // 3. Keywords
            // 4. Creator
            // 5. Author
            // 6. Header
            report.AddTitle("Employee Details Report");
            report.AddSubject("This file is generated for administrative use only");
            report.AddKeywords("Civil Security Department, Employee Management System, Version 1.0.0, Report Generator");
            report.AddCreator("Ozious Technologies");
            report.AddAuthor("Eranga Heshan");
            report.AddHeader("Owner", "Civil Security Department");

            // _______________________________________________________3_______________________________________________________
            // Setup the font factory
            /*
            int totalFonts = FontFactory.RegisterDirectory("C:\\WINDOWS\\Fonts");
            StringBuilder sb = new StringBuilder();
            foreach (string fontname in FontFactory.RegisteredFonts) { sb.Append(fontname + "\n"); }
            report.Add(new Paragraph("All Fonts:\n" + sb.ToString()));
            */
            iTextSharp.text.Font fontHeader_1 = FontFactory.GetFont("Calibri", 30, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));
            iTextSharp.text.Font fontHeader_2 = FontFactory.GetFont("Calibri", 15, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(125, 125, 125));

            // _______________________________________________________x_______________________________________________________
            // Create header
            PdfContentByte cb = writer.DirectContent;
            cb.MoveTo(marginLeft, marginTop);
            cb.LineTo(500, marginTop);
            cb.Stroke();

            Paragraph paraHeader_1 = new Paragraph("Civil Security Department", fontHeader_1);
            paraHeader_1.Alignment = Element.ALIGN_CENTER;
            paraHeader_1.SpacingAfter = 0f;
            report.Add(paraHeader_1);

            Paragraph paraHeader_2 = new Paragraph("Employee Detailed Report", fontHeader_2);
            paraHeader_2.Alignment = Element.ALIGN_CENTER;
            paraHeader_2.SpacingAfter = 10f;
            report.Add(paraHeader_2);

            // _______________________________________________________x_______________________________________________________
            // Adding employee image
            iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imgEmployee.ImageLocation);
            img.ScaleToFit(100f, 100f);
            img.Border = iTextSharp.text.Rectangle.BOX;
            img.BorderColor = iTextSharp.text.BaseColor.BLACK;
            img.BorderWidth = 5f;
            img.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT | iTextSharp.text.Image.ALIGN_TOP;
            img.IndentationLeft = 50f;
            img.SpacingAfter = 20f;
            img.SpacingBefore = 20f;
            report.Add(img);

            Paragraph para1 = new Paragraph("Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ");
            para1.Alignment = Element.ALIGN_JUSTIFIED;
            report.Add(para1);

            report.Close();
            this.Close();
        }
開發者ID:lakmalbuddikalucky,項目名稱:OOSD-Project,代碼行數:79,代碼來源:frmSearch.cs

示例2: GetOrCreatePDF

 /// <summary>
 /// 讀取或創建Pdf文檔並打開寫入文件流
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="folderPath"></param>
 public Document GetOrCreatePDF(string fileName, string folderPath)
 {
     string filePath = folderPath + fileName;
     FileStream fs = null;
     if (!File.Exists(filePath))
     {
         fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
     }
     else
     {
         fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.None);
     }
     //獲取A4紙尺寸
     Rectangle rec = new Rectangle(PageSize.A4);
     Document doc = new Document(rec);
     //創建一個 iTextSharp.text.pdf.PdfWriter 對象: 它有助於把Document書寫到特定的FileStream:
     PdfWriter writer = PdfWriter.GetInstance(doc, fs);
     doc.AddTitle(fileName.Remove(fileName.LastIndexOf('.')));
     doc.AddSubject(fileName.Remove(fileName.LastIndexOf('.')));
     doc.AddKeywords("Metadata, iTextSharp 5.4.4, Chapter 1, Tutorial");
     doc.AddCreator("MCS");
     doc.AddAuthor("Chingy");
     doc.AddHeader("Nothing", "No Header");
     //打開 Document:
     doc.Open();
     ////關閉 Document:
     //doc.Close();
     return doc;
 }
開發者ID:fuhongliang,項目名稱:GraduateProject,代碼行數:34,代碼來源:DIStatementExport.aspx.cs

示例3: Form1

        // From <ClickButt> -> PdfConnector PdfCreatora <- PdfCreator(naemBank,Bodytext)
        // Form <Image> <- PdfConnector -- tworzyć pdf |
        public Form1() 
        {
            while (!fileBanksLists.EndOfStream)
            {
                    InitializeComponent();
            
                     using (FileStream file = new FileStream(String.Format(path, nameBank), FileMode.Create))
                    {

                        Document document = new Document(PageSize.A7);
                        PdfWriter writer = PdfWriter.GetInstance(document, file);
              
                        /// Create metadate pdf file
                        document.AddAuthor(nameBank);
                        document.AddLanguage("pl");
                        document.AddSubject("Payment transaction");
                        document.AddTitle("Transaction");
                        document.AddKeywords("OutcomingNumber :" + OutcomingNumber);
                        document.AddKeywords("IncomingNumber :" + IncomingNumber);
                        /// Create text in pdf file
                        document.Open();
                        document.Add(new Paragraph(_przelew + "\n"));
                        document.Add(new Paragraph(String.Format("Bank {0}: zaprasza\n", nameBank)));
                        document.Add(new Paragraph(DateTime.Now.ToString()));
                        document.Close();
                        writer.Close();
                        file.Close();
                    }
            }
            
            
        }
開發者ID:blacha14,項目名稱:nitrogen,代碼行數:34,代碼來源:Form1.cs

示例4: TryCreatePdf

        public bool TryCreatePdf(string nameBank)
        {
            try
            {
                using (FileStream file = new FileStream(String.Format(path,nameBank), FileMode.Create))
                {
                    Document document = new Document(PageSize.A7);
                    PdfWriter writer = PdfWriter.GetInstance(document, file);

                    /// Create metadate pdf file
                    document.AddAuthor("");
                    document.AddLanguage("pl");
                    document.AddSubject("Payment transaction");
                    document.AddTitle("Transaction");
                    /// Create text in pdf file
                    document.Open();
                    document.Add(new Paragraph(_przelew+"\n"));
                    document.Add(new Paragraph(String.Format("Bank {0}: zaprasza\n",nameBank)));
                    document.Add(new Paragraph(DateTime.Now.ToString()));
                    document.Close();
                    writer.Close();
                    file.Close();
                    return true;
                }
            }
            catch (SystemException ex)
            {
                return false;
            }
        }
開發者ID:sparrow41,項目名稱:training,代碼行數:30,代碼來源:PdfCreator.cs

示例5: CreatePdf

        public void CreatePdf(Project project, Stream writeStream)
        {
            var document = new Document();
            var writer = PdfWriter.GetInstance(document, writeStream);

            // landscape
            document.SetPageSize(PageSize.A4.Rotate());
            document.SetMargins(36f, 36f, 36f, 36f); // 0.5 inch margins

            // metadata
            document.AddCreator("EstimatorX.com");
            document.AddKeywords("estimation");
            document.AddAuthor(project.Creator);
            document.AddSubject(project.Name);
            document.AddTitle(project.Name);
            
            document.Open();

            AddName(project, document);
            AddDescription(project, document);
            AddAssumptions(project, document);
            AddFactors(project, document);
            AddTasks(project, document);
            AddSummary(project, document);

            writer.Flush();
            document.Close();
        }
開發者ID:modulexcite,項目名稱:Estimatorx,代碼行數:28,代碼來源:DocumentCreator.cs

示例6: Publish

        public void Publish(IReadOnlyList<ReleaseNoteWorkItem> workItems)
        {
            var stream = new MemoryStream();
            try
            {
                _document = new Document(PageSize.A4, 36, 36, 90, 72);

                // Initialize pdf writer
                _writer = PdfWriter.GetInstance(_document, stream);
                _writer.PageEvent = new ReleaseNotesPdfPageEvents(Settings);

                // Open document to write
                _document.Open();
                _document.AddTitle(Settings.GetDocumentTitle());
                _document.AddSubject(Settings.ProductName + " Release Notes");
                _document.AddAuthor("ReleaseNotes Generator");
                _document.AddKeywords(Settings.ProductName + "Release Notes");
                _document.AddCreationDate();
                _document.AddCreator("ReleaseNotes Generator");

                // Add manual release notes for current release
                int chapterNumber = 1;

                if (!string.IsNullOrEmpty(Settings.MergeReleaseNotesFile) && File.Exists(Settings.MergeReleaseNotesFile))
                {
                    Bookmarks.AddRange(Merge(Settings.MergeReleaseNotesFile, 1));
                    if (Bookmarks.Count > 0)
                        chapterNumber = Bookmarks.Count;
                }

                // Add automatic releases notes for current release
                WriteWorkItems("How do I?", ref chapterNumber, workItems.Where(x => x.ResolutionType == "How do I" || x.ResolutionType == "As Designed"));
                WriteWorkItems("Bug Fixes", ref chapterNumber, workItems.Where(x => x.ResolutionType == "Bug Fix"));
                WriteWorkItems("Known Issues", ref chapterNumber, workItems.Where(x => x.ResolutionType == "Known Issue"));
                WriteWorkItems("User Manual", ref chapterNumber, workItems.Where(x => x.ResolutionType == "User Manual"));

                CreateBookmarks();
            }
            catch (Exception exception)
            {
                throw new Exception("There has an unexpected exception occured whilst creating the release notes: " + exception.Message, exception);
            }
            finally
            {
                _document.Close();
            }

            File.WriteAllBytes(Settings.OutputFile, stream.GetBuffer());
        }
開發者ID:marcostomazini,項目名稱:ReleaseNotes,代碼行數:49,代碼來源:ReleaseNotesPdfWriter.cs

示例7: PdfGraphics

 public PdfGraphics(Stream stream, int width, int height)
 {
     originalWidth = currentWidth = width;
     originalHeight = currentHeight = height;
     document = new Document(new Rectangle(width, height), 50, 50, 50, 50);
     document.AddAuthor("");
     document.AddSubject("");
     try{
         writer = PdfWriter.GetInstance(document, stream);
         document.Open();
         content = writer.DirectContent;
         template = topTemplate = content.CreateTemplate(width, height);
         content.AddTemplate(template, 0, 0);
     } catch (DocumentException de){
         throw new IOException(de.Message);
     }
 }
開發者ID:JurgenCox,項目名稱:compbio-base,代碼行數:17,代碼來源:PdfGraphics.cs

示例8: CreateDocument

    public static void CreateDocument(Stream stream, Action<Document> action)
    {
        using (var document = new Document(PageSize.A4))
            {
                var writer = PdfWriter.GetInstance(document, stream);
                document.Open();
                document.AddAuthor(Author);
                document.AddCreator(DocumentCreator);
                document.AddKeywords(DocumentKeywords);
                document.AddSubject(DocumentSubject);
                document.AddTitle(DocumentTitle);

                action.Invoke(document);

                document.Close();
            }
    }
開發者ID:mesutcakir,項目名稱:ITextSharpPdfGeneratorHelper,代碼行數:17,代碼來源:ITextSharpPdfGeneratorHelper.cs

示例9: PdfGraphics

 internal PdfGraphics(string filename, int width, int height)
 {
     originalWidth = currentWidth = width;
     originalHeight = currentHeight = height;
     document = new Document(new iTextSharp.text.Rectangle(width, height), 50, 50, 50, 50);
     document.AddAuthor("");
     document.AddSubject("");
     try{
         writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
         document.Open();
         content = writer.DirectContent;
         template = topTemplate = content.CreateTemplate(width, height);
         content.AddTemplate(template, 0, 0);
     } catch (DocumentException de){
         throw new IOException(de.Message);
     }
 }
開發者ID:neuhauser,項目名稱:compbio-base,代碼行數:17,代碼來源:PdfGraphics.cs

示例10: CreatePdf

// ---------------------------------------------------------------------------
/**
 * Creates a PDF document.
 */
    public byte[] CreatePdf() {
      using (MemoryStream ms = new MemoryStream()) {
        // step 1
        using (Document document = new Document()) {
          // step 2
          PdfWriter.GetInstance(document, ms);
          // step 3
          document.AddTitle("Hello World example");
          document.AddAuthor("Bruno Lowagie");
          document.AddSubject("This example shows how to add metadata");
          document.AddKeywords("Metadata, iText, PDF");
          document.AddCreator("My program using iText");
          document.Open();
          // step 4
          document.Add(new Paragraph("Hello World"));
        }
        return ms.ToArray();    
      }
    }    
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:23,代碼來源:MetadataPdf.cs

示例11: Export

        //public void PDModel2Html(PDModel m)
        //{
        //    Export(m, ExportTyep.HTML);
        //}

        private void Export(IList<PDTable> tableList,string title, ExportTyep exportType)
        {
            Document doc = new Document(PageSize.A4.Rotate(), 20, 20, 20, 20);
            DocWriter w;

            switch (exportType)
            {
                case ExportTyep.PDF:
                    w = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                    break;
                case ExportTyep.RTF:
                    w = RtfWriter2.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                    break;
                //case ExportTyep.HTML:
                //    w = HtmlWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create, FileAccess.Write));
                //break;
                default:
                    break;
            }

            doc.Open();
            doc.NewPage();

            //IList<PDTable> tableList = m.AllTableList;

            //Chapter cpt = new Chapter(m.Name, 1);
            Chapter cpt = new Chapter(title, 1);
            Section sec;

            //doc.AddTitle(m.Name);
            doc.AddTitle(title);
            doc.AddAuthor("Kalman");
            doc.AddCreationDate();
            doc.AddCreator("Kalman");
            doc.AddSubject("PDM數據庫文檔");

            foreach (PDTable table in tableList)
            {
                sec = cpt.AddSection(new Paragraph(string.Format("{0}[{1}]", table.Name, table.Code), font));

                if (string.IsNullOrEmpty(table.Comment) == false)
                {
                    Chunk chunk = new Chunk(table.Comment, font);
                    sec.Add(chunk);
                }

                t = new Table(9, table.ColumnList.Count);

                //t.Border = 15;
                //t.BorderColor = Color.BLACK;
                //t.BorderWidth = 1.0f;
                t.AutoFillEmptyCells = true;
                t.CellsFitPage = true;
                t.TableFitsPage = true;
                t.Cellpadding = 3;
                //if (exportType == ExportTyep.PDF) t.Cellspacing = 2;
                t.DefaultVerticalAlignment = Element.ALIGN_MIDDLE;

                t.SetWidths(new int[] { 200, 200, 150, 50, 50, 50, 50, 50, 300 });

                t.AddCell(BuildHeaderCell("名稱"));
                t.AddCell(BuildHeaderCell("代碼"));
                t.AddCell(BuildHeaderCell("數據類型"));
                t.AddCell(BuildHeaderCell("長度"));
                t.AddCell(BuildHeaderCell("精度"));
                t.AddCell(BuildHeaderCell("主鍵"));
                t.AddCell(BuildHeaderCell("外鍵"));
                t.AddCell(BuildHeaderCell("可空"));
                t.AddCell(BuildHeaderCell("注釋"));

                foreach (PDColumn column in table.ColumnList)
                {
                    t.AddCell(BuildCell(column.Name));
                    t.AddCell(BuildCell(column.Code));
                    t.AddCell(BuildCell(column.DataType));
                    t.AddCell(BuildCell(column.Length == 0 ? "" : column.Length.ToString()));
                    t.AddCell(BuildCell(column.Precision == 0 ? "" : column.Precision.ToString()));
                    t.AddCell(BuildCell(column.IsPK ? " √" : ""));
                    t.AddCell(BuildCell(column.IsFK ? " √" : ""));
                    t.AddCell(BuildCell(column.Mandatory ? "" : " √"));
                    t.AddCell(BuildCell(column.Comment));
                }

                sec.Add(t);
            }

            doc.Add(cpt);
            doc.Close();
        }
開發者ID:Leafney,項目名稱:Kalman.Studio,代碼行數:94,代碼來源:Export.cs

示例12: CreateFactuur

        public static string CreateFactuur(Factuur factuur)
        {
            try
            {
                var filename = GenerateFileName(factuur);
                using (var fs = new FileStream(Path.Combine(FactuurFolder.FullName, filename), FileMode.Create))
                {
                    var document = new Document(PageSize.A4, 25, 25, 30, 1);
                    var writer = PdfWriter.GetInstance(document, fs);
                    writer.PageEvent = new FactuurHelper();
                    // Add meta information to the document
                    document.AddAuthor("Dura - Vanseveren");
                    document.AddCreator("DuraFact");
                    document.AddKeywords("Factuur");
                    document.AddSubject(string.Format("Factuur {0}", factuur.FactuurNummer));
                    document.AddTitle("Factuur");

                    // Open the document to enable you to write to the document
                    document.Open();

                    // Makes it possible to add text to a specific place in the document using
                    // a X & Y placement syntax.
                    var content = writer.DirectContent;
                    // Add a footer template to the document
                    //	content.AddTemplate(PdfFooter(content, factuur), 30, 1);

                    // Add a logo to the invoice
                    var img = DuraLogo;
                    img.ScalePercent(80);
                    img.SetAbsolutePosition(40, 650);
                    content.AddImage(img);

                    // First we must activate writing
                    content.BeginText();

                    // First we write out the header information
                    AddKlantData(factuur, content);
                    WriteText(content, "Factuur", 40, 600, 20, true);
                    AddFactuurData(factuur, content);

                    // You need to call the EndText() method before we can write graphics to the document!
                    content.EndText();
                    // Separate the header from the rows with a line
                    // Draw a line by setting the line width and position
                    content.SetLineWidth(0f);
                    content.MoveTo(40, 590);
                    content.LineTo(560, 590);
                    content.Stroke();
                    // Don't forget to call the BeginText() method when done doing graphics!
                    content.BeginText();
                    // Before we write the lines, it's good to assign a "last position to write"
                    // variable to validate against if we need to make a page break while outputting.
                    // Change it to 510 to write to test a page break; the fourth line on a new page
                    const int lastwriteposition = 150;

                    // Loop thru the table of items and set the linespacing to 12 points.
                    // Note that we use the -= operator, the coordinates goes from the bottom of the page!
                    var topMargin = 570;
                    if (!string.IsNullOrEmpty(factuur.Opmerking))
                    {
                        WriteText(content, "Opmerking", 40, topMargin, 12, true);
                        topMargin -= 20;
                        foreach (string s in factuur.Opmerking.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
                        {
                            WriteText(content, s, 40, topMargin, 10);
                            topMargin -= 16;
                        }
                        topMargin -= 4;
                    }

                    AddItemData(factuur, document, lastwriteposition, content, ref topMargin);

                    // You need to call the EndText() method before we can write graphics to the document!
                    content.EndText();
                    // Separate the header from the rows with a line
                    // Draw a line by setting the line width and position
                    content.SetLineWidth(0f);
                    content.MoveTo(40, topMargin);
                    content.LineTo(560, topMargin);
                    content.Stroke();
                    // Don't forget to call the BeginText() method when done doing graphics!
                    content.BeginText();
                    topMargin -= 15;
                    AddBTWData(factuur, content, topMargin);

                    // End the writing of text
                    content.EndText();

                    // Close the document, the writer and the filestream!
                    document.Close();
                    writer.Close();
                    fs.Close();
                    return Path.Combine(FactuurFolder.FullName, filename);
                }
            }
            catch
            {
                return string.Empty;
            }
        }
開發者ID:desmetjens,項目名稱:DuraFact,代碼行數:100,代碼來源:PDFGenerator.cs

示例13: GenerateHerinnering

        public static string GenerateHerinnering(Factuur factuur)
        {
            try
            {
                var filename = GenerateFileNameHerinnering(factuur);
                using (var fs = new FileStream(Path.Combine(HerinneringFolder.FullName, filename), FileMode.Create))
                {
                    var document = new Document(PageSize.A4, 25, 25, 30, 1);
                    var writer = PdfWriter.GetInstance(document, fs);

                    // Add meta information to the document
                    document.AddAuthor("Dura - Vanseveren");
                    document.AddCreator("DuraFact");
                    document.AddKeywords("Herinnering");
                    document.AddSubject(string.Format("Herinnering voor factuur {0}", factuur.FactuurNummer));
                    document.AddTitle("Herinnering");

                    // Open the document to enable you to write to the document
                    document.Open();

                    // Makes it possible to add text to a specific place in the document using
                    // a X & Y placement syntax.
                    var content = writer.DirectContent;
                    // Add a footer template to the document
                    //	content.AddTemplate(PdfFooter(content, factuur), 30, 1);

                    // Add a logo to the invoice
                    var img = DuraLogo;
                    img.ScalePercent(80);
                    img.SetAbsolutePosition(40, 650);
                    content.AddImage(img);

                    // First we must activate writing
                    content.BeginText();

                    // First we write out the header information
                    AddKlantData(factuur, content);
                    WriteText(content, string.Format("Tielt, {0}", DateTime.Now.ToShortDateString()), 40, 600, 10);
                    WriteText(content, "Herinnering", 40, 550, 20, true);

                    WriteText(content, "Geachte heer/mevrouw", 40, 520, 10);
                    WriteText(content, string.Format("Wij hebben bij u een betalingsachterstand van {0:C} geconstateerd.", factuur.TotaalIncl), 40, 500, 10);
                    WriteText(content, "Dit bedrag heeft betrekking op de onderstaande factuur:", 40, 485, 10);

                    const int aantalMargin = 230, ehprijsMargin = 300, totaalMargin = 460;

                    WriteText(content, "Factuur", 140, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, "Datum", aantalMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, "Bedrag", ehprijsMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, "Betalingskenmerk", totaalMargin, 460, 12, true, PdfContentByte.ALIGN_RIGHT);

                    WriteText(content, factuur.FactuurNummer.ToString(), 140, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, factuur.FacturatieDatum.ToShortDateString(), aantalMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, string.Format("{0:C}", factuur.TotaalIncl), ehprijsMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);
                    WriteText(content, factuur.FacturatieDatum.ToShortDateString(), totaalMargin, 440, 10, false, PdfContentByte.ALIGN_RIGHT);

                    WriteText(content, string.Format("Wij verzoeken u nu vriendelijk het bovenstaande bedrag zulks ten bedrage van {0:C} te doen overmaken.", factuur.TotaalIncl), 40, 400, 10);
                    WriteText(content, "Dit kan op rekeningnummer 733-0318587-69 bij KBC of 001-6090654-03 bij BNP Paribas Fortis onder vermelding", 40, 385, 10);
                    WriteText(content, "van uw betalingskenmerk.", 40, 370, 10);
                    WriteText(content, "Wanneer u vragen mocht hebben over deze herinnering, verzoeken wij u zo spoedig mogelijk contact op te nemen", 40, 355, 10);
                    WriteText(content, "op het telefoonnummer (051) 40 34 77.", 40, 340, 10);
                    WriteText(content, "Heeft u inmiddels uw betalingsachterstand voldaan, dan is deze herinnering voor u niet meer van toepassing.", 40, 325, 10);
                    WriteText(content, "Hoogachtend,", 40, 280, 10);
                    WriteText(content, "Filip Vanseveren", 40, 180, 10);

                    // End the writing of text
                    content.EndText();

                    // Close the document, the writer and the filestream!
                    document.Close();
                    writer.Close();
                    fs.Close();
                    return Path.Combine(HerinneringFolder.FullName, filename);
                }
            }
            catch
            {
                return string.Empty;
            }
        }
開發者ID:desmetjens,項目名稱:DuraFact,代碼行數:80,代碼來源:PDFGenerator.cs

示例14: PrintTerms

        private MemoryStream PrintTerms(IEnumerable<GlossaryItem> terms)
        {
            float ppi = 72.0F;
            float PageWidth = 8.5F;
            float PageHeight = 11.0F;
            float TopBottomMargin = 0.625F;
            float LeftRightMargin = 0.75F;
            float GutterWidth = 0.25F;
            float HeaderFooterHeight = 0.125F;
            float Column1Left = LeftRightMargin;
            float Column1Right = ((PageWidth - (LeftRightMargin * 2) - GutterWidth) / 2) + LeftRightMargin;
            float Column2Left = Column1Right + GutterWidth;
            float Column2Right = PageWidth - LeftRightMargin;

            bool HasMultipleDefinitions = (terms.Count() > 1);

            string version = DataAccess.GetKeyValue("glossaryversion").Value;

            Document doc = new Document(new Rectangle(0, 0, PageWidth * ppi, PageHeight * ppi));

            MemoryStream m = new MemoryStream();

            PdfWriter writer = PdfWriter.GetInstance(doc, m);
            writer.CloseStream = false;

            try {
                doc.AddTitle("The Glossary of Systematic Christian Theology");
                doc.AddSubject("A collection of technical terms and associated definitions as taught from the pulpit by Dr. Ron Killingsworth in classes at Rephidim Church.");
                doc.AddCreator("My program using iText#");
                doc.AddAuthor("Dr. Ron Killingsworth");
                doc.AddCreationDate();

                writer.SetEncryption(PdfWriter.STRENGTH128BITS, null, "xaris", PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowDegradedPrinting);

                doc.Open();

                BaseFont bfArialBlack = BaseFont.CreateFont("C:\\windows\\fonts\\ariblk.ttf", BaseFont.WINANSI, false);
                BaseFont bfGaramond = BaseFont.CreateFont("C:\\windows\\fonts\\gara.ttf", BaseFont.WINANSI, false);
                Font fntTerm = new Font(bfArialBlack, 10, Font.BOLD, new BaseColor(57, 81, 145));
                Font fntDefinition = new Font(bfGaramond, 9, Font.NORMAL, new BaseColor(0, 0, 0));

                ///////////////////////////////////////////

                if (HasMultipleDefinitions) {
                    PdfContentByte cbCover = new PdfContentByte(writer);
                    cbCover = writer.DirectContent;

                    cbCover.BeginText();

                    cbCover.SetFontAndSize(bfGaramond, 42);
                    cbCover.SetRGBColorFill(57, 81, 145);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Glossary of", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(1.5)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Systematic Christian Theology", (PageWidth / 2) * ppi, ((PageHeight / 2) + 1) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 16);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "A collection of technical terms and associated definitions", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.6)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "as taught by Dr. Ron Killingsworth, Rephidim Church, Wichita Falls, Texas", (PageWidth / 2) * ppi, ((PageHeight / 2) + Convert.ToSingle(0.4)) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 12);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Published by:", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.6)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "Rephidim Doctrinal Bible Studies, Inc.", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(0.8)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "4430 Allendale Rd., Wichita Falls, Texas 76310", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.0)) * ppi, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_CENTER, "(940) 691-1166     rephidim.org     [email protected]", (PageWidth / 2) * ppi, ((PageHeight / 2) - Convert.ToSingle(1.2)) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Version: " + version + " / " + terms.Count() + " terms", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "© 1971-" + DateTime.Today.Year.ToString() + " Dr. Ron Killingsworth, Rephidim Doctrinal Bible Studies, Inc.", (PageWidth - LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbCover.EndText();

                    doc.NewPage();

                    ///////////////////////////////////////////

                    PdfContentByte cbBlank = new PdfContentByte(writer);
                    cbBlank = writer.DirectContent;

                    cbBlank.BeginText();

                    cbCover.SetFontAndSize(bfGaramond, 10);
                    cbCover.SetRGBColorFill(0, 0, 0);
                    cbCover.ShowTextAligned(PdfContentByte.ALIGN_LEFT, " ", (LeftRightMargin) * ppi, (TopBottomMargin) * ppi, 0);

                    cbBlank.EndText();

                    doc.NewPage();

                    ///////////////////////////////////////////

                }

                PdfContentByte cb = writer.DirectContent;
                ColumnText ct = new ColumnText(cb);

//.........這裏部分代碼省略.........
開發者ID:jslaybaugh,項目名稱:rephidim-web,代碼行數:101,代碼來源:GlossaryController.cs

示例15: GeneratePDF

    protected void GeneratePDF()
    {
        // Refresh the summary grid else there will be nothing to generate (no postback)
        this.PopulateGrid();

        // Create and initialize a new document object
        iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.LEGAL, 24, 24, 24, 24);
        document.PageSize.Rotate();
        System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();

        try
        {
            // Create an instance of the writer object
            iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, memoryStream);

            // Add some meta information to the document
            Label lblPageTitle = (Label)(this.Page.Master.FindControl("lblDefaultMasterPageTitle"));
            document.AddAuthor(lblPageTitle.Text);
            document.AddSubject(this.lblReportTitle.Text);

            // Open the document
            document.Open();

            // Create a table to match our current summary grid
            iTextSharp.text.Table table = null;

            if (this.DateRangeType == DateRangeTypes.UserSpecified)
                table = new iTextSharp.text.Table(6);
            else if (this.DateRangeType == DateRangeTypes.Daily)
                table = new iTextSharp.text.Table(7);
            else
                table = new iTextSharp.text.Table(8);

            table.TableFitsPage = true;

            // Apply spacing/padding/borders/column widths to the table
            table.Padding = 2;
            table.Spacing = 0;
            table.DefaultCellBorderWidth = 1;

            if (this.DateRangeType == DateRangeTypes.UserSpecified)
            {
                float[] headerwidths1 = { 30, 30, 30, 30, 30, 30 };
                table.Widths = headerwidths1;
            }
            else if (this.DateRangeType == DateRangeTypes.Daily)
            {
                float[] headerwidths2 = { 40, 30, 30, 30, 30, 30, 30 };
                table.Widths = headerwidths2;
            }
            else
            {
                float[] headerwidths3 = { 40, 30, 30, 30, 30, 30, 30, 35 };
                table.Widths = headerwidths3;
            }

            table.Width = 100;

            // Add report title spanning all columns
            iTextSharp.text.Font titleFont = new iTextSharp.text.Font(Font.GetFamilyIndex("Tahoma"), 6, Font.BOLD);
            titleFont.Color = new iTextSharp.text.Color(System.Drawing.Color.Firebrick);

            iTextSharp.text.Cell titleCell = new iTextSharp.text.Cell();
            titleCell.SetHorizontalAlignment("Left");
            titleCell.SetVerticalAlignment("Top");
            titleCell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.White);
            titleCell.BorderWidth = 0;

            if (this.DateRangeType == DateRangeTypes.UserSpecified)
                titleCell.Colspan = 6;
            else if (this.DateRangeType == DateRangeTypes.Daily)
                titleCell.Colspan = 7;
            else
                titleCell.Colspan = 8;

            titleCell.AddElement(new iTextSharp.text.Phrase(this.lblReportTitle.Text, titleFont));
            table.AddCell(titleCell);

            // Add table headers
            for (int i = 0; i < this.grdRaveForm.Columns.Count; i++)
            {
                iTextSharp.text.Font headerCellFont = new iTextSharp.text.Font(Font.GetFamilyIndex("Tahoma"), 8, Font.NORMAL + Font.UNDERLINE);
                headerCellFont.Color = new iTextSharp.text.Color(System.Drawing.Color.White);

                iTextSharp.text.Cell headerCell = new iTextSharp.text.Cell();
                headerCell.SetHorizontalAlignment("Left");
                headerCell.SetVerticalAlignment("Top");
                headerCell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.SteelBlue);
                headerCell.BorderColor = new iTextSharp.text.Color(System.Drawing.Color.White);

                headerCell.AddElement(new iTextSharp.text.Phrase(this.grdRaveForm.Columns[i].HeaderText, headerCellFont));
                table.AddCell(headerCell);
            }

            table.EndHeaders();

            // Add data to the table
            int j = 0;
            int k = 0;
            string phrase = "";
//.........這裏部分代碼省略.........
開發者ID:vorman,項目名稱:WebStats,代碼行數:101,代碼來源:RaveForm.ascx.cs


注:本文中的iTextSharp.text.Document.AddSubject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。