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 Feb 03, 2022 2:27 pm

Hi, I need to convert HTML to DOCX in .net. I have testing a sample through .Doc nuget package and it worked well, However I need to test the below features as well , can u pls confirm whether below features are supported and if it does, how to configure.

Does this package work in Azure app services
How to load custom fonts ( many of our clients have their own fonts , and should be loaded in Azure app service)
How to load images through web URLs , need to add authentication header tokens for those urls.
The html file will not have the CSS inline, instead add the css external on conversion. the requirement is we need to format the same HTML with different styles when converted to word. should be able to add page margins as well.

Appreciate if you can share this information at your earliest.

sathsaranim
 
Posts: 3
Joined: Thu Feb 03, 2022 2:15 pm

Fri Feb 04, 2022 7:50 am

Hello,

Thanks for your inquiry. Below are my answers to your questions.
1. Spire.Doc supports working with Azure app services.
2. We provide the PdfDocument.SetCustomFontsFolders("fontFolder") method to load fonts from custom folder.
3. Spire.Doc supports loading the html in which the image src is web url.
4. Spire.Doc supports loading the html which links external css.
5. Setting page margin is also available. Please refer to this tutorial: Set Word Page Margins.

If there is any question during testing, please feel free to contact us.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Mon Feb 07, 2022 8:34 am

Thanks for your response, can you please further clarify below

2. We provide the PdfDocument.SetCustomFontsFolders("fontFolder") method to load fonts from custom folder. - This if for PDF documents, do you have a sample code for loading for Word documents.
3. Spire.Doc supports loading the html in which the image src is web url. - The external URLs works as long as that url does not need any authentication headers added. we load images through authenticated urls via bearer token. Can we incept the request for image and add the authentication header from code.
4. Spire.Doc supports loading the html which links external css. - The css works as long as its included as a external link in the head of html. We need to set the css when converting the document which will not be available in the html header section. for example something like document.setCssStyles(cssurl);

sathsaranim
 
Posts: 3
Joined: Thu Feb 03, 2022 2:15 pm

Mon Feb 07, 2022 10:31 am

Hi,

Thanks for your feedback.
2. When converting HTML to Docx, our Spire.Doc will use the fonts that you set in your html. If there is no font declaration in html, the font (Times New Roman) will be used by default. Do you want to reset the text font before converting to Word? If so, your could try the code below.
Code: Select all
//load html
Document document = new Document();
document.LoadFromFile("test.html",Spire.Doc.FileFormat.Html,XHTMLValidationType.None);
//loop through elements
foreach (Section section in document.Sections)
{
    foreach (Paragraph para in section.Body.Paragraphs)
    {
        foreach (DocumentObject documentObject in para.ChildObjects)
        {
            if (documentObject is TextRange)
            {
                //set text font
                TextRange textRange = documentObject as TextRange;
                textRange.CharacterFormat.FontName = "Aleo";
            }
        }
    }
}
//save to word
document.SaveToFile("result.docx", Spire.Doc.FileFormat.Docx2013);

3&4. Sorry the two requirements are not available in our Spire.Doc.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 01, 2022 1:03 pm

Thanks, i tried to convert attached html to docx, but it give a null exception, but if i remove below part from the style sheet it works,
.commentary-ext-container p {
line-height: 1.5;
color: #707070;
text-align: justify
}

sathsaranim
 
Posts: 3
Joined: Thu Feb 03, 2022 2:15 pm

Wed Mar 02, 2022 9:22 am

Hi,

Thanks for your feedback.
I have reproduced your issue and logged it into our bug tracking system with the ticket number SPIREDOC-7467. Once it is resolved, I will inform you immediately.
Apologize for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Mon Aug 01, 2022 9:31 am

Hi,

Thanks for your patient waiting.
I'm writing to inform you that the SPIREDOC-7467 has been fixed and the hotfix (Spire.Doc Pack(hot fix) Version:10.7.16) is available. Please download it from the following link.
Website download link: https://www.e-iceblue.com/Download/download-word-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Doc/10.7.16

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Doc