簡體   English   中英

iText7 矩形移動方式不正確

[英]iText7 rectangle moves not the correct way

我已經旋轉了段落。 該段落是在 xy 點出現的矩形中,但它正在向下增長。
這里

我希望這個矩形像這里一樣長大
這

這是我的代碼。

        Canvas canvas = new Canvas(pdfCanvas, new Rectangle(
                 float.Parse(_xJobID, CultureInfo.InvariantCulture) * POINT, //dynamic x in mm
                 float.Parse(_yJobID, CultureInfo.InvariantCulture) * POINT, //dynamic y in mm
                8f,
                0));

        DeviceRgb rgb = new DeviceRgb(0, 0, 0); //black
        Color szin = Color.ConvertRgbToCmyk(rgb);
        DeviceRgb rgbGreen = new DeviceRgb(152, 251, 152); //green
        Color szinGreen = Color.ConvertRgbToCmyk(rgbGreen);

        canvas.Add(new Paragraph($"{_jobID}_{_client}") // dynamic text that goes down not up
            .SetRotationAngle(DegreeConvertation("90"))  //rotaded paragraph.
            .SetFont(ARIAL)
            .SetFontSize(5)
            .SetFontColor(szin).SetBackgroundColor(szinGreen).SetTextAlignment(TextAlignment.LEFT));

我應該更改什么才能使文本從 xy 左下角上升。

您可以嘗試將 SetRotationAngle 更改為 270 度。

我使用方法ShowTextAligned而不是段落。
它顯示了完美的一條線。

canvas.SetFont(ARIAL).SetFontSize(5.0F).SetFontColor(szin); // font
canvas.ShowTextAligned(
                       $"SomeText",
                       100,
                       100,
                       TextAlignment.LEFT,
                       VerticalAlignment.BOTTOM,
                       (float)Math.PI / 2
                      );
canvas.Close();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM