标签: pdfsharp

PDFsharp自动换行

我似乎无法理解如何使用PDFsharp在我创建的矩形中包装文本.我已经看过文章解释如何,但是当我尝试它时,我的文本仍然延伸到PDF的页面.任何帮助都会很棒(这是我第一次使用PDFsharp).

rect = new XRect(20, 300, 400, 100);
tf.Alignment = XParagraphAlignment.Left;
gfx.DrawString("\t • Please call the borrower prior to closing and confirm your arrival time and the closing location. \n", font, XBrushes.Black, rect, XStringFormats.TopLeft);
rect = new XRect(20, 320, 100, 100);
gfx.DrawString("\t • If the borrower needs to change the closing appointment time or date for any reason please have them call McDonnell Law Firm at 866-931-8793 \n", font, XBrushes.Black, rect, XStringFormats.TopLeft);
rect = new XRect(20, 340, 100, 100);
gfx.DrawString("\t …
Run Code Online (Sandbox Code Playgroud)

c# pdfsharp

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

将XAxis标签旋转到90度

嗨,我正在使用PDFsharp和MigraDoc生成柱形图.我想知道,如果我可以将x轴标签旋转到90度,那么它们就像垂直而不是水平.有什么机构有任何想法吗?如果没有,有人可以告诉我任何其他我可以用于同一目的的图书馆吗?

c# pdf charts pdfsharp migradoc

9
推荐指数
0
解决办法
530
查看次数

PdfSharp - 在Acrobat中打开文档时,PDF页面设置错误

我编写了一段使用PdfSharp库的代码.PdfSharp.Pdf.PdfDocument的实例已按预期保存到磁盘.显示正确的内容,但显示在错误的页面设置上.

PdfSharp的默认页面设置为:

  1. PdfSharp.PageSizes.A4
  2. PdfSharp.PageOrientation.Portrait

我的问题是这些设置似乎覆盖了所需的设置.

我创建了PdfDocument类的实例,并将一个新的PdfPage类实例添加到其Pages集合属性中.然后,我像这样设置页面:

  1. PdfDocument.Pages [0] .Size = PdfSharp.PageSizes.Letter
  2. PdfDocument.Pages [0] .Orientation = PdfSharp.PageOrientation.Landscape
  3. 我绘制字符串(这很好)
  4. 我将文档保存到磁盘(这很好)
  5. Process.Start(myPdfFilename) - 然后Acrobat Reader打开我的文档.
  6. 页面设置为A4 - 纵向...

我很困惑.我知道Acrobat Reader中有一个选项,允许用户在不改变文本方向的情况下更改页面方向.无论我是否选中此选项,仍然会出现错误的设置.

有人有想法吗?谢谢!

c# pdfsharp

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

Pdf锋利的字体样式大胆,斜体和下划线在一起

有什么办法设置字体样式ItalicUnderline或BoldItalicUnderline? 在此输入图像描述

谢谢

.net c# pdf-generation pdfsharp migradoc

8
推荐指数
1
解决办法
5805
查看次数

如何在.NET中获取Properties.Resources.Image的路径

我在这篇文章之后将图像作为资源包括在内: 如何在.NET中创建和使用资源

我正在使用PDFSharp库来创建PDF.绘制图像的方法需要图像的路径.我如何获得路径Properties.Resources.Image

或者还有另一种方法吗?

.net c# pdfsharp

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

如何在ASP.Net MVC中使用PdfSharp显示PDF?

我们正在制作一个ASP.Net MVC应用程序,它需要能够生成PDF并将其显示在屏幕上或将其保存在易于用户访问的地方.我们正在使用PdfSharp生成文档.一旦完成,我们如何让用户保存文档或在阅读器中打开文档?我特别困惑,因为PDF是在服务器端生成的,但我们希望它显示在客户端.


以下是创建我们目前编写的报告的MVC控制器:

public class ReportController : ApiController
{
    private static readonly string filename = "report.pdf";

    [HttpGet]
    public void GenerateReport()
    {
        ReportPdfInput input = new ReportPdfInput()
        {
            //Empty for now
        };

        var manager = new ReportPdfManagerFactory().GetReportPdfManager();
        var documentRenderer = manager.GenerateReport(input);
        documentRenderer.PdfDocument.Save(filename); //Returns a PdfDocumentRenderer
        Process.Start(filename);
    }
}
Run Code Online (Sandbox Code Playgroud)

当这个运行时,我得到一个UnauthorizedAccessExceptiondocumentRenderer.PdfDocument.Save(filename);那说,Access to the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\report.pdf' is denied.我也不能确定线的时候会发生什么Process.Start(filename);被执行.

这是以下代码manager.GenerateReport(input):

public class ReportPdfManager : IReportPdfManager
{
    public PdfDocumentRenderer GenerateReport(ReportPdfInput input)
    { …
Run Code Online (Sandbox Code Playgroud)

pdfsharp c#-4.0 asp.net-mvc-4

8
推荐指数
2
解决办法
2万
查看次数

使用pdfsharp添加acroform

如何将pdfsharp lib的Acroforms(或任何输入字段)添加到pdf?例如一个文本框(PdfSharp :: Pdf :: AcroForms :: PdfTextField)我找不到任何这样的例子,只能读/修改.

我发现"page-> Elements-> Add(key,pdfitem)",但是我无法从PdfSharp :: Pdf :: AcroForms :: PdfTextField或其他表单(没有构造函数)创建一个Object

pdf c++-cli pdfsharp

8
推荐指数
1
解决办法
890
查看次数

使用MigraDoc生成DOC或DOCX

我正在一个需要创建Word文件的项目中工作。为此,我将MigraDoc库用于C#。

使用此库,我可以通过编写以下代码轻松生成RTF文件:

Document document = CreateDocument();
RtfDocumentRenderer rtf = new RtfDocumentRenderer();
rtf.Render(document, "test.rtf", null);
Process.Start("test.rtf");
Run Code Online (Sandbox Code Playgroud)

但是要求现在要求我获取DOC或DOCX文件而不是RTF文件。有没有一种使用MigraDoc生成DOC或DOCX文件的方法?如果是这样,我该如何实现?

c# pdfsharp migradoc

8
推荐指数
1
解决办法
1750
查看次数

C#:使用 PDFsharp 创建 PDF 表单 (AcroForm)

如何将 PDF 表单元素添加到 PDFsharpPdfPage对象?

我知道 AcroForm 是可填写表单的 PDF 元素的最佳格式,但 PDFsharp 库似乎不允许您创建 AcroForm 对象的实例。

我已经能够使用 PDFsharp 生成简单的文档,如下所示:

static void Main(string[] args) {
    PdfDocument document = new PdfDocument();
    document.Info.Title = "Created with PDFsharp";

    // Create an empty page
    PdfPage page = document.AddPage();

    // Draw Text
    XGraphics gfx = XGraphics.FromPdfPage(page);
    XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
    gfx.DrawString("Hello, World!", font, XBrushes.Black,
        new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);

    // Save document
    const string filename = "HelloWorld.pdf";
    document.Save(filename);
}
Run Code Online (Sandbox Code Playgroud)

但我不知道如何添加可填写的表单元素。我猜它可能会使用该page.Elements.Add(string key, PdfItem …

c# pdf pdfsharp

8
推荐指数
1
解决办法
5968
查看次数

MigraDoc C#在同一条线上左右对齐

我有一个带有单元格的表格,我想要两个文本,第一个在左边对齐,第二个在右边,在同一个单元格中,在同一行上.

我试图用MigraDoc重现这个细胞而没有成功.我只能添加两个左右对齐但不在同一行的文本.

这是我的代码:

Cell cellFooter1 = rowFooter.Cells[0];
Paragraph paraphTot = new Paragraph();
paraphTot.Format.Alignment = ParagraphAlignment.Left;
paraphTot.AddText("Left text");
cellFooter1.Add(paraphTot);
Paragraph paraphDetails = new Paragraph();
paraphDetails.Format.Alignment = ParagraphAlignment.Right;
paraphDetails.AddText("Right text");
cellFooter1.Add(paraphDetails);
Run Code Online (Sandbox Code Playgroud)

这里提供了一个解决方案(http://forum.pdfsharp.net/viewtopic.php?f=2&t=2373),但我无法对我的表做同样的事情.我不明白它是如何工作的.

编辑:部分解决方案:

在努力了解它是如何工作之后,我的代码部分正常工作.部分因为我发现右对齐的唯一方法是创建一个具有近似值的TabStop ...不好.

Table table = new Table();
table.Borders.Width = 0.75;
Column myColumn = table.AddColumn(Unit.FromCentimeter(7));
Row myRow = table.AddRow();
Cell myCell = myRow.Cells[0];
Paragraph myParagraph = new Paragraph();
Style myStyle = doc.AddStyle("myStyle", "Normal");
myStyle.ParagraphFormat.Font.Size = 6.5;
myStyle.ParagraphFormat.Font.Bold = true;
myStyle.ParagraphFormat.TabStops.Clear();
myStyle.ParagraphFormat.AddTabStop(Unit.FromMillimeter(67), TabAlignment.Right);
myParagraph.Style = "myStyle";
myParagraph.Format.Alignment = ParagraphAlignment.Left; …
Run Code Online (Sandbox Code Playgroud)

c# pdf pdf-generation pdfsharp migradoc

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

标签 统计

pdfsharp ×10

c# ×8

migradoc ×4

pdf ×4

.net ×2

pdf-generation ×2

asp.net-mvc-4 ×1

c#-4.0 ×1

c++-cli ×1

charts ×1