Folder properties : Criticism

Hello,
There are some Folder / FolderAlias properties in different SaveOptions.

The bad behavior is that some of them have Null/Nothing as default while some have String.Empty as default.
Some should get Null/Nothing while some only accept String.Empty.

SvgSaveOptions.ResourcesFolder / SvgSaveOptions.ResourcesFolderAlias : Default is null.

HtmlSaveOptions.ResourceFolder / HtmlSaveOptions.ResourceFolderAlias Default is an empty string. If we assign null: System.ArgumentNullException in Aspose.Words.dll: Value cannot be null.

This causes confusion, IMO, for all properties ending with Folder / FolderAlias that accept a folder as string, internally, you should check if input value: String.IsNullOrWhiteSpace instead of String.IsNullOrEmpty

Beside that, I’m strongly against Null Nothing which was the billion dollar mistake of Sir Tony Hoare:

The Spec# programming system: An overview, by Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte. In CASSIS 2004, LNCS vol. 3362, Springer, 2004, they wrote

1.0 Non-Null Types Many errors in modern programs manifest themselves as null-dereference errors, suggesting the importance of a programming language providing the ability to discriminate between expressions that may evaluate to null and those that are sure not to (for some experimental evidence, see [24, 22]). In fact, we would like to eradicate all null dereference errors.

https://www.youtube.com/watch?v=YYkOWzrO3xg

@australian.dev.nerds Thank you for pointing this.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25585

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Thanks, just to mention I forgot:

HtmlFixedSaveOptions : ResourcesFolder / ResourcesFolderAlias / TempFolder > Default is null.

While such folderss’ default in HtmlSaveOptions > String.Empty

BTW:

HtmlSaveOptions is used for Html Mhtml Epub Azw3 Mobi
What about HtmlFixedSaveOptions, only for Html? And not for Mhtml or orher ebooks above?

And is:
HtmlSaveOptions.ExportPageSetup = True
the same as using HtmlFixedSaveOptions ?

Any advise when converting email messages (mhtml) to Html, which one should be used?
HtmlSaveOptions vs HtmlFixedSaveOptions?

Sorry my last query:

HtmlSaveOptions , these 3 properties:

ExportImagesAsBase64
ExportFontsAsBase64
ExportPageSetup

If set to False, and is used to save as Mhtml EPUB AZW3 MOBI
What happens?
I mean, for example, the nature of Mhtml is to embed all files within in (RFC-822 eml)

@australian.dev.nerds

Yes, we have noticed this and added to the WORDSNET-25585 task description.

HtmlSaveOptions class is for saving document in flow HTML like formats. Structure of such documents is closer to the original MS Word document. On other hand HtmlFixedSaveOptions is for saving to HtmlFixed format, which is built from another document model - after building document layout. It’s structure is more closer to PDF or XPS, i.e. it is build from absolutely positioned elements. This format is good for viewing, but is not applicable for document roundtrip or for editing.

Not, it is not the same. HtmlSaveOptions.ExportPageSetup allows to preserve page setup of the original document in HTML for further usage.

It depends on your needs. If you need a simple flow HTML, to view in browser or edit in HTML editor, HtmlSaveOptions should be used. If it is required to get HTML only for viewing purposes and HTML should look the same as original document looks in MS Word, then HtmlFixedSaveOptions should be used.

1 Like

Hello

I still could not get:
https://reference.aspose.com/words/net/aspose.words.saving/htmlsaveoptions/exportimagesasbase64/

ExportImagesAsBase64
Specifies whether images are saved in Base64 format to the output HTML, MHTML or EPUB. Default is false.

The nature of MHTML (which is exact equivalent of RFC-822 Eml) is all files embedded in MIME parts, saving images externally does not make sense.

I mean when saving as Mhtml, ExportImagesAsBase64 = False does not make sense, or I’m missing something?!


HtmlSaveOptions > CssStyleSheetType

When we wanna embed it to the Html file, 2 options are there:
0 Inline
1 Embedded
Any advise on which one to choose?

Thanks :slight_smile:

@australian.dev.nerds

  1. HtmlSaveOptions is a class that has a combination of properties related to HTML-based formats. You are right ExportImagesAsBase64 is not applicable for Mhtml, so you can simply leave it with a default value.

  2. The choice of CssStyleSheetType depends on your needs. The default value is Inline.

1 Like

Hello and thanks,

Yes, I already disregarded that, just mentioned to raise your awareness to update the docs or inner code to avoid confusion of the developers.

Kindly run my sample and the check the output generated Tiff file, extra information is rendered at the end of the file.
WindowsApplication11.zip (26.0 KB)

Note that my source file might have problems, but am not sure, because Outlook 2021 shows it correctly, but ancient Windows Live Mail does not.

And looking into my code, for such usages, when directly converting mhtml to other formats like Tif, Pdf, Html, Doc/x, setting SaveOptions > UpdateFields to True or False makes any change? (Not making or altering the source or target file, just might use password encryption for pdf, doc or docx)
Best :slight_smile:

@australian.dev.nerds

We will consider splitting HtmlSaveOptions. This task is logged as WORDSNET-24635. We will let you know once it is resolved.

Please note EML format is not supported by Aspose.Words. In your case EML document is loaded by Aspose.Words as MHTML and as I can see if open the attached file as MHTML it looks the same as Aspose.Words output. You can try using Aspose.Email to work with e-mail files, like MSG and EML.

UpdateFields option has an effect only if the document contain fields.