Пример #1
0
    /// <summary>
    /// Defines page setup, headers, and footers.
    /// </summary>
    static void DefineContentSection(Document document, Project currentProject)
    {
    	try {
    	  Section section = document.AddSection();
	      section.PageSetup.OddAndEvenPagesHeaderFooter = true;
	      section.PageSetup.StartingNumber = 1;
	
	      HeaderFooter header = section.Headers.Primary;
	      header.AddParagraph(currentProject.Name);
	      
	      header = section.Headers.EvenPage;
	      header.AddParagraph(currentProject.Name);
	
	      // Create a paragraph with centered page number. See definition of style "Footer".
	      Paragraph paragraph = new Paragraph();
	      paragraph.AddTab();
	      paragraph.AddPageField();
	
	      // Add paragraph to footer for odd pages.
	      section.Footers.Primary.Add(paragraph);
	      // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
	      // not belong to more than one other object. If you forget cloning an exception is thrown.
	      section.Footers.EvenPage.Add(paragraph.Clone());
    	} catch (Exception ex) {
    		throw ex;
    	}
     
    }
        /// <summary>
        /// Renders <paramref name="control"/> to the <paramref name="document"/>.
        /// </summary>
        /// <param name="document">The PDF document.</param>
        /// <param name="control">The control to be rendered.</param>
        /// <param name="level">The depth down the control tree being rendered (affects indenting).</param>
        /// <param name="controlList">The complete control list.</param>
        protected override void DoRender(Document document, Control control, int level, ControlList controlList)
        {
            TextFrame frameTemplate = this.CreateCharacterInputBox(document.Styles[StyleNames.Normal]);

            Paragraph paragraphTemplate = new Paragraph
                                              {
                                                  Style = StyleNames.Normal,
                                                  Format = { Alignment = ParagraphAlignment.Justify, Font = { Color = Colors.LightGray } }
                                              };
            Unit spacer = new Unit((frameTemplate.Width.Point - paragraphTemplate.Format.Font.Size.Point) / 4, UnitType.Point);
            paragraphTemplate.Format.SpaceBefore = spacer;
            paragraphTemplate.Format.LeftIndent = spacer;
            frameTemplate.MarginBottom = frameTemplate.Height;

            for (int i = 0; i < 8; i++)
            {
                TextFrame frame = frameTemplate.Clone();
                frame.WrapFormat.DistanceLeft = (frame.Width * i) + (new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter));
                string watermark = i < 2 ? "D" : i < 4 ? "M" : "Y";
                Paragraph paragraph = paragraphTemplate.Clone();
                paragraph.AddText(watermark);
                frame.Add(paragraph);
                document.LastSection.Add(frame);
            }

            TextFrame clearFrame = frameTemplate.Clone();
            clearFrame.WrapFormat.Style = WrapStyle.TopBottom;
            clearFrame.LineFormat.Width = 0;
            document.LastSection.Add(clearFrame);
        }
Пример #3
0
        /// <summary>
        /// Defines page setup, headers, and footers.
        /// </summary>
        private static void DefineContentSection(Document document, List<QueryData> data )
        {
            Section section = document.AddSection();
            //section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            HeaderFooter header = section.Headers.Primary;
            header.AddParagraph(data[0].ProjectName + " - Отчет проверки данных от " + DateTime.Now.ToShortDateString() );
            header.Format.Alignment = ParagraphAlignment.Center;
            // Create a paragraph with centered page number. See definition of style "Footer".
            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();
            paragraph.AddText(" из ");
            paragraph.AddNumPagesField();
            // Add paragraph to footer for odd pages.
            section.Footers.Primary.Add(paragraph);
            // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
            // not belong to more than one other object. If you forget cloning an exception is thrown.
            section.Footers.EvenPage.Add(paragraph.Clone());
        }
Пример #4
0
        void DefineRevisionHistory(Document document, string fontName, Color fontColor, List<RevisionHistory> listRevisionHistory)
        {
            Section section = document.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();

            section.Headers.Primary.Add(paragraph);
            section.Headers.EvenPage.Add(paragraph.Clone());

            DocumentFormat.DefineHeading(document, "Revision History", "Heading1", "Revision History");
            DocumentFormat.DefineParagraph(document, "", ParagraphAlignment.Center);

            string[] strArrayHeader = new string[4] { "Version", "Author", "Issue Date", "Changes" };
            string[] strArrayHeaderSize = new string[4] { (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm", (PageWidth / 4).ToString() + "cm" };
            Table table = DocumentFormat.CreateSimpleTable(strArrayHeader, strArrayHeaderSize, DataStaging.GetStrMatrixFromListRevisionHistory(listRevisionHistory), FontName, Colors.Black, Colors.LightGray, 12, 0.5, 0.5, true);

            document.LastSection.Add(table);
        }
Пример #5
0
        private void defineFooter()
        {
            Section section = document.AddSection();
            section.PageSetup.OddAndEvenPagesHeaderFooter = true;
            section.PageSetup.StartingNumber = 1;

            HeaderFooter header = section.Headers.Primary;

            header = section.Headers.EvenPage;

            // Create a paragraph with centered page number. See definition of style "Footer".
            Paragraph paragraph = new Paragraph();
            paragraph.AddTab();
            paragraph.AddPageField();

            // Add paragraph to footer for odd pages.
            section.Footers.Primary.Add(paragraph);
            // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
            // not belong to more than one other object. If you forget cloning an exception is thrown.
            section.Footers.EvenPage.Add(paragraph.Clone());
        }