当前位置: 首页>>代码示例>>C#>>正文


C# DocumentObjectModel.Document类代码示例

本文整理汇总了C#中MigraDoc.DocumentObjectModel.Document的典型用法代码示例。如果您正苦于以下问题:C# Document类的具体用法?C# Document怎么用?C# Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Document类属于MigraDoc.DocumentObjectModel命名空间,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DemonstrateAlignment

    static void DemonstrateAlignment(Document document)
    {
    	try {
	      document.LastSection.AddParagraph("Alignment", "Heading2");
	
	      document.LastSection.AddParagraph("Left Aligned", "Heading3");
	
	      Paragraph paragraph = document.LastSection.AddParagraph();
	      paragraph.Format.Alignment = ParagraphAlignment.Left;
	      paragraph.AddText("Algo de texto");
	
	      document.LastSection.AddParagraph("Right Aligned", "Heading3");
	
	      paragraph = document.LastSection.AddParagraph();
	      paragraph.Format.Alignment = ParagraphAlignment.Right;
	      paragraph.AddText("Algo de texto");
	
	      document.LastSection.AddParagraph("Centered", "Heading3");
	
	      paragraph = document.LastSection.AddParagraph();
	      paragraph.Format.Alignment = ParagraphAlignment.Center;
	      paragraph.AddText("Algo de texto");
	
	      document.LastSection.AddParagraph("Justified", "Heading3");
	
	      paragraph = document.LastSection.AddParagraph();
	      paragraph.Format.Alignment = ParagraphAlignment.Justify;
	      paragraph.AddText("Algo de texto");
    	} catch (Exception ex) {
    		throw ex;
    	}
     
    }
开发者ID:jiashida,项目名称:cameratrapmanager,代码行数:33,代码来源:Paragraphs.cs

示例2: CreateDocument

        public void CreateDocument(DataTable dt, string filename)
        {
            // Create a new MigraDoc document
            this.document = new Document();
            this.document.Info.Title = "A sample invoice";
            this.document.Info.Subject = "Demonstrates how to create an invoice.";
            this.document.Info.Author = "Stefan Lange";

            DefineStyles();

            CreatePage();

            FillContent(dt);

            // Create a renderer for PDF that uses Unicode font encoding.
            var pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document.
            pdfRenderer.Document = document;

            // Create the PDF document.
            pdfRenderer.RenderDocument();

            // Save the PDF document...
            //var filename = "Invoice.pdf";

            // I don't want to close the document constantly...
            //filename = "Invoice-" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf";

            pdfRenderer.Save(filename);
            // ...and start a viewer.
            //Process.Start(filename);
        }
开发者ID:toaap,项目名称:RegionSkane,代码行数:33,代码来源:PrintUtils.cs

