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.

Tue Aug 02, 2011 4:44 am

I have already learnt how to extract paragraph from a doc file, but i need divide a document by pages.

How to solve this problem? Is there any function I can use?

and additionally, it can't deal with Chinese characters, it will be translated to "?". Why? it may be my web-server's problem.

Code: Select all
StreamReader sr1 = new StreamReader(cssPath, System.Text.Encoding.Default);


I use this code to encode the files.

these two problems puzzle me in a long time, anyone can help me?

ethan.li
 
Posts: 5
Joined: Tue Aug 02, 2011 4:07 am

Tue Aug 02, 2011 7:11 am

Dear ethan.li,
Thanks for your inquiry.
# About divide by pages, there are 3 optional solution.
1. Save to Pdf and the divide by pages.
Code: Select all
 Document doc = new Document();
            doc.LoadFromFile("test.doc");
            using(MemoryStream stream=new MemoryStream())
            {
                doc.SaveToStream(stream,FileFormat.PDF);
                PdfDocument pdfDoc = new PdfDocument();
                pdfDoc.LoadFromStream(stream);
                String pattern = "SplitDocument-{0}.pdf";
                pdfDoc.Split(pattern);
            }

2. Save to Images by pages
Code: Select all
Document doc = new Document();
            doc.LoadFromFile("test.doc");
            Image[] images = doc.SaveToImages(Spire.Doc.Documents.ImageType.Bitmap);
            int i=0;
            foreach (Image image in images)
            {
                image.Save(string.Format("{0}.bmp", i++), System.Drawing.Imaging.ImageFormat.Bmp);
            }

3. Save to doc by Sections. Since it's no way to save by pages right now.
Code: Select all
Document doc = new Document();
            doc.LoadFromFile("test.doc");
            Document divideDocument = new Document();
            int i=0;
            foreach (Section sec in doc.Sections)
            {
                Section section=sec.Clone();
                divideDocument.Sections.Add(sec);
                //Section section = divideDocument.Sections.Add(sec);
                //section = sec;
                divideDocument.SaveToFile(string.Format("{0}.doc", ++i));
                divideDocument.Close();
            }


#2 About Chinese characters, I need more details. You can upload your demo code to me.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Tue Aug 02, 2011 9:01 am

Thanks for solving my problem. I will try your solutions.

The Chinese character's problem is:

Code: Select all
                    Document document = new Document();
                    document.LoadFromFile(SaveFilePath);
                    document.SaveToFile(htmlPath, FileFormat.Html);


then, i checked the content in "htmlPath", the chinese characters is changed into "??".

I develop this function in website(asp.net and c#), maybe I should config my web, but I have tried add

Code: Select all
    <globalization
        requestEncoding="gb2312"
        responseEncoding="gb2312"
    />

in the web.config, it still doesn't work.

can you help me to solve this problem? thanks!

ethan.li
 
Posts: 5
Joined: Tue Aug 02, 2011 4:07 am

Wed Aug 03, 2011 1:45 am

Dear ethan.li,
Thanks for your inquiry.
You should upload your doc/docx files to me so that I can reproduce your problem.
I tested a doc file and got nothing wrong.
The rusult html file I got is used UTF8 encoding.
Like this:
Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Maybe you can use UTF8 encoding.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Wed Aug 03, 2011 7:00 am

hello,

Thanks for your reply, i have solved the problem about chinese characters. :D

and what's more. I use the spire.doc for transforming the .doc to .pdf, and it remains a lot of "同" and “支” characters in the white space of the pdf document. like this:

Evaluation同Warning同:同The同document同was同created同with同Spire.Doc同for同.NET.


支支支支支支支支支支支支支支支支 支支 目前生产企业采购业务面临的十大机遇问题和十大问题 支支支支支支支支支支支支支支支支支支支支


this problem happens because i just use the free version? If I buy the license, this problem will be completely fixed?

Thanks

Ethan

ethan.li
 
Posts: 5
Joined: Tue Aug 02, 2011 4:07 am

Wed Aug 03, 2011 7:38 am

Dear ethan.li,
Thanks for your inquiry.
About convert to pdf problem, maybe it's a bug.
It's no functional difference between versions.
We need your doc files to reproduce your problem.
Best regards.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Wed Aug 03, 2011 7:58 am

Dear Justin:

try this file. I just download randomly online.

and there is another doc file, 2 tables included, failed converting to pdf. Why...
Ok, i will try more doc files.

Thanks a lot.

Ethan.

ethan.li
 
Posts: 5
Joined: Tue Aug 02, 2011 4:07 am

Thu Aug 04, 2011 1:58 am

Dear ethan.li,
Thanks for your inquiry.
You just upload only 1 doc file.
I can not reproduce "支支支支支支支支支支支支支支支支 支支 目前生产企业采购业务面临的十大机遇问题和十大问题 支支支支支支支支支支支支支支支支支支支支"
And the file you uploaded has Shape which we do not support right now.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Thu Aug 04, 2011 7:10 am

Dear Justin,

I don't now why my program produce like this, and exactly there is no shape or image in the document, the results is pretty good.
I just let the file upload to server first, and open it, then convert it. and, i find it's a little slow when i convert a doc to pdf first then save it into html.
honestly, If I there is a function can read the doc by pages, It will certainly save my time.
Why not let spire.doc have that function in next version? I think it is an essential one, not only me need it.

Thanks for your help.

Ethan

ethan.li
 
Posts: 5
Joined: Tue Aug 02, 2011 4:07 am

Return to Spire.Doc