问题描述
我已经旋转了段落。
该段落是在 xy 点出现的矩形中,但它正在向下生长。
我希望这个矩形像这里一样长大
这是我的代码。
Canvas canvas = new Canvas(pdfCanvas,new Rectangle(
float.Parse(_xJobID,CultureInfo.InvariantCulture) * POINT,//dynamic x in mm
float.Parse(_yJobID,//dynamic y in mm
8f,0));
DeviceRgb rgb = new DeviceRgb(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,TextAlignment.LEFT,VerticalAlignment.BOTTOM,(float)Math.PI / 2
);
canvas.Close();