示例3: ReportTools

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="doc"></param>
        public ReportTools(Document doc)
        {
            document = doc;
            DefineStyles(document);

            section = document.AddSection();
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:11,代码来源:ReportTools.cs

示例4: AddTripSummary

        public static void AddTripSummary(Document document, BookingInfo booking)
        {
            Table table = document.LastSection.AddTable();
            table.Borders.Visible = true;
            table.TopPadding = TopPadding;
            table.BottomPadding = BottomPadding;
            table.Format.Alignment = ParagraphAlignment.Justify;
            table.Rows.Height = 1;

            Column column = table.AddColumn("5cm");
            column.Format.Alignment = ParagraphAlignment.Right;
            column = table.AddColumn("11cm");
            column.Format.Alignment = ParagraphAlignment.Left;

            table.AddTableHeader("TRIP SUMMARY");
            table.AddTableRow("City of service:", booking.City, "Normal");
            table.AddTableRow("Type of Journey:", booking.TypeOfJourney, "Normal");
            table.AddTableRow("Pick-Up  Date/Time:", booking.PickUpTime, "NormalBold");
            table.AddTableRow("Type of Vehicle:", booking.Vehicle, "Normal");
            table.AddTableRow("Pick-Up Location:", booking.PickUp, "NormalBold");
            table.AddTableRow("Drop-Off Location:", booking.DropOff, "NormalBold");
            if (booking.Stops.Count() > 0)
                table.AddStopTableRow("Added Stops (" + booking.Stops.Count() + "):", booking.Stops, "Normal");
            table.AddTableFooter("");
        }
开发者ID:felixthehat,项目名称:Limo,代码行数:25,代码来源:BookingVoucher.TripSummary.cs

示例5: DefineCover

    /// <summary>
    /// Defines the cover page.
    /// </summary>
    public static void DefineCover(Document document, Project currentProject)
    {
    	try {
    		Section section = document.AddSection();

		    Paragraph paragraph = section.AddParagraph();
		    paragraph.Format.SpaceAfter = "3cm";
				    
		    Image image = section.AddImage(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location)[email protected]"\\logo.jpg");
		    image.Width = "6cm";
		
		    paragraph = section.AddParagraph("Report generated using Cameratrap Manager\nfor the project:\n"+currentProject.Name);
		    paragraph.Format.Font.Size = 16;
		    paragraph.Format.Font.Color = Colors.DarkRed;
		    paragraph.Format.SpaceBefore = "6cm";
		    paragraph.Format.SpaceAfter = "3cm";
		
		    paragraph=section.AddParagraph("Creation date: " + currentProject.StartDate.ToString());
		    paragraph=section.AddParagraph("Last modified: " + currentProject.CompletionDate.ToString());
		      
		    paragraph = section.AddParagraph("Rendering date: ");
		    paragraph.AddDateField();
    	} catch (Exception ex) {
    		throw ex;
    	}
    	
     
    }
开发者ID:jiashida,项目名称:cameratrapmanager,代码行数:31,代码来源:Cover.cs

示例6: TestSpecialCharacters

//    [UnitTestFunction]
    public static void TestSpecialCharacters()
    {
      Document doc = new Document();
      Section sec = doc.Sections.AddSection();
      Paragraph par = sec.AddParagraph();
      par.AddCharacter('\x93');
      par.AddCharacter(SymbolName.Blank);
      par.AddCharacter(SymbolName.Bullet);
      par.AddCharacter(SymbolName.Copyright);
      par.AddCharacter(SymbolName.Em);
      par.AddCharacter(SymbolName.Em4);
      par.AddCharacter(SymbolName.EmDash);
      par.AddCharacter(SymbolName.En);
      par.AddCharacter(SymbolName.EnDash);
      par.AddCharacter(SymbolName.Euro);
      par.AddCharacter(SymbolName.HardBlank);
      par.AddCharacter(SymbolName.LineBreak);
      par.AddCharacter(SymbolName.Not);
      par.AddCharacter(SymbolName.ParaBreak);
      par.AddCharacter(SymbolName.RegisteredTrademark);
      par.AddCharacter(SymbolName.Tab);
      par.AddCharacter(SymbolName.Trademark);

      DocumentRenderer docRndrr = new DocumentRenderer();
      docRndrr.Render(doc, "RtfSpecialChars.txt", null);

      File.Copy("RtfSpecialChars.txt", "RtfSpecialChars.rtf", true);
      System.Diagnostics.Process.Start("RtfSpecialChars.txt");
    }
开发者ID:Sl0vi,项目名称:MigraDoc,代码行数:30,代码来源:RtfDocumentArea.cs

