简体   繁体   中英

iText7 rectangle moves not the correct way

I have rotated paragraph. That paragraph is in rectangle that appears in xy point, but it GROWING DOWN.
这里

I want this rectangle to GROW UP like here
这

Here is my code.

        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));

What should I change to make the text rise up from the xy bottom left.

您可以尝试将 SetRotationAngle 更改为 270 度。

Instead of paragraph I used method ShowTextAligned .
It shows perfect one line.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM