本文整理汇总了C#中MigraDoc.DocumentObjectModel.Document.AddSection方法的典型用法代码示例。如果您正苦于以下问题:C# Document.AddSection方法的具体用法?C# Document.AddSection怎么用?C# Document.AddSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigraDoc.DocumentObjectModel.Document
的用法示例。
在下文中一共展示了Document.AddSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineContentSection
/// <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;
}
}
示例2: SetDocument
private void SetDocument(ref Document document, Order order)
{
var tableColor = new Color(0, 0, 0, 0);
Section section = document.AddSection();
//HEADER
SetHeader(ref section);
//FOOTER
SetFooter(ref section);
//INFO
SetInfo(order, ref section);
//TABLE STYLE
Table table = SetTableStyle(ref section, tableColor);
//HEADERS
SetTableHeader(ref table, tableColor);
//ITEMS
SetTableData(order, ref table);
//SUMMARY
SetTableSummary(order, ref table);
}
示例3: 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);
}
示例4: 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;
}
}
示例5: Alignment
/// <summary>
/// Tests alignments.
/// </summary>
public static void Alignment(string pdfOutputFile)
{
Document document = new Document();
Section section = document.AddSection();
section.PageSetup.LeftMargin = 0;
section.PageSetup.RightMargin = 0;
Paragraph par = section.AddParagraph();
// FillFormattedParagraph(par);
// par.Format.Alignment = ParagraphAlignment.Left;
// par = section.AddParagraph();
// FillFormattedParagraph(par);
// par.Format.Alignment = ParagraphAlignment.Right;
// par = section.AddParagraph();
FillFormattedParagraph(par);
par.Format.Alignment = ParagraphAlignment.Center;
//
// par = section.AddParagraph();
// FillFormattedParagraph(par);
// par.Format.Alignment = ParagraphAlignment.Justify;
par.Format.FirstLineIndent = "-2cm";
par.Format.LeftIndent = "2cm";
par.Format.RightIndent = "3cm";
PdfDocumentRenderer renderer = new PdfDocumentRenderer();
renderer.Document = document;
renderer.RenderDocument();
renderer.PdfDocument.Save(pdfOutputFile);
}
示例6: 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;
}
}
示例7: ReportTools
/// <summary>
/// Constructor
/// </summary>
/// <param name="doc"></param>
public ReportTools(Document doc)
{
document = doc;
DefineStyles(document);
section = document.AddSection();
}
示例8: CreateSample1
/// <summary>
/// Creates the initial sample document.
/// </summary>
public static Document CreateSample1()
{
// Create a new MigraDoc document
Document document = new Document();
// Add a section to the document
Section section = document.AddSection();
// Add a paragraph to the section
Paragraph paragraph = section.AddParagraph();
// Add some text to the paragraph
paragraph.AddFormattedText("Hi!");
paragraph = section.AddParagraph();
paragraph.AddText("This is a MigraDoc document created for the DocumentViewer sample application.");
paragraph.AddText("The DocumentViewer demonstrates all techniques you need to preview and print a MigraDoc document, and convert it to a PDF, RTF, or image file.");
section.AddParagraph();
section.AddParagraph();
paragraph = section.AddParagraph("A4 portrait");
paragraph.Format.Font.Size = "1.5cm";
section.AddPageBreak();
section.AddParagraph().AddText("Page 2");
section = document.AddSection();
section.PageSetup.Orientation = Orientation.Landscape;
paragraph = section.AddParagraph("A4 landscape");
paragraph.Format.Font.Size = "1.5cm";
section.AddPageBreak();
section.AddParagraph().AddText("Page 4");
section = document.AddSection();
section.PageSetup.Orientation = Orientation.Portrait;
section.PageSetup.PageFormat = PageFormat.A5;
paragraph = section.AddParagraph("A5 portrait");
paragraph.Format.Font.Size = "1.5cm";
section.AddPageBreak();
section.AddParagraph().AddText("Page 6");
return document;
}
示例9: SingleRecipePDF
/// <summary>
/// Create a pdf file of a single recipe
/// </summary>
/// <param name="recipe">Recipe Entry</param>
/// <param name="filename">string of save location</param>
/// <param name="preview">bool</param>
public static void SingleRecipePDF(RecipeEntry recipe, string filename, bool preview)
{
Document file = new Document();
file.Info.Title = recipe.Name;
Section section = file.AddSection();
DrawRecipe(recipe, ref section);
SavePDF(file, filename, preview);
}
示例10: InitDocument
protected void InitDocument()
{
Document = new Document();
CurrentSection = Document.AddSection();
CurrentSection.PageSetup.PageFormat = PageFormat.A4;
CurrentSection.PageSetup.TopMargin = Unit.FromMillimeter(10);
CurrentSection.PageSetup.LeftMargin = Unit.FromMillimeter(10);
CurrentSection.PageSetup.RightMargin = Unit.FromMillimeter(10);
CurrentSection.PageSetup.BottomMargin = Unit.FromMillimeter(10);
}
示例11: Formatted
/// <summary>
/// Tests AddFormattedText.
/// </summary>
public static void Formatted(string pdfOutputFile)
{
Document document = new Document();
Section section = document.AddSection();
Paragraph par = section.AddParagraph();
FillFormattedParagraph(par);
PdfDocumentRenderer printer = new PdfDocumentRenderer();
printer.Document = document;
printer.RenderDocument();
printer.PdfDocument.Save(pdfOutputFile);
}
示例12: PDFDocumentBuilder
public PDFDocumentBuilder()
{
document = new Document();
const bool unicode = true;
pdfRenderer = new PdfDocumentRenderer(unicode);
document.Info.Title = "Search results";
document.Info.Author = "Zajęcia projektowe z TO grupa 9:30 Wtorek";
DefineStyles(document);
pdfRenderer.Document = document;
section = document.AddSection();
}
示例13: CreateDocument
Document CreateDocument()
{
// Create a new MigraDoc document
Document document = new Document();
// Add a section to the document
Section section = document.AddSection();
// Add a paragraph to the section
Paragraph paragraph = section.AddParagraph();
// Add some text to the paragraph
paragraph.AddImage(Application.StartupPath + "\\images\\logo.png");
paragraph.AddFormattedText("Braze number: " + textBox1.Text + "\n", TextFormat.Bold);
paragraph.AddFormattedText("Date: " + textBox2.Text + "\n", TextFormat.NotBold);
paragraph.AddFormattedText("Duration: " + textBox3.Text + "\n", TextFormat.NotBold);
paragraph.AddFormattedText("Status: " + textBox5.Text + "\n\n", TextFormat.NotBold);
paragraph.AddFormattedText("Log: " +"\n", TextFormat.Bold);
int loCount = 0;
for (int i = 0; i < listView1.Items.Count; i++)
{
if (listView1.Items[i].Text.Contains("The large Nitrogen valve is opened."))
{
if (loCount < 2)
{
paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
}
loCount++;
if (loCount == 2)
{
paragraph.AddFormattedText("...\n", TextFormat.NotBold);
}
}
else if (listView1.Items[i].Text.Contains("The large Nitrogen valve is closed."))
{
if (loCount < 2)
{
paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
}
}
else
{
paragraph.AddFormattedText(listView1.Items[i].Text + "\n", TextFormat.NotBold);
}
}
//paragraph.AddImage("../../SomeImage.png");
//paragraph.AddImage("../../Logo.pdf");
//section.AddImage("../../Logo.pdf");
section.AddImage(Application.StartupPath + "\\temp\\testa.png");
section.AddImage(Application.StartupPath + "\\temp\\testb.png");
return document;
}
示例14: CreateHelloWorld
private static Document CreateHelloWorld()
{
var doc = new Document();
var section = doc.AddSection();
var p = section.AddParagraph("Hello World");
p = section.AddParagraph();
p.AddImage(System.IO.Path.Combine(Environment.CurrentDirectory, "Diagram.png"));
DefineCharts(doc);
return doc;
}
示例15: Borders
public static void Borders(string outputFile)
{
Document document = new Document();
Section section = document.AddSection();
Paragraph par = section.AddParagraph();
FillFormattedParagraph(par);
GiveBorders(par);
PdfPrinter printer = new PdfPrinter();
printer.Document = document;
printer.PrintDocument();
printer.PdfDocument.Save(outputFile);
}