【问题标题】:PDFsharp 1.32 to 1.50 updatePDFsharp 1.32 到 1.50 更新
【发布时间】:2021-09-29 17:49:14
【问题描述】:

我刚刚将我的 PDFsharp 包从 1.32 更新到 1.50,现在我收到了无法将 System.Drawing.Rectangle 转换为 PdfSharp.Drawing.XRect 的错误。我有什么遗漏或者我需要根据新包更改此方法吗?

protected void DrawVerticalLines(XGraphics graphics, double pageWidth, double pageHeight, int marginX, int marginY, int topMarginY)
        {
            
            XPen pen = new XPen(XColors.Black, 0.5);

            graphics.DrawRectangle(pen, new Rectangle(marginX, topMarginY, (int)(pageWidth - marginX * 2), (int)(pageHeight - marginY * 2 - topMarginY)));
            
        }

【问题讨论】:

    标签: c# pdfsharp


    【解决方案1】:

    当您说new Rectangle(etc... 时,您传递的是System.Drawing.Rectangle(一个“Microsoft”矩形)。 DrawRectangle 方法期望您传入 PdfSharp.Drawing.XRect 矩形(“Pdf Sharp”矩形)。构建 Pdf Sharp 矩形并将其传入。

    【讨论】:

    • 那么它会被转换成这个吗? XRect rect = new XRect(marginX, topMarginY, (int)(pageWidth - marginX * 2), (int)(pageHeight - marginY * 2 - topMarginY));
    • 是的,类似的。我不是 100% 了解 XRect 的构造函数参数。当你这样做时会发生什么?
    猜你喜欢
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-07
    相关资源
    最近更新 更多