The above piece of code is working fine(without Headers and Footers on each page ) .
But when we are trying to display these Headers and Footers on each and every page so as per following link , it is throwing "an invalid save format for this options type was chosen "
// Exception is being thrown
options = new HtmlSaveOptions(SaveFormat.HtmlFixed);
options.DocumentSplitCriteria = DocumentSplitCriteria.PageBreak;
options.ExportHeadersFootersMode = ExportHeadersFootersMode.PerSection;
options.ImagesFolderAlias
= ConfigurationManager.AppSettings["asposeURL"].ToString() +
Convert.ToString(HttpContext.Current.Session["UserId"]) + @"/"
options.ImageSavingCallback = new HandleImageSaving();
doc.Save(firstStream, options);
Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:
Your input Word/HTML document.
Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip and upload them.
Thanks for sharing the detail. Please use SaveFormat.Html instead of SaveFormat.HtmlFixed in HtmlSaveOptions constructor to fix this issue.
Please replace following line of code options = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.HtmlFixed);
with options = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
options = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
As i said in my initial request, the problem lies here when we are trying to achieve Headers and Footers in each page in the converted html using below
options = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.HtmlFixed);
Thanks for your inquiry. If you want to export header and footer for each page in output HTML, we suggest you please use HtmlFixedSaveOptions instead of HtmlSaveOptions.
Can you please update our last shared sample piece of code with your above suggestion and share us as we are getting error like below:
"Resource file(s) cannot be written to disk. When saving the document to a stream either ResourceFolder should be specified or ExportEmbeddedImages, ExportEmbeddedFonts, ExportEmbeddedCss, and ExportEmbeddedSvg should be set or custom streams should be provided via ResourceSavingCallback. "
We tried the above sample as you suggested to achieve capturing all headers, footers and maintaining paging too but it’s giving different problems like below
Can’t generate html with inline styles on html tags itself
Can’t store images in our application custom folder like we did earlier using
Please use HtmlFixedSaveOptions.ExportEmbeddedCss property to specify whether the CSS (Cascading Style Sheet) should be embedded into Html document.
Please use HtmlFixedSaveOptions.ResourcesFolderAlias property to specify the name of the folder used to construct image URIs written into an Html document.
#1 : May be i haven’t made it clear in my last request. Let me give some more input on this. It’s getting created INTERNALLY but we want css styles to be part of each and every html tag(element) that got generated while generating html.
#2 : Can you please give us a working sample for your last suggested approach since we are not able to find any samples nowhere specific to this.
Hope i made it clear now. Please help us in this regard.
Please note that HtmlFixed file format is different from HTML. You can embed the style in HtmlFixed file using HtmlFixedSaveOptions.ExportEmbeddedCss property. However, it is different from inline CSS styles.
Please check the following code example. Hope this helps you.
Still your suggestions are not giving any solution to our initial request.
We tried the above suggested piece of code but still no image/css/etc. file is getting saved in the mentioned resource folder path using options.ResourcesFolderAlias = @“c:\temp”;
Again, giving you my request input:
Generate HTML from DOCX . The generated html should have these below things:
1. Html tags with ONLY inline styles like below
<span "style="font-family:Arial; font-size:10.5pt; font-style:italic; text-decoration:underline; color:#0b0080">Harvard Business Review</span>
2. All the html generated images should be saved(pointed to) to a folder/cloud (which should be configurable)
3. Lastly and MAINLY, capture all the Headers / Footers / Footnotes / Paging
FYI, we’re currently good having solution on above 1&2 using “HtmlSaveOptions” but stuck in finding a solution for above 3.
This’s why we raised this request. When you provide solutions like earlier those are making the solution to fail in both 1 & 2 .
Please provide a concrete solution fort the above requested criteria(1,2 &3).
We have logged this feature request as WORDSNET-16737 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.
Please use HtmlFixedSaveOptions.ResourcesFolder instead of ResourcesFolderAlias. ResourcesFolder allows you to specify where the images will be saved and ResourcesFolderAlias allows to specify how the image URIs will be constructed.
If you still face problem, please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.
#1. As i told we are able to get the HTML inline currently using HtmlSaveOptions but when we are trying your suggested solution HtmlFixedSaveOptions, it’s failing to generate html as requested means INLINE
#2 & 3: Still issue exists even with HtmlFixedSaveOptions.ResourcesFolder
Finally, once again telling you our request
" Generate HTML as output
( with inline styles on each and every html tag along with images with path configurable to a location and able to capture Headers / Footers / Footnotes /Paging on each and every page )
from Doc/DocX. as input"
Thanks in advance. As requested attached the same . PFA and let us know if you need anything in this regard.ASPOSE Sample.zip (178.2 KB)
If you want to save resources (images, fonts, css) to physical folder, please do not use ExportEmbeddedImages, ExportEmbeddedSvg, ExportEmbeddedFonts, and ExportEmbeddedCss properties of HtmlFixedSaveOptions class.
We have converted the shared document to HtmlFixed file format and have not found the shared issues (2nd and 3rd). We have attached the output document with this post for your kind reference. output.zip (5.9 KB)
Please check the exported resources in attached image. resources.png (18.9 KB)
Thanks for your inquiry. You can achieve the 2nd and 3rd requirement using latest version of Aspose.Words for .NET 18.4.
Regarding your first requirement (inline styles for HtmlFixed file format), please note that we try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.
Currently, this feature is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.
If you can give us an approximate time that in how many days we can make a decision on providing an estimate so that we will plan our work which dependent on this.
Thanks for your inquiry. Unfortunately, we cannot share the EAT at the moment. This feature is pending for analysis and is in the queue.
You asked for this feature in free support forum and it will be treated with normal priority. To speed up the progress of issue’s resolution, we suggest you please check our paid support policies from following link. Paid Support Policies