Sun Nov 20, 2011 9:48 pm
Hi Tina,
Here's the source code of what I'm talking about. If you reduce the size of the string it shows up fine. Also, if you take out the pipes (new lines) it shows up fine.
using System;
using System.Windows.Forms;
using Spire.Doc;
namespace Replace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
//load a document
document.LoadFromFile(@"..\\..\\test.docx",FileFormat.Docx2010);
// Test string
string testS = "testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|testing|";
int len = testS.Length;
string testFormatted = testS.Replace("|", Environment.NewLine);
//Replace text
//document.Replace(this.textBox1.Text, this.textBox2.Text+Environment.NewLine + "test"+Environment.NewLine+"Test2",true,true);
document.Replace("TEST", testFormatted, true, true);
//Save doc file.
document.SaveToFile("Sample.pdf", FileFormat.PDF);
//Launching the MS Word file.
WordDocViewer("Sample.pdf");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}