我似乎无法理解如何使用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 …嗨,我正在使用PDFsharp和MigraDoc生成柱形图.我想知道,如果我可以将x轴标签旋转到90度,那么它们就像垂直而不是水平.有什么机构有任何想法吗?如果没有,有人可以告诉我任何其他我可以用于同一目的的图书馆吗?
我编写了一段使用PdfSharp库的代码.PdfSharp.Pdf.PdfDocument的实例已按预期保存到磁盘.显示正确的内容,但显示在错误的页面设置上.
PdfSharp的默认页面设置为:
我的问题是这些设置似乎覆盖了所需的设置.
我创建了PdfDocument类的实例,并将一个新的PdfPage类实例添加到其Pages集合属性中.然后,我像这样设置页面:
我很困惑.我知道Acrobat Reader中有一个选项,允许用户在不改变文本方向的情况下更改页面方向.无论我是否选中此选项,仍然会出现错误的设置.
有人有想法吗?谢谢!
有什么办法设置字体样式ItalicUnderline或BoldItalicUnderline?

谢谢
我在这篇文章之后将图像作为资源包括在内: 如何在.NET中创建和使用资源
我正在使用PDFSharp库来创建PDF.绘制图像的方法需要图像的路径.我如何获得路径Properties.Resources.Image?
或者还有另一种方法吗?
我们正在制作一个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);
    }
}
当这个运行时,我得到一个UnauthorizedAccessException在documentRenderer.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)
    { …如何将pdfsharp lib的Acroforms(或任何输入字段)添加到pdf?例如一个文本框(PdfSharp :: Pdf :: AcroForms :: PdfTextField)我找不到任何这样的例子,只能读/修改.
我发现"page-> Elements-> Add(key,pdfitem)",但是我无法从PdfSharp :: Pdf :: AcroForms :: PdfTextField或其他表单(没有构造函数)创建一个Object
我正在一个需要创建Word文件的项目中工作。为此,我将MigraDoc库用于C#。
使用此库,我可以通过编写以下代码轻松生成RTF文件:
Document document = CreateDocument();
RtfDocumentRenderer rtf = new RtfDocumentRenderer();
rtf.Render(document, "test.rtf", null);
Process.Start("test.rtf");
但是要求现在要求我获取DOC或DOCX文件而不是RTF文件。有没有一种使用MigraDoc生成DOC或DOCX文件的方法?如果是这样,我该如何实现?
如何将 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);
}
但我不知道如何添加可填写的表单元素。我猜它可能会使用该page.Elements.Add(string key, PdfItem …
我有一个带有单元格的表格,我想要两个文本,第一个在左边对齐,第二个在右边,在同一个单元格中,在同一行上.
我试图用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);
这里提供了一个解决方案(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; …