Fixed Html

Hello,
After saving an html file to fixed html, may I load back the fixed html again? Because loading back saved fixed html and saving it again as html will render some issues, for example, the place of image has been changed in this sample, kindly run it and compare out1 vs out2
Best
WinApp7.zip (6.3 MB)

@australian.dev.nerds Unfortunately, there is no way to load HtmlFixed to Aspose.Words DOM preserving it structure. HtmlFixed was designed for preserving MS Word document layout only for viewing purposes. This format is not designed for document roundtrip. Its structure may not be loaded correctly.

1 Like

Thanks for clarification, appreciated, it was nice if at the save time of HtmlFixed some kind of tag was inserted into the Html document so FileFormatInfo.LoadFormat would detect it as HtmlFixed for developer to decide decline opening or issue some warning, just an idea…

FileFormatInfo.HasDigitalSignature seems more wise to be FileFormatInfo.IsSigned, as many other similar SDKs use IsEncrypted/IsSigned, just a naming idea…

If FileFormatInfo.HasDigitalSignature = True, can we get the certificate(s) in x509Certificate2 (collection)?

@australian.dev.nerds Aspose.Words shows the following warning when HtmlFixed document is loaded:

The document is fixed-page HTML. Its structure may not be loaded correctly.

LoadOptions opt = new LoadOptions();
opt.WarningCallback = new WarningCallback();
Document doc = new Document(@"C:\Temp\in.html", opt);
private class WarningCallback : IWarningCallback
{
    public void Warning(WarningInfo info)
    {
        Console.WriteLine(info.Description);
    }
}
1 Like

Thanks for the tip:
https://reference.aspose.com/words/net/aspose.words.loading/loadoptions/warningcallback/
Is there a vb.net sample? converting the sample using this online tool will not run
( using visual studio .net 2010 .net framework 4.0 )

@australian.dev.nerds Sure, here is the same code in VB.NET:

Dim opt As Aspose.Words.Loading.LoadOptions = New Aspose.Words.Loading.LoadOptions()
opt.WarningCallback = New WarningCallback()
Dim doc As Document = New Document("C:\Temp\in.html", opt)
Private Class WarningCallback
    Implements IWarningCallback

    Public Sub Warning(info As WarningInfo) Implements IWarningCallback.Warning
        Console.WriteLine(info.Description)
    End Sub

End Class
1 Like

Thanks indeed, just one more thing, I have an Rtf saved from Mapi Msg body Rtf part, after loading to Aspose Words, may I set a background color for it without changing anything else?

Only 5 basic colors are needed to set as bg, html names: LightSkyBlue LightGreen LightPink WhiteSmoke LightYellow
Thanks :slight_smile:

@australian.dev.nerds You can use Document.PageColor property to specify page background color.

1 Like

Thanks, I load Outlook MapiMessage’s RTF body part into Document and set background color for it, then save it back as RTF and load back to MapiMessage RTF bodypart.
Output Rtf does not satisfy Outlook Rtf req and the backcolor is not shown in Msg.
Since there are different Rtf versions, and Outlook uses a more basic version versus Word, just wanted to check if there’s some compatibility property to choose when loading/saving Rtf documents
Thanks
I compared 2 Msg files made using Outlook with and without backcolor, after “ilfomacatclnup0” this is inserted to have backcolor:
"{\*\background {\shp{\*\shpinst\shpleft0\shptop0\shpright0\shpbottom0\shpfhdr0\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr0\shpwrk0\shpfblwtxt1\shpz0\shplid1025{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fillColor}{\sv 3506515}}{\sp{\sn fFilled}{\sv 1}}{\sp{\sn lineWidth}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn bWMode}{\sv 9}}{\sp{\sn fBackground}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 1}}}}}\"

@australian.dev.nerds I am afraid, there are no compatibility properties to make RTF compatible with outlook messages. Aspose.Words is designed to work with MS Word document at first, so RTF produced by Aspose.Words is optimized for MS Word and other more advanced viewers.

1 Like

Thanks, so no option to choose to save as classic Rtf vs https://interoperability.blob.core.windows.net/files/MS-OXRTFEX/%5bMS-OXRTFEX%5d.pdf? :slight_smile:

What about the code page and language of output Rtf?
For example, in the 1st line of this Rtf:

{\rtf1\ansi\**ansicpg1252**\deff0\nouicompat\**deflang1033**{\fonttbl{\f0\fswiss\fcharset0 Calibri;}}

Deleted, Thanks :slight_smile:

@australian.dev.nerds

No, unfortunately, there is no such option.

Aspose.Words always writes ansicpg1252 codepage. And the following languages defaults in the RTF header:

builder.WriteControlWord("\\deflang1033");          // US English
builder.WriteControlWord("\\deflangfe2052");        // Chinese China
builder.WriteControlWord("\\adeflang1025");         // Arabic
1 Like

Thanks, ok but any option to permanently exclude Chinese from the default header?

@australian.dev.nerds No, unfortunately, there is no way to exclude it.