我正在使用一个简单的程序,该程序将使用tallPDF xml并将其转换为PDF视图,以便您知道自己在看什么。问题是我只能输入多少角色。这是一个问题,我可以在表单的设计视图中纠正,或者是代码中的原语,因为代码很少?
再说这不是我的代码。我不承担任何信贷!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
// load the XML document template
System.Xml.XmlDocument documentTemplate = new System.Xml.XmlDocument();
documentTemplate.LoadXml(txtPDFXML.Text);
// Setup the document
TallComponents.PDF.Layout.Document pdf = new TallComponents.PDF.Layout.Document();
pdf.Read(documentTemplate.DocumentElement);
// Finally write the PDF document
webBrowser1.Navigate("about:blank");
System.IO.FileStream fs = null;
try
{
fs = new System.IO.FileStream(@"Out.pdf", System.IO.FileMode.Create);
}
catch
{
fs = new System.IO.FileStream(@"Out2.pdf", System.IO.FileMode.Create);
}
pdf.Write(fs, false);
fs.Close();
fs.Dispose();
webBrowser1.Navigate(fs.Name);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
这是表单designer.cs
'部分类Form1 { /// ///所需的设计变量。 /// private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.txtPDFXML = new System.Windows.Forms.TextBox();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.txtPDFXML);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.webBrowser1);
this.splitContainer1.Size = new System.Drawing.Size(1347, 824);
this.splitContainer1.SplitterDistance = 693;
this.splitContainer1.SplitterWidth = 5;
this.splitContainer1.TabIndex = 0;
//
// txtPDFXML
//
this.txtPDFXML.AcceptsReturn = true;
this.txtPDFXML.AcceptsTab = true;
this.txtPDFXML.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtPDFXML.Location = new System.Drawing.Point(0, 0);
this.txtPDFXML.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtPDFXML.Multiline = true;
this.txtPDFXML.Name = "txtPDFXML";
this.txtPDFXML.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtPDFXML.Size = new System.Drawing.Size(693, 824);
this.txtPDFXML.TabIndex = 0;
this.txtPDFXML.WordWrap = false;
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.webBrowser1.MinimumSize = new System.Drawing.Size(27, 25);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(649, 824);
this.webBrowser1.TabIndex = 0;
//
// button1
//
this.button1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button1.Location = new System.Drawing.Point(0, 824);
this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(1347, 28);
this.button1.TabIndex = 1;
this.button1.Text = "&View";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1347, 852);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.button1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "Form1";
this.Text = "Form1";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TextBox txtPDFXML;
private System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.Button button1;
}
}
,
答案 0 :(得分:0)
我偶然发现了延长这个记事本风格程序允许的字符的方法。我打算关闭这个问题,但META告诉我,我应该发布我的答案并接受它,以便其他人可以使用它或添加它等等。所以,在查看代码并找到任何可以帮助我查看UI。这包括记事本样式窗口。我点击它并查看右侧的属性。有一个MaxLength属性设置为3700,我设置为9999.这增加了我能够输入的文本数量并解决了我的问题。可能还有其他方法可以做到这一点,但这就是我所做的,而且效果很好。