bulk text replace function with newlines

Technical support for Spire.Doc

Moderator: iceblue support

bulk text replace function with newlines

Postby djwinder » Fri Nov 18, 2011 5:41 am

Hi,

Scenario: I'm pulling in large strings and conditionally exporting them to a pdf document. I've tested up to 600 character strings that this is working fine using the "replace" function. I want to output these strings formatted with new line's so I use this value in the text "Environment.Newline".

Issue: Even when I use strings of 400 characters with the newline value the document can't be saved as the index is out of range. However, if I reduce the amount to say 50 characters it works fine.

i.e No newline newline

Long String Works Doesn't work

Short String Works Works

Please let me know if you need any additional information.
djwinder
 
Posts: 4
Joined: Tue Nov 15, 2011 4:58 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Fri Nov 18, 2011 3:45 pm

Hello djwinder,

Sorry for the inconvenience caused by us and thank you for your patience.

Would you sent the file/code to help us reproduce the problem?

Thanks in advance.
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Sat Nov 19, 2011 6:46 am

Hello djwinder,


Sorry for that I am not very clear about the meaning of your issue.

Do you mean that:
1.Get a string from doc file
2.use the "replace" function to replace some words of the string
3.Get the string formatted byEnvironment.newline then save the string to pdf

Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Sat Nov 19, 2011 7:38 am

Hello

I attached the demo. You can have a try.
If you still have any other questions, please feel free to contact us.
You do not have the required permissions to view the files attached to this post.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Re: bulk text replace function with newlines

Postby djwinder » 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 { }
}
}
}
djwinder
 
Posts: 4
Joined: Tue Nov 15, 2011 4:58 am

Re: bulk text replace function with newlines

Postby djwinder » Sun Nov 20, 2011 10:03 pm

Whoops, just overlooking the code that I sent you, there is about another 2 lines of testing with pipes :)
djwinder
 
Posts: 4
Joined: Tue Nov 15, 2011 4:58 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Mon Nov 21, 2011 7:38 am

Hello djwinder,

Sorry for the inconvenience caused by us and thank you for your patience.

We have reproduced the problem. We need some time to fix on this issue. Would you kindly give us more time?
Once we finished, we will inform you as soon as possible.

Thanks
Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Re: bulk text replace function with newlines

Postby djwinder » Mon Nov 21, 2011 11:29 pm

Hi Tina,

I don't mean to bug, were you able to reproduce the issue?
djwinder
 
Posts: 4
Joined: Tue Nov 15, 2011 4:58 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Tue Nov 22, 2011 6:53 am

Hello djwinder,

I have reproduced the problem. The PDF file generated by Spire.Doc is a blank file as your. Maybe in parsing files came up with error. We still need time to research on this issue. Please wait with patience. Once we have progress in the issue , we will inform you as soon as possible.

Have a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Re: bulk text replace function with newlines

Postby Tina.Lin » Wed Nov 30, 2011 8:39 am

Hello djwinder,

Sorry for late reply.

The problem you proposed last week had been fixed in Spire.Doc HotFix 4.1.14. You can download it from the following address:
http://www.e-iceblue.com/Download/download-word-for-net-now.html.

If you still have any other questions, please don't hesitate to contact us.

Hava a nice day.
Tina
Technical Support/Developer,
e-iceblue Support Team
User avatar
Tina.Lin
 
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am


Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 1 guest