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.

Thu Jan 14, 2016 3:34 pm

Hi,

I'm having trouble converting docx to html with external styles.

I'm using following code:

Code: Select all
Document doc = new Document();
doc.LoadFromFile("D:\\ManagingImportantRecords.docx");
doc.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.External;
doc.SaveToFile("D:\\aaa\\ManagingImportantRecords.html", FileFormat.Html);


alldough conversion is ok, and I get external css file with styles and classes, a lot of styles remains inline with Html document.

Am I doing something wrong or is there another way to do this without styles remaining inline?

Thanks,
Dragan

DraganDragan
 
Posts: 2
Joined: Tue Nov 03, 2015 12:22 pm

Fri Jan 15, 2016 1:42 am

Hi,

Thanks for your posting and using our Spire.Doc.
Please try internal type.
Code: Select all
   doc.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.Internal;


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Mon Jan 18, 2016 9:38 am

Hi Amy,

thanks for you prompt reply.

The thing is, I want them to be external, as a separate css file, but although I creates the file, lots of styles are still in html file inline-d.

Is there a way to get them external in file (as it is) but not leave them in the html markup.

Thanks,
Dragan

DraganDragan
 
Posts: 2
Joined: Tue Nov 03, 2015 12:22 pm

Tue Jan 19, 2016 2:52 am

Hi Dragan,

Thanks for your further information.
Sorry that at present we have no ways to get such external css file.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Fri Sep 20, 2019 1:50 pm

Hi,
There is any way to design inline style without Spire.Doc, Because i am already using Spire.pdf and Spire.XLS in my application.
Thanks

prism
 
Posts: 20
Joined: Thu Aug 15, 2019 11:16 am

Mon Sep 23, 2019 7:23 am

Hi,

Thanks for your inquiry.
Do you want to design the inline styles while converting Word file to Html file but not using Spire.Doc? If so, I'm afraid it is not advisable, Spire.Doc is the only choice for you to convert Word file to Html file.
If I misunderstand, to help us better investigate your issue, please provide detailed information.
1. Your input file.
2. Your desired result file.

Best wishes,
Amber
E-iceblue support team
Last edited by Amber.Gu on Thu Sep 26, 2019 8:15 am, edited 2 times in total.
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Mon Sep 23, 2019 1:04 pm

Hi,

Thanks, There is any way to convert bitmap to HTML using spire product. And I want to add inline image style and name at the time of image to HTML conversion.

With Regards
Arunkumar R

prism
 
Posts: 20
Joined: Thu Aug 15, 2019 11:16 am

Tue Sep 24, 2019 9:58 am

Hi,

Thanks for your reply.
Sorry that our products don't support to convert image to Html file directly at present. But you could use Spire.Pdf to draw the image on the Pdf page first then save the page to Html file, and the image will be embedded in the result Html file automatically. Below is the code for your reference.

Code: Select all
            //Create a pdf document with a section and page added.
            PdfDocument doc = new PdfDocument();
            PdfSection section = doc.Sections.Add();
            PdfPageBase page = doc.Pages.Add();

            //Load an image from system
            PdfImage image = PdfImage.FromFile(@"……\Logo.png");
            //Set image display location and size in PDF
            float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;
            float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;
            float fitRate = Math.Max(widthFitRate, heightFitRate);
            float fitWidth = image.PhysicalDimension.Width / fitRate;
            float fitHeight = image.PhysicalDimension.Height / fitRate;
            //Draw the image on Pdf page.
            page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight);

            //Convert the Pdf file to Html file.
            doc.SaveToFile("toHtml.html", FileFormat.HTML);


If the code couldn't solve your issue, please offer us your input file and your desired result file for further investigation.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Wed Sep 25, 2019 12:00 pm

Hi,
Thanks, I need one more thing. There is any possibility to insert customized image title in HTML within the <figcaption> tag.

Thanks
With Regards
Arunkumar R

prism
 
Posts: 20
Joined: Thu Aug 15, 2019 11:16 am

Thu Sep 26, 2019 7:59 am

Hi,

Thanks for your reply.
Sorry to tell you that our products don't support to set customized image title within <figcaption> tag while converting file to Html file at present.
Any question, welcome to contact us.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.Doc