示例7: BuildDocument

        public override Document BuildDocument()
        {
            Document retVal = new Document();

            Log.Info("Creating findings report");
            retVal.Info.Title = "EFS Subset-076 Findings report";
            retVal.Info.Author = "ERTMS Solutions";
            retVal.Info.Subject = "Subset-076 findings report";

            FindingsReport report = new FindingsReport(retVal);

            if (addReviewed)
            {
                report.ReviewedParagraphs = false;
                BuildSections(report);
            }

            if (addNotReviewed)
            {
                report.ReviewedParagraphs = true;
                BuildSections(report);
            }

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:25,代码来源:FindingsReportHandler.cs

示例8: DemonstrateAlignment

    static void DemonstrateAlignment(Document document)
    {
      document.LastSection.AddParagraph("Alignment", "Heading2");

      document.LastSection.AddParagraph("Left Aligned", "Heading3");

      Paragraph paragraph = document.LastSection.AddParagraph();
      paragraph.Format.Alignment = ParagraphAlignment.Left;
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("Right Aligned", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.Alignment = ParagraphAlignment.Right;
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("Centered", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.Alignment = ParagraphAlignment.Center;
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("Justified", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.Alignment = ParagraphAlignment.Justify;
      paragraph.AddText(FillerText.MediumText);
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:28,代码来源:Paragraphs.cs

示例9: DemonstrateIndent

    static void DemonstrateIndent(Document document)
    {
      document.LastSection.AddParagraph("Indent", "Heading2");

      document.LastSection.AddParagraph("Left Indent", "Heading3");

      Paragraph paragraph = document.LastSection.AddParagraph();
      paragraph.Format.LeftIndent = "2cm";
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("Right Indent", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.RightIndent = "1in";
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("First Line Indent", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.FirstLineIndent = "12mm";
      paragraph.AddText(FillerText.Text);

      document.LastSection.AddParagraph("First Line Negative Indent", "Heading3");

      paragraph = document.LastSection.AddParagraph();
      paragraph.Format.LeftIndent = "1.5cm";
      paragraph.Format.FirstLineIndent = "-1.5cm";
      paragraph.AddText(FillerText.Text);
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:29,代码来源:Paragraphs.cs

示例10: Convert

        public Boolean Convert(String inputFileName, String outputFileName)
        {
            try
            {
                var text = File.ReadAllText(inputFileName);

                // Create a MigraDoc document
                Document document = new Document();
                var section = document.AddSection();
                var paragraph = section.AddParagraph();
                paragraph.Format.Font.Size = 12;
                paragraph.AddFormattedText(text);


                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
                pdfRenderer.Document = document;
                pdfRenderer.RenderDocument();
                pdfRenderer.PdfDocument.Save(outputFileName);
                return true;
            }
            catch (Exception ex)
            {
                Logger.WarnFormat(ex, "Error converting file {0} to Pdf.", inputFileName);
                return false;
            }
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:26,代码来源:TextPdfConverter.cs

示例11: CreateDocument

        private static Document CreateDocument(string title, string subject)
        {
            Document document = new Document();
            #region DocInfo
            document.Info.Title = title;
            document.Info.Subject = subject;
            Locales currentLocale = LocalesExtension.LocalesFromString(Thread.CurrentThread.CurrentUICulture.Name);
            document.Info.Author = "RecruitmentSystem";
            #endregion
            #region DocStyle
            //Set normal text styles
            Style style = document.Styles[StyleNames.Normal];
            style.Font.Name = "Arial";

            //Set header styles
            style = document.Styles[StyleNames.Header];
            style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);

            //Set footer styles
            style = document.Styles[StyleNames.Footer];
            style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);

            //Add table style
            style = document.Styles.AddStyle("Table", StyleNames.Normal);
            style.Font.Name = "Arial";
            style.Font.Size = 9;
            #endregion

            return document;
        }
开发者ID:majilik,项目名称:RecruitmentSystem,代码行数:30,代码来源:PdfGenerator.cs

示例12: DoRender

        /// <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);
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:37,代码来源:DateControlRenderer.cs

示例13: crearPdf

        public string crearPdf(string[] fotos)
        {

            Document document = new Document();
            PdfDocument pdfDocument = new PdfDocument();
            document.DefaultPageSetup.PageFormat = PageFormat.A4;
            document.DefaultPageSetup.LeftMargin = "1cm";
            document.DefaultPageSetup.TopMargin = "1cm";
            setDocumentStyle(ref document);
            string footerText = "LISTADO DE CODIGO DE BARRAS POR PROPIETARIO CON NIT Y NUMERO DE UNIDAD ";
            setDocumentHeaders2(
                 ref document,
                 footerText
            );
            foreach (string foto in fotos)
            {
                document.LastSection.AddImage(foto);
                
              //document.Section.AddImage(foto);
              //deja codigo de barras por pagina document.AddSection();
              //duplica la imagendocument.LastSection.AddImage(foto);
            }
            PdfDocumentRenderer pdfDocumentRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
            pdfDocumentRenderer.Document = document;
            pdfDocumentRenderer.RenderDocument();
            string filename = "archivopdf\\ARCHIVO_CODIGO_DE_BARRAS.pdf";
            pdfDocumentRenderer.PdfDocument.Save(filename);
            return filename;
            }
开发者ID:jennifervpacheco,项目名称:apppacheco,代码行数:29,代码来源:Pdf.cs

示例14: setDocumentStyle

 private void setDocumentStyle(ref Document document)
 {
     Style style = document.Styles["Normal"];
     style.Font.Name = "Calibri";
     style = document.Styles[StyleNames.Header];
     //style.Section.PageSetupHeaders.EvenPage.AddTable();
     style.ParagraphFormat.AddTabStop("1cm", TabAlignment.Center);
     style = document.Styles[StyleNames.Footer];
     style.ParagraphFormat.AddTabStop("1cm", TabAlignment.Center);
     style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
     style.ParagraphFormat.Font.Bold = false;
     style.ParagraphFormat.Font.Size = 7;
     style = document.Styles[StyleNames.Heading1];
     style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
     style.ParagraphFormat.Font.Bold = true;
     style = document.Styles[StyleNames.Heading2];
     style.ParagraphFormat.Font.Bold = false;
     style = document.Styles[StyleNames.Heading3];
     style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
     style.ParagraphFormat.Font.Bold = true;
     style.ParagraphFormat.Font.Size = 6;
     style = document.Styles[StyleNames.Heading4];
     style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
     style.ParagraphFormat.Font.Bold = false;
     style.ParagraphFormat.Font.Size = 8;
     style = document.Styles[StyleNames.Heading5];
     style.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
     style.ParagraphFormat.Font.Bold = false;
     style.ParagraphFormat.Font.Size = 7;
 }
开发者ID:jennifervpacheco,项目名称:apppacheco,代码行数:30,代码来源:Pdf.cs

示例15: Run

        void Run()
        {
            if (File.Exists(outputName))
            {
                File.Delete(outputName);
            }

            var doc = new Document();
            doc.DefaultPageSetup.Orientation = Orientation.Portrait;
            doc.DefaultPageSetup.PageFormat = PageFormat.A4;
            //doc.DefaultPageSetup.LeftMargin = Unit.FromMillimeter(5.0);
            //doc.DefaultPageSetup.RightMargin = Unit.FromMillimeter(5.0);
            //doc.DefaultPageSetup.BottomMargin = Unit.FromMillimeter(5.0);
            //doc.DefaultPageSetup.TopMargin = Unit.FromMillimeter(5.0);
            StyleDoc(doc);
            var section = doc.AddSection();
            var footer = new TextFrame();

            section.Footers.Primary.Add(footer);
            var html = File.ReadAllText("example.html");
            section.AddHtml(html);

            var renderer = new PdfDocumentRenderer();
            renderer.Document = doc;
            renderer.RenderDocument();

            renderer.Save(outputName);
            Process.Start(outputName);
        }
开发者ID:jgshumate1,项目名称:MigraDoc.Extensions,代码行数:29,代码来源:Program.cs


注:本文中的MigraDoc.DocumentObjectModel.Document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。