[英]Generating tiff file from a multi-line text box in C#
我正在將在Web表單上輸入的信息寫到tiff文件中。 我的問題是Web表單的注釋框在哪里起作用。 注釋框是多行的,將其寫入到tiff文件時,輸入到注釋框中的某些信息會從tiff圖像中消失。
我試圖將其寫入tiff文件的代碼:-
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000); //Creates Bitmap
Graphics g = Graphics.FromImage(bitmap);
g.DrawString("Comment: " + CommentBox.Text, outputFont, Brushes.Black, new PointF(0, 700)); // Writing the text from the comment box on to the Tiff file.
所以這對我來說意味着,如果我將多行注釋寫為:
“你好測試。
你好,一次又一次,一次又一次,一次又一次。
你好,一次又一次,一次又一次,一次又一次。 你好,一次又一次,一次又一次,一次又一次。
我的tiff文件僅捕獲最大1000寬度的線元素,超過該寬度的元素不會自動在新行中生成。
誰能幫我這個? 想法?
嘗試類似的事情-您可以使用DrawString的重載,該重載包含一個包含矩形,並且文本應在該矩形內換行:
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000); //Creates Bitmap
using(Graphics g = Graphics.FromImage(bitmap))
{
RectangleF rect = new RectangleF(new PointF(0, 700), new SizeF(200,200)); // adjust these accordingly for your bounding rect
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Near;
g.DrawString("Comment: " + CommentBox.Text, outputFont, Brushes.Black, rect, drawFormat); // Writing the text from the comment box on to the Tiff file.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.