标签: migradoc

在MigraDoc-WPF中使用section.AddImage()后释放锁定图像文件

我有以下代码生成报告PDF,上传它然后删除生成中使用的临时图像:

// Generate document and then add a section with an image
var document = new Document {Info = {Title = "Results"}};
var section = document.AddSection();
var logo = section.AddImage(logoPath);

// Render the PDF
const PdfFontEmbedding embedding = PdfFontEmbedding.Always;
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument(); // This is the line which locks the files

// Save the PDF to a memory stream and upload it to azure blob storage
var reportPath = "";
using (var stream …
Run Code Online (Sandbox Code Playgroud)

c# wpf pdfsharp migradoc asp.net-mvc-4

4
推荐指数
1
解决办法
1073
查看次数

使用MigraDoc将图像拟合到一个PDF页面上

我可以使用MigraDoc轻松地将图像添加到PDF文件的某个部分.但是,图像按页面宽度减半.

有没有办法强制图片调整大小以使其完全适合一页?或者必须手动完成吗?

如果必须手动完成,是否有人知道MigraDoc中PDF页面的尺寸?

migradoc

4
推荐指数
1
解决办法
3887
查看次数

MigraDoc - imbricated/nested表?

我想在另一个表(在特定单元格内)中添加一个表.我找不到将Table对象添加到Cell对象的方法.这根本不可能吗?

或者,我可能会合并一些细胞,但我在MigraDoc网站上找不到任何样本合并细胞的样本.

这是我的代码:

Table parentTable = new Table();
parentTable.AddColumn(Unit.FromCentimeter(9));
Row parentRow = parentTable.AddRow();
Cell parentCell = parentRow.Cells[0];

Table currentTable = new Table();
currentTable.AddColumn(Unit.FromCentimeter(4));
Row currentRow = currentTable.AddRow();
currentRow.Cells[0].AddParagraph("blablabla");

parentCell.Add(currentTable); // this does not work
Run Code Online (Sandbox Code Playgroud)

c# pdfsharp migradoc

4
推荐指数
1
解决办法
3135
查看次数

MigraDoc - 从十六进制设置单元格颜色

HEX在数据库("#ADD8E6")中有一个颜色代码字符串,我想用它来改变MigraDoc单元格的背景颜色.我找到了Color.Parse()功能,但它没有改变我的细胞的颜色.我不得不做以下事情:

string colourHex = (database.HexCode).Replace("#", "0x");
var colourObject = MigraDoc.DocumentObjectModel.Color.Parse(colourHex);

Cell.Shading.Color = colourObject;
Run Code Online (Sandbox Code Playgroud)

我知道这Cell.Shading.Color是正确的,因为如果我申请,Cell.Shading.Color = Colors.AliceBlue那么单元格会按预期更改颜色.我理解Color.Parse要求HEX代码开始0x而不是#.我尝试使用它#并且它失败了......至少我得到的是渲染......只是没有我的颜色.

c# colors migradoc

4
推荐指数
1
解决办法
780
查看次数

在 Migradoc 中添加最后 3 行之前检查页尾是否接近

我是第一次使用 MigraDoc 库,需要帮助。我正在使用 .pdf 格式打印表格MigraDoc。在我的表 3 行形成一个组。所以每个 3 行组必须在同一页面上,但在我当前的代码中这不会发生。

它将在同一页上打印第一行或第二行,如果页面结束,则第三行进入下一页。

public void CreateDocument()
{
this.document = new Document { Info = { Title = "Time Sheet Report By Job", } };
this.DefineStyles();
this.CreatePage();
this.FillContent();
}

public void FillContent()
{
    int x = 1;
    foreach (XElement r in this.xReport.Element(ElrepTable).Elements(ElrepRow))
    {
        Row row1 = this.table.AddRow();
        int i = 0;
        row1.Cells[0].Borders.Visible = false;
        foreach (XElement c in r.Elements(ElrepCell))
        {
            row1.Cells[i++].AddParagraph(c.Value);
        }

        if (x++ % 3 != 0)
        {
            continue; …
Run Code Online (Sandbox Code Playgroud)

c# pdf pdf-generation pdfsharp migradoc

3
推荐指数
1
解决办法
3459
查看次数

如何将表放在页面的中心?

使用MigraDoc我试图在页面的中心放一张桌子.我正在使用此代码(c#,VS).

Section secondPage = new Section(); 
Table table = new Table();
AddColumns(table);
AddFirstRow(table);
AddSecondRow(table);
table.Format.Alignment=ParagraphAlignment.Center;
secondPage.Add(table);
Run Code Online (Sandbox Code Playgroud)

我得到一个与页面右侧对齐的表格; 如何在页面中心获取表格?

c# pdf-generation migradoc

3
推荐指数
2
解决办法
3496
查看次数

如何设置MigraDoc的页面大小?

抱歉,我只是PDFsharp的初学者.

如何将PageSize设置为文档?让我们说A4.怎么设置呢?这是我的代码.谢谢.

    Document document = new Document();

    // Add a section to the document
    Section section = document.AddSection();
    section.AddParagraph("dddddd");


    // Add a section to the document
    var table = section.AddTable();
    table.AddColumn("8cm");
    table.AddColumn("8cm");

    var row = table.AddRow();
    var paragraph = row.Cells[0].AddParagraph("Left text");
    paragraph.AddTab();
    paragraph.AddText("Right text");
    paragraph.Format.ClearAll();
    // TabStop at column width minus inner margins and borders:
    paragraph.Format.AddTabStop("27.7cm", TabAlignment.Right);
    row.Cells[1].AddParagraph("Second column");
    table.Borders.Width = 1;
Run Code Online (Sandbox Code Playgroud)

c# migradoc

3
推荐指数
1
解决办法
4806
查看次数

通过 migradoc 为 pdf 添加上标和下标

我正在查看某人编写的函数。该函数的目标是通过MigraDoc.

这是函数的定义。

private Boolean RecursiveFormattedParagraph(Document d, Paragraph para, HtmlNode currentNode, ListInfo listinfo, Boolean listFlag, TextFormat currentFormat) {

它适用于程序当前支持的标签(即<b>, <i>)。

如何添加对subscript和 的支持superscript?我做了一些研究,FormattedText似乎是这里合适的方法。但是作为 C# 开发新手,我不太确定如何将其集成到程序中。

html c# migradoc

3
推荐指数
1
解决办法
794
查看次数

如何在 MigraDoc 中为表格添加边框?

有没有办法在表格周围添加边框并在 MigraDoc 中隐藏单元格边框?

c# migradoc

3
推荐指数
1
解决办法
5812
查看次数

将外部 PDF 页面添加到 PDFSharp/MigraDoc

我目前使用 MigraDoc 构建一个 PDF 文件,然后渲染创建 PdfDocument (PDFSharp) 的文档,以便我可以从其他 PDF 中添加外部页面(因为根据我的理解,MigraDoc 没有页面的“概念”,因此无法添加外部页面)页)

我当前的 PDF 文件格式是:

(PDFSharp) Page 1 --- 
(PDFSharp) Page 2   | (MigraDoc) Section 1
(PDFSharp) Page 3 ---
(PDFSharp) Page 4 --- (MigraDoc) Section 2
(PDFSharp) Page 5 --- (MigraDoc) Section 2
(PDFSharp) Page 6 --- (MigraDoc) Section 3
(PDFSharp) External Page 1
(PDFSharp) External Page 2
(PDFSharp) External Page 3
(PDFSharp) External Page 4
Run Code Online (Sandbox Code Playgroud)

我需要有类似的东西:

(PDFSharp) Page 1 --- 
(PDFSharp) Page 2   | (MigraDoc) Section 1
(PDFSharp) Page …
Run Code Online (Sandbox Code Playgroud)

c# pdf-generation pdfsharp migradoc

2
推荐指数
1
解决办法
1328
查看次数

标签 统计

migradoc ×10

c# ×9

pdfsharp ×4

pdf-generation ×3

asp.net-mvc-4 ×1

colors ×1

html ×1

pdf ×1

wpf ×1