HtmlConverter not honering the formatting information

Feb 6, 2014 at 4:35 AM
I was successfully able to convert the paragraph into the HTML using converter.
but all paragraphs are missing the color. How to generate CSS information for this requirement?
Feb 6, 2014 at 5:57 AM
Hi,

Will you kindly post a document that contains color where the color is missing from the HTML?

I know that in most cases, the color is converted properly, but apparently I have missed a case, so if I have the misbehaving document, I'm sure I can fix it quickly.

Cheers, Eric
Feb 7, 2014 at 3:58 AM
Hi Eric,

Nice to see your email in my Inbox. I am really happy to save your email as i see lots of wonderful job from you.

Please find attached simple document that i used. ( Created using MsWord from MAC ).
Also, i got null pointer exceptions at various locations just to make things work for my testing, i modified code to handle null and return null value back to caller.

Here are my modifications:

diff -C2 ../pt26/OpenXmlPowerTools-2-06-00/OpenXmlPowerTools/PtOpenXmlUtil.cs OpenXmlPowerTools/PtOpenXmlUtil.cs
*** ../pt26/OpenXmlPowerTools-2-06-00/OpenXmlPowerTools/PtOpenXmlUtil.cs 2014-01-29 18:59:48.000000000 -0600
--- OpenXmlPowerTools/PtOpenXmlUtil.cs 2014-02-05 21:45:04.664790900 -0600
***************
*** 37,43 ****
public static XDocument GetXDocument(this OpenXmlPart part)
{
try
{
! XDocument partXDocument = part.Annotation<XDocument>();
if (partXDocument != null)
return partXDocument;
--- 37,45 ----
public static XDocument GetXDocument(this OpenXmlPart part)
{
+ XDocument partXDocument = null;
+ if (part == null) return partXDocument;
try
{
! partXDocument = part.Annotation<XDocument>();
if (partXDocument != null)
return partXDocument;

*** ../pt26/OpenXmlPowerTools-2-06-00/OpenXmlPowerTools/HtmlConverter.cs 2014-01-30 15:39:40.000000000 -0600
--- OpenXmlPowerTools/HtmlConverter.cs 2014-02-05 22:12:31.055158300 -0600
***************
*** 1227,1238 ****

// w:defaultTabStop in settings
! var defaultTabStop = (int?)wordDoc.MainDocumentPart.DocumentSettingsPart.GetXDocument().Descendants(W.defaultTabStop).Attributes(W.val).FirstOrDefault();
! if (defaultTabStop == null)
! defaultTabStop = 720;

! XDocument pxd = wordDoc.MainDocumentPart.GetXDocument();
! XElement newRoot = (XElement)CalculateSpanWidthTransform(pxd.Root, (int)defaultTabStop);
! pxd.Root.ReplaceWith(newRoot);
! wordDoc.MainDocumentPart.PutXDocument();
}

--- 1227,1245 ----

// w:defaultTabStop in settings
! if (wordDoc.MainDocumentPart.StyleDefinitionsPart != null)
! {
! if (wordDoc.MainDocumentPart.DocumentSettingsPart.GetXDocument() != null)
! {
! var defaultTabStop = (int?)wordDoc.MainDocumentPart.DocumentSettingsPart.GetXDocument().Descendants(W.defaultTabStop).Attributes(W.val).FirstOrDefault();
! if (defaultTabStop == null)
! defaultTabStop = 720;

!
! XDocument pxd = wordDoc.MainDocumentPart.GetXDocument();
! XElement newRoot = (XElement)CalculateSpanWidthTransform(pxd.Root, (int)defaultTabStop);
! pxd.Root.ReplaceWith(newRoot);
! wordDoc.MainDocumentPart.PutXDocument();
! }
! }
}

*** ../pt26/OpenXmlPowerTools-2-06-00/OpenXmlPowerTools/MarkupSimplifier.cs 2014-01-29 21:51:30.000000000 -0600
--- OpenXmlPowerTools/MarkupSimplifier.cs 2014-02-05 21:47:35.393234900 -0600
***************
*** 94,98 ****
{
XDocument settingsXDoc = doc.MainDocumentPart.DocumentSettingsPart.GetXDocument();
! settingsXDoc.Root.Elements(W.rsids).Remove();
doc.MainDocumentPart.DocumentSettingsPart.PutXDocument();
}
--- 94,98 ----
{
XDocument settingsXDoc = doc.MainDocumentPart.DocumentSettingsPart.GetXDocument();
! if(settingsXDoc != null) settingsXDoc.Root.Elements(W.rsids).Remove();
doc.MainDocumentPart.DocumentSettingsPart.PutXDocument();
}


Presently for another document i am getting null pointer exception when Reveser() is called.
File name: FieldRetriever.cs
FieldElementTypeInfo<Stack> fis = new Stack<FieldElementTypeInfo>(s.FiStack.Reverse());

Thanks,
Madhava

Feb 18, 2014 at 6:44 AM
Hi Madhava,

I finally carved out some time to look at this - but I can't see the attached document. Can you please try to post it here and attach it again?

Thanks, Eric
Feb 18, 2014 at 5:24 PM
Hi Eric,

sorry for delay as i was not available to work.
Please find the document attached.


Thanks,
http://developertoolsautomation.blogspot.in/ ( TECHNOLOGY SOLUTIONS )
http://madhavkulkarni.blogspot.in/ ( GENERAL WRITING )
http://dailylifeinindia.blogspot.in/ ( USEFUL SOCIAL HELP )