c# - 以从右到左的布局打印文档
问题描述
我写了这段代码:
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
Font normalFont = new Font("B nazanin",25);
StringFormat format = new StringFormat(StringFormatFlags.DirectionRightToLeft);
e.Graphics.DrawString("سلام", normalFont, Brushes.Black, 0, 0 , format);
}
private void btnPrint_Click(object sender, EventArgs e)
{
try
{
printPreviewDialog.Document = printDocument;
pageSetupDialog.PageSettings = printDocument.DefaultPageSettings;
pageSetupDialog.ShowDialog();
printDocument.DefaultPageSettings = pageSetupDialog.PageSettings;
printPreviewDialog.ShowDialog();
}
catch
{
MessageBox.Show("error");
}
}
它工作得很好,但问题是它从右到左打印文本,我也需要从右到左打印文档。这样它就不会显示我的文本,因为它将不在我的文档中。
谁能帮我?谢谢。
解决方案
实际上我这样做了,它的工作很棒:
int widthNegetive = printDocument.DefaultPageSettings.PaperSize.Width;
e.Graphics.DrawString("متن", normalFont, Brushes.Black, widthNegetive, 0, format);
推荐阅读
- java - 过滤嵌套的回收视图,包括带有微调器的复选框
- javascript - 如何使用浏览器打开 Visual Studio 代码
- android - NoSuchMethodError:没有静态方法 setContent,因为 gradle buildSrc
- php - 通过 PDO 连接到 AWS RDS
- ios - 如何在 List SwiftUI 中禁用默认填充和反弹
- ios - 你将如何从 Swift 访问 xcargs?
- vb.net - VB .Net 获取具有最低值的整数变量的名称
- javascript - 将JS对象转换为不同的顺序
- python - HuggingFace T5 变压器模型 - 如何准备自定义数据集以进行微调?
- excel - 使用 if 语句将多列堆叠为一列 - vba(excel)