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 Jul 05, 2011 7:50 am

convert doc, docx to Image (jpg)
Is this feature available in current version?

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Tue Jul 05, 2011 8:28 am

Dear kma1975,
Thanks for your inquiry.
Here is a sample demo
Code: Select all
//Create word document
            Document document = new Document();
            document.LoadFromFile(@"..\..\..\..\..\..\Data\Word.doc");

            //Save doc file.
            Image img = document.SaveToImages(0, ImageType.Metafile);
            img.Save("sample.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Thu Jul 07, 2011 12:24 pm

Hi Justin Weng,

Thanks for your reply.

I can convert normal word doc to images.
But the one I really need to convert to image is not working.
I have the following error.
Font 'Helvetica' does not support style 'Regular'.
Here is my code.
byte[] fileContent = Edit_Document;
MemoryStream ms = new MemoryStream(fileContent);
Document document = new Document(ms, FileFormat.Doc);

//Save doc file.
System.Drawing.Image img = document.SaveToImages(0, ImageType.Metafile);
ms = new MemoryStream();
// Error Occur
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

I try to attach sample doc that cause the error but file extension is not allowed to upload.
The document has Chart item and tables and font used is Helvetica.
Any help would be appriciated.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Fri Jul 08, 2011 1:28 am

Dear kma1975,
Thanks for your inquiry.
You should compress files to ZIP. And then upload to us.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Fri Jul 08, 2011 2:21 am

Hi,

Thanks. Here is sample doc.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Fri Jul 08, 2011 5:01 am

Dear kma1975,
Thanks for your inquiry.
Sorry to tell you our Spire.Doc do not support Chart right now.
But we'll have a schedule to research it.
Sorry for unconvenience.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Fri Jul 08, 2011 6:52 am

Hi Justin,

Thanks for your time.
But it was my mistake that I said "Chart" is included inside the doc file.
If you open the sample doc I sent, actually inside is Text, Image and tables.
And the original font using is Helvetica.
Then I got the font conversion error.
Font 'Helvetica' does not support style 'Regular'.
Even I change all to Aerial font and saved, I still got the the same error.

So is there anywhere in your code that taking care of converting fonts inside?

Thank you.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Fri Jul 08, 2011 8:04 am

Dear kma1975,
Thanks for your inquiry.
The file you upload didn't use Helvetica but Arial.
I cann't reproduce your problem. Although the picture I got is not you want(some errors).
I upload your doc file and picture I got. Please have a check.
Give us your full code or your test solution will be better.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Sat Jul 09, 2011 6:00 am

Hi Justin,

Yes. Because of I got the font converting error, I changed all text to Aerial.
Then tried again still got the same font error.

Then I change my code to
System.Drawing.Image img = document.SaveToImages(0, ImageType.Bmp);

Then no error, but I got the same picture like you. (not what I expected)
If I create the new word file and put text, imange and formatted table, it works.
But the one we have to convert is prepared and uploaded by our customer to the system.

Any suggestion and workaround, please let me know.
Thanks for the good response and help.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Mon Jul 11, 2011 9:20 am

Dear kma1975,
Thanks for your inquiry.
Please upload your font converting code demo/snippet to us, so that we can fix your problem.
About Doc to Image, it's a bug we are dealing with.
Once we finished we will inform you.
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Wed Jul 13, 2011 2:32 am

Hi Justin,

I didn't develop font converting code.
Document is using Helvetica Regular font and I got the error message
Font 'Helvetica' does not support style 'Regular'.
in following line.
System.Drawing.Image img = document.SaveToImages(0, ImageType.Metafile);
If I change the code to ImageType.Bmp, then no error.
But the image is not what I expected.

So after the bug fixed, pls let me know.
Thanks.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Fri Jul 15, 2011 10:17 am

Hi kma1975,

A new version will be released in the next week and could help you solve this problem.

Feel free to contact us! Have a nice day!
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Mon Jul 18, 2011 5:33 am

Hi

Happy to hear that.
Really waiting.

Thanks for effort.

kma1975
 
Posts: 7
Joined: Mon Jul 04, 2011 9:12 am

Tue Jul 19, 2011 7:19 am

Hi Justin,

We bought the Spire.Office yesterday.
I have downloaded the latest version and tested the doc to image again and still fail.
The outcome image is not what we expected.
Please help us on this.

spiresupport
 
Posts: 8
Joined: Tue Jul 19, 2011 5:55 am

Tue Jul 19, 2011 7:35 am

Dear kma1975,
Thanks for your inquiry.
The latest Spire.Doc version is 4.0.6, please have a check http://www.e-iceblue.com/Download/download-word-for-net-now.html
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

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

Return to Spire.Doc