Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jan 02, 2019 12:37 pm

Hi,

We are using free version of Spire where it is mentioned that free version can read 500 paragraphs. But in our application , it only reads file upto 379 paragraphs. Can you please help why this is happening. attached is the file, where free SPIRE version reads only 379 paragraphs.

You can reach me at +918360124279 or mail me at [email protected]

pallavigarg
 
Posts: 3
Joined: Wed Jan 02, 2019 12:16 pm

Thu Jan 03, 2019 3:49 am

Hi pallavi,

Thanks for your inquiry.
After testing your case with Free Spire.Doc for .NET Version:6.3, I could read 500 paragraphs.
How do you get the paragraph count? Could you please provide your full code?

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Jan 04, 2019 5:05 am

Thanks for the reply betsy. Belos is the code for your reference:-

HttpContext postedContext = HttpContext.Current;
HttpFileCollection Request = postedContext.Request.Files;
HttpPostedFile postedFile = Request[0];

byte[] buffer = new byte[postedFile.InputStream.Length];
postedFile.InputStream.Seek(0, SeekOrigin.Begin);
postedFile.InputStream.Read(buffer, 0, Convert.ToInt32(postedFile.InputStream.Length));
Stream stream2 = new MemoryStream(buffer);
string data = "";
Boolean StringExist = true;

// write to a file
using (FileStream file = new FileStream("C:\\inetpub\\wwwroot\\WSExtractor\\logs\\"
+ postedFile.FileName, FileMode.Create, System.IO.FileAccess.Write))
stream2.CopyTo(file);

string SearchParam = "";
string SearchParam_TRS = "";
XmlDocument xml = new XmlDocument();
xml.Load(Server.MapPath("Configuration.xml"));
XmlNode xn = xml.SelectSingleNode("config");

log.Info("TransType='" + TransType + "', TransName='" + TransitionName + "', Filename='"
+ postedFile.FileName + "', FileSize(Bytes)='" + postedFile.ContentLength );

The copied file shows 379 paragraphs. Whole word doc is not getting copied. We are using 4.5 .net framework.

Thanks in advance.

pallavigarg
 
Posts: 3
Joined: Wed Jan 02, 2019 12:16 pm

Fri Jan 04, 2019 6:11 am

Hi pallavi,

Thanks for your information.
Sorry that I didn't find any code about using our product, how did you use Spire.Doc to manipulate your Word file?
And could you please also provide your result file and the screenshot of showing 379 paragraphs for further investigation?

Many thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Jan 04, 2019 7:51 am

Code: Select all
public Boolean WSExtractFileContent()
{
   try
   {
      HttpContext postedContext = HttpContext.Current;
      HttpFileCollection Request = postedContext.Request.Files;
      string TransitionName = postedContext.Request.Params["TransitionName"];
      string TransType = postedContext.Request.Params["transType"];
      HttpPostedFile postedFile = Request[0];
      
      byte[] buffer = new byte[postedFile.InputStream.Length];
      postedFile.InputStream.Seek(0, SeekOrigin.Begin);
      postedFile.InputStream.Read(buffer, 0, Convert.ToInt32(postedFile.InputStream.Length));
      Stream stream2 = new MemoryStream(buffer);
      string data = "";
      Boolean StringExist = true;
      
[b]      // Input file received from HTTP POST, write to a file
      using (FileStream file = new FileStream("C:\\inetpub\\wwwroot\\WSExtractor\\logs\\"
         + postedFile.FileName, FileMode.Create, System.IO.FileAccess.Write))
         stream2.CopyTo(file);[/b]

      string SearchParam = "";
      string SearchParam_TRS = "";
      XmlDocument xml = new XmlDocument();
      xml.Load(Server.MapPath("Configuration.xml"));
      XmlNode xn = xml.SelectSingleNode("config");

      log.Info("TransType='" + TransType + "', TransName='" + TransitionName + "', Filename='"
         + postedFile.FileName + "', FileSize(Bytes)='" + postedFile.ContentLength );

      if (TransType == "TRS")
      {
         // TransitionName = TransitionName + "_TRS";
         if (xn.SelectSingleNode(TransitionName+"_TRS") != null)
            SearchParam_TRS = xn[TransitionName + "_TRS"].InnerText;
         //TransitionName = TransitionName + "_SETUP";
         if (xn.SelectSingleNode(TransitionName + "_SETUP") != null)
            SearchParam = xn[TransitionName + "_SETUP"].InnerText;
      }

      else
      {
         //TransitionName = TransitionName + "_" + TransType;
         if (xn.SelectSingleNode(TransitionName) != null)
            SearchParam = xn[TransitionName].InnerText;
      }
      Document doc = new Document(stream2);
                  
[b]      //save as file from Spire Doc object
      doc.SaveToFile("C:\\inetpub\\wwwroot\\WSExtractor\\logs\\spireapi_"
         + postedFile.FileName, FileFormat.Doc);[/b]

      StringBuilder sb = new StringBuilder();
      foreach (Section section in doc.Sections)
      {

         /* ensure to read header/footer before paragrah,
          * since Spire Doc API free version has limit of 500 paragraphs and 25 tables */
         HeaderFooter footer = section.HeadersFooters.Footer;
         foreach (Paragraph paragraph in footer.Paragraphs)
         {
            sb.AppendLine(paragraph.Text);
         }

      }
      log.Debug("footer data='" + sb.ToString() + "'");
      foreach (Section section in doc.Sections)
      {
         foreach (Paragraph paragraph in section.Paragraphs)
         {
            sb.AppendLine(paragraph.Text);
         }                   
      }
      data = sb.ToString();
      log.Debug("data='" + data + "'");
}


Also, the doc uploaded to HTTP post and the one read an saved by Spiredoc API is attached.
Documents.zip


379 para count was from MS-WORD app.
379_Para_Count_From Ms-WORD.png

pallavigarg
 
Posts: 3
Joined: Wed Jan 02, 2019 12:16 pm

Fri Jan 04, 2019 9:17 am

Hi pallavi,

Many thanks for the detailed information.
Kindly note the paragraph count from MS-WORD app is not actual paragraph count in Spire. For example, in Word it will not count the paragraphs in TOC while Spire would count that paragraphs. Actually the paragraph count in your document counted by Spire is more than 379.

After saving your document using free Spire.Doc, I indeed reproduced your issue that some paragraphs were missing, sorry for the inconvenience. I have confirmed that your case worked well using Spire.Doc Pack Version:7.1. Please use it and try again.
To help you evaluate our product better, our sales team has sent you one-month free license of Spire.Doc to help removing the warning message. Here is the guide for applying the license.
If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc

cron