标签: migradoc

如何减少 MigraDoc 文档的上边距?

如何减少 MigraDoc 文档的上边距?

我在文档的右上角添加了一个图像,但是文档顶部和图像之间的空间太大。

这是我设置图像的方法:

Section section = document.AddSection();
Image image = section.AddImage(@"C:\img\mentSmallLogo.png");
image.Height = "1.5cm";
image.Width = "4cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
Run Code Online (Sandbox Code Playgroud)

以及文档样式:

Style style = document.Styles["Normal"];
style.Font.Name = "Verdana";

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

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

// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = …
Run Code Online (Sandbox Code Playgroud)

migradoc

5
推荐指数
1
解决办法
5820
查看次数

MigraDoc - 获取页码

请帮忙!如何在渲染前获取页数?我需要在我的文档中将数字写为单词。对不起我的英语不好

pdfsharp migradoc

5
推荐指数
1
解决办法
5180
查看次数

如何使用 Migradoc PDF 库打开现有的 PDF 文件

我正在尝试使用 PDFSharp ( http://www.pdfsharp.net/ ) 中的 Migradoc 库来打印 pdf 文件。到目前为止,我发现 Migradoc 确实支持通过其MigraDoc.Rendering.Printing.MigraDocPrintDocument类进行打印。但是,我还没有找到使用 MigraDoc 打开现有 PDF 文件的方法。

我确实找到了一种使用 PDFSharp 打开现有 PDF 文件的方法,但我无法成功将 aPDFSharp.Pdf.PdfDocument转换为MigraDoc.DocumentObjectModel.Document对象。到目前为止,我还没有发现 MigraDoc 和 PDFSharp 文档很有帮助。

有没有人有使用这些库来处理现有 PDF 文件的经验?

我在示例的帮助下编写了以下代码,但是当我的输入 PDF 为 2 页时,结果是一个带有 2 个空白页的输出 PDF。

using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;

...

public void PrintPDF(string filePath, string outFilePath)
{

    var document = new Document();

    var docRenderer = new DocumentRenderer(document);
    docRenderer.PrepareDocument();

    var inPdfDoc = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);

    for …
Run Code Online (Sandbox Code Playgroud)

c# printing pdf pdfsharp migradoc

5
推荐指数
1
解决办法
1万
查看次数

是否可以在 Azure 应用服务上安装字体?

我们正在使用 MigraDoc/PDFsharp GDI+,它依赖于将字体安装到系统以进行渲染。我们已尝试嵌入字体,但 MigraDoc 的 GDI+ 版本似乎不支持此功能。

尝试将此组件移动到 Azure 应用服务时,它找不到字体。有没有办法在本地将字体“安装”到应用服务,以便 GDI 可以看到它们?

fonts azure pdfsharp migradoc azure-web-app-service

5
推荐指数
1
解决办法
4983
查看次数

如何在图表下放置一个大图例?

我的图表中有很多元素,这些元素不适合图表下的一行。如何实现换行以便所有图例都适合图表下方?

这是我的用例示例,将其复制到本地项目并使用 NuGet 来配置 MigraDoc 包。

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Xml.XPath;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using System.Diagnostics;
using PdfSharp.Pdf;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main()
        {
            // Create a MigraDoc document
            Document document = CreateDocument();

            //string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);
            //MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");

            PdfDocumentRenderer renderer = new PdfDocumentRenderer(unicode: true);
            renderer.Document = document;

            renderer.RenderDocument();

            // Save the document...

            //renderer.PdfDocument.Save(filename);
            renderer.PdfDocument.Save("example.pdf");
            // ...and start a viewer. …
Run Code Online (Sandbox Code Playgroud)

c# legend migradoc

5
推荐指数
0
解决办法
739
查看次数

处理这些PDFSharp表限制的最佳方法是什么?

我正在使用PDFSharp将表导出为PDF(使用常规MigraDoc.DocumentObjectModel.Tables.Table对象).它运行得很好,除了我遇到了一些问题:

  1. 如果表格中单个单元格的内容长于页面的高度,则内容就会被切断.一个表本身可以跨越多个页面,但是一行似乎只能是1页高,看起来它不会延伸到下一页.

有没有解决方法或者这只是库中的错误?

  1. 对于跨越多个页面的表,是否有办法让表格上的标题行显示在每个页面的顶部?

c# pdf pdfsharp migradoc

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

MigraDoc页眉和页脚

我正在用MigraDoc创建一个PDF,我想要第一页,只有第一页有页脚,而每个后续页面(但不是第一页)都有标题.我已经尝试过,DifferentFirstPageHeaderFooter但它没有给我我需要的结果.我知道有一些设置的组合,以及添加页眉和页脚的正确位置,但我不知道是什么.我的代码基于MigraDoc发票样本.封面是一个部分,然后文档的其余部分是一个带分页符的部分.也许我需要将其分成每页一节?谢谢你的任何提示.

编辑

我得到了标题显示,但似乎有一个更好的方法来做它比我正在做的.页脚根本没有显示出来.这是我添加它们的地方:

Document document = new Document();
Section section = document.AddSection();

section.PageSetup.DifferentFirstPageHeaderFooter = true;        

Paragraph paragraph = section.Footers.Primary.AddParagraph();
paragraph.AddFormattedText(ReportName, TextFormat.Bold);
paragraph.AddText("\nCreated on ");
paragraph.AddFormattedText(CreateDate, TextFormat.Bold);
paragraph.AddFormattedText("\n" + Properties.Length, TextFormat.Bold);
paragraph.AddText(" Records");
paragraph.AddFormattedText("\n" + TurnoverPercent, TextFormat.Bold);
paragraph.AddText(" Turnover Rate");
paragraph.Format.Font.Size = 10;
paragraph.Format.Alignment = ParagraphAlignment.Center;

// Later, in a different method...
Section section = document.AddSection();

    // Header image
    Image image = section.Headers.Primary.AddImage(filename);
    image.Height = "2.5cm";
    image.LockAspectRatio = true;
    image.RelativeVertical = RelativeVertical.Line;
    image.RelativeHorizontal = RelativeHorizontal.Margin;
    image.Top = ShapePosition.Top;
    image.Left …
Run Code Online (Sandbox Code Playgroud)

c# pdf migradoc

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

MigraDoc 是否支持国家字符/Unicode 字符?

我正在使用 MigraDoc 生成 PDF 文档。它工作得很好,但我有两个问题:

  1. 我无法将波兰语字符(尤其是?)添加到文本中。
  2. 我无法在文本中添加磅字符 (?)。

我试图改变字体,但没有结果。

c# pdf-generation migradoc

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

MigraDoc Two Tables in one row

I am working on creating a report with MigraDoc that would be able to have 4 tables, 2 rows with 2 tables.

I have tried a number of different methods to accomplish this.

1- I have tried creating a leftIndent on the table.

table1.Format.LeftIndent = 7;

  1. I have tried creating a leftIndent on the rows of the table.

tables.Rows.LeftIndent = 5;

  1. 我也尝试创建一个表,将每个表到一个单独的单元格,但我不知道如何放置的表格单元格中创建表的方法.

任何帮助或输入,我可以得到这将是大加赞赏.谢谢!

report migradoc

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

MigraDoc 和 .NET Core 2.0

我为 PDF 生成制作了一个类库。它是使用 PDFshart-MigraDoc(核心包*)实现的。类库本身使用 .NET Standard 作为其目标框架。

我可以在经典 C# 项目(如 WinForms)中使用类库,但是如果我尝试将它与 .NET Core 2.0 一起使用,我会收到以下错误:

无法加载文件或程序集“System.Drawing.Common,Version=0.0.0.0,Culture=neutral,PublicKeyToken=xxxx”。该系统找不到指定的文件。

我想这样做的原因可能是 MigraDoc 在其实现中使用了“System.Drawing”,(据我所知).NET Core 框架不支持它。

但是,这并没有真正解决我的问题,即我需要类库适用于所有 .NET 框架。根据这篇文章的建议,我尝试包含 NuGet 包CoreCompat.System.Drawing。但这一直没有效果,可能是因为 MigraDoc 还在尝试使用“原始”System.Drawing库。

有什么方法可以让我的类库适用于 .NET Core?还是我运气不好……?

注意:MigraDoc Core Package 与 .NET Core Framework 无关。名字的冲突只是巧合。

c# system.drawing migradoc .net-core

4
推荐指数
2
解决办法
8338
查看次数