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.

Sun Oct 26, 2014 9:42 am

I'm currently making some experiments with the free version of Spire.Doc. However, despite the license limitation of 100 paragraphs per document, I can't add more than the half.
Here is the snippet.

Code: Select all
            const int size = 100;

            string[] names = Enum.GetNames(typeof(Spire.Doc.Documents.BuiltinStyle));
            int count = 0;

            while (count < names.Length)
            {
                //Create New Word
                using (var document = new Spire.Doc.Document())
                {
                    //Add Section
                    Spire.Doc.Section section = document.AddSection();

                    //enumerate built-in styles
                    for (int n = 0; n < size; n++)
                    {
                        if (count + n >= names.Length) break;

                        var bs = (Spire.Doc.Documents.BuiltinStyle)Enum.Parse(
                            typeof(Spire.Doc.Documents.BuiltinStyle),
                            names[count + n]
                            );

                        Spire.Doc.Documents.Paragraph p = section.AddParagraph();
                        p.ApplyStyle(bs);
                        p.AppendText(names[count + n] + Environment.NewLine);
                    }

                    //Save Word
                    document.SaveToFile(
                        string.Format(@"C:\Users\Mario\Documents\BuiltInStyles_{0}.docx", count),
                        Spire.Doc.FileFormat.Docx
                        );

                    count += size;
                }
            }

            Console.WriteLine("Complete.");

When I put the break to the "SaveToFile" method (so, *before* executing it), the only section shows exactly 100 paragraphs. However, the execution of the "SaveToFile" method throws an exception caused by the limitation overflow. By re-watching the section content, it appears that the paragraphs are doubled.
If I set the "size" const to 50, everything goes fine. If I set to 51, an exception is raised.
Where's the trick?

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Oct 27, 2014 2:11 am

Dear vernarim

Thanks for your inquiry.

In your code snippet, you add a paragraph with text and an Enviroment.NewLine which causes this problem:
Code: Select all
p.AppendText(names[count + n] + Environment.NewLine);

Please remove "Enviroment.NewLine" and it will go well.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Oct 29, 2014 7:04 am

Dear vernarim,

Have you tried the method I provided you to resolve the problem?
Please feel free to contact us if you have any problems.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Nov 03, 2014 6:37 am

Dear vernarim,

Have you tried the method?
Please feel free to contact us if you have any problems.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Nov 04, 2014 1:30 pm

My apologies! I didn't realize that you asked me a feedback, and -yes- I wasn't on the forum since your first answer.

Back to the original problem...
Of course it works. I wasn't aware that every "new-line" is actually a paragraph, and that faces the free-license limitation which is indeed very...limiting. However, for a descriptive text won't be a huge problem.

I also realized that on a table every single cell counts at least with a paragraph. THAT is really limiting!
Let me know if there's a workaround...

Thanks anyway.

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Wed Nov 05, 2014 2:27 am

Dear vernarim,

I'm sorry I cannot get you. When you create table, there is no paragraph in cells unless you call method "cell.AddParagraph()", you can see that in Debug view. Also you can create many paragraphs in one cell as you wish. There is no limit in paragraphs in cell.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Nov 24, 2014 6:32 am

Thank you very much for the info: I was unaware about that.
I'm happy to hear about the table, however I'm facing the three-pages limitation on the PDF conversion, which actually forces me to limit the number of rows in my table.
No matter, anyway: I chose a 50-rows table, which should be enough for what I'm doing.
Many thanks again.
Mario

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Nov 24, 2014 6:55 am

Dear vernarim,

Please feel free to contact us if you have any problems.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc