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.

Fri Dec 20, 2019 10:50 am

Hello,

I try to create a word document with the free version of Spire.DOC.
When I create the document, the exception "Spire.Doc free version is limited to 500 paragraphs" appears. But when I count the number of paragraphs, I count only 311 paragraphs.
Maybe is because every new lign ("\n") is count as a new paragraph?
Can you tell me how you define a paragraph?

I join my code and the console to this post.

Sincerely,
Vancia COLLEONI

Code: Select all
int nbPara = 0;
       
Document doc = new Document();
Section section = doc.addSection();
Paragraph para1 = section.addParagraph();
Paragraph para2 = section.addParagraph();
           
ParagraphStyle style1 = new ParagraphStyle(doc);
style1.setName("titleStyle");
style1.getCharacterFormat().setBold(true);
style1.getCharacterFormat().setTextColor(Color.BLUE);
style1.getCharacterFormat().setFontName("Arial");
style1.getCharacterFormat().setFontSize(20f);
doc.getStyles().add(style1);
para1.applyStyle("titleStyle");
para1.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);      
            
ParagraphStyle style2 = new ParagraphStyle(doc);
style2.setName("title2Style");
style2.getCharacterFormat().setBold(true);
style2.getCharacterFormat().setTextColor(Color.BLUE);
style2.getCharacterFormat().setFontName("Arial");
style2.getCharacterFormat().setFontSize(18f);
doc.getStyles().add(style2);
para2.applyStyle("title2Style");
            
                  
para1.appendText("Résumé des modifications");
nbPara += 1;
            
 try {
   for (int i = 0; i < diffs.size(); i ++) {
      para2.appendText("\n \n       " + textes.get(i + 1).getName() + "\n\n").applyCharacterFormat(style2.getCharacterFormat());
                  
      para2.appendText("Dans le fichier " + textes.get(i + 1).getName() + ", on trouve les différences suivantes: \n").applyCharacterFormat(style3.getCharacterFormat());
      nbPara += 2;
                  
      List<String> diffLign = Arrays.asList(diffs.get(i).getContenu().split("\n"));
               
      for (int j = diffLign.size() - 1; j >= 0; j --) {
         para2.appendText("\nLigne: " + diffLign.get(j).substring(diffLign.get(j).indexOf("position revised: ") + 18,
            diffLign.get(j).indexOf(", lines: ")) + "\n").applyCharacterFormat(style3.getCharacterFormat());
         nbPara += 1;
                     
         if (diffLign.get(j).toString().startsWith("[ChangeDelta")) {
            para2.appendText("Type: Modification \nAvant: \n" + diffLign.get(j).substring(diffLign.get(j).indexOf("], lines original: [") + 20,
                         diffLign.get(j).indexOf("], size revised: ")).replaceAll("retourligne", "\r\n") + "\nAprès: \n" +
               diffLign.get(j).substring(diffLign.get(j).indexOf(", lines: [") + 10, diffLign.get(j).indexOf("], lines original: ")).replaceAll("retourligne", "\r\n") +
                                         "\n").applyCharacterFormat(style3.getCharacterFormat());
          nbPara += 1;

         } else if (diffLign.get(j).toString().startsWith("[InsertDelta")) {
            para2.appendText("Type: Insertion \nLignes: \n" + diffLign.get(j).substring(diffLign.get(j).indexOf(", lines: [") + 10,
               diffLign.get(j).indexOf("], size: ")).replaceAll("retourligne", "\r\n") + "\n").applyCharacterFormat(style3.getCharacterFormat());
            nbPara += 1;
                        
         } else if (diffLign.get(j).toString().startsWith("[DeleteDelta")) {
            para2.appendText("Type: Suppression \nLignes: \n" + diffLign.get(j).substring(diffLign.get(j).indexOf(", lines: ") + 9,
               diffLign.get(j).indexOf(", size: ")).replaceAll("retourligne", "\r\n") + "\n").applyCharacterFormat(style3.getCharacterFormat());
            nbPara += 1;
                        
         }
          }               
}
               
               
System.out.println("nbPara: " + nbPara);
                              
doc.saveToFile(Export, FileFormat.Docx);

Vancia97
 
Posts: 1
Joined: Thu Dec 19, 2019 2:31 pm

Mon Dec 23, 2019 6:50 am

Hi,

Thanks for your inquiry.
Yes, the code "par.AppendText("\n \n")" will define a new paragraph. Our sales team has sent you a one-month free license of Spire.Doc via email. And you could have a better evaluation on our products. Please refer to following guide to apply the license:
https://www.e-iceblue.com/Tutorials/Lic ... nsing.html

Sincerely,
Betsy
E-iceblue support team
User avatar

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

Return to Spire.Doc