【问题标题】:MigraDoc: How can i write vertical text?MigraDoc:如何编写垂直文本?
【发布时间】:2017-11-27 14:50:35
【问题描述】:

我有一个段落,它在我的 pdf 上呈现得很好:

var para = currentSection.AddParagraph();
para.AddText("My text.")
RenderObject(docRenderer, XUnit.FromCentimeter(1.27), XUnit.FromCentimeter(22.86), "4cm", myParagraph);

事情是我想垂直写段落。

如何使用 Migradoc 和/或 PdfSharp 实现这一目标?

【问题讨论】:

  • 你是this helpful吗?
  • 不幸的是,在这个例子中他们只旋转图像
  • @Thariama 该示例旋转文本和图像。旋转适用于使用 XGraphics 对象绘制的任何内容。
  • 真的。实际上我正在努力让它工作但没有成功

标签: c# pdf-generation pdfsharp migradoc


【解决方案1】:

我成功了(感谢 PDFsharp Novice 和 Mong Zhu)。 这是其他人想写垂直文本的代码:

        XForm form = new XForm(this.currentGfx, XUnit.FromMillimeter(70), XUnit.FromMillimeter(55));
        XGraphics formGfx = XGraphics.FromForm(form);
        formGfx.DrawString("Test text", new XFont("Verdana", 6, XFontStyle.Regular), XBrushes.Black, 3, 0, XStringFormats.TopLeft);

        currentGfx.Dispose();
        currentGfx = XGraphics.FromPdfPage(this.currentPage);

        currentGfx.RotateAtTransform(270, new XPoint(15, 773));
        currentGfx.DrawImage(form, 15, 773, 200, 200);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-07
    • 2022-11-23
    • 2014-01-28
    • 2013-10-15
    • 2011-06-22
    • 1970-01-01
    相关资源
    最近更新 更多