Quantcast
Channel: html2openxml Discussions Rss Feed
Viewing all 228 articles
Browse latest View live

New Post: List paragraph style not picked up

$
0
0
Looks like I got it to work. My solution is using .NET 4.5. I downloaded the source from here and updated this project to target 4.5, rebuilt and the list now aligns properly with the rest of the paragraphs.

Hope this helps someone.

New Post: deleting blank pages in the word doc using htmltoopenxml

$
0
0
Hello friends,

I have been using this library for the last 6 months and let me tell you, its really wonderful which made creating the word document simpler for us.

Lately I have been facing some issues with the blank pages getting generated in the word document. I have identified the issue cause, its more of a issue with how the html is created.

Is there a way, where we can delete the blank pages in the word document before the response is sent to the user.

Thanks

New Post: deleting blank pages in the word doc using htmltoopenxml

$
0
0
Hello,


Thanks you for your kind comment :-)
Do you know what causes these blank pages?

At the end of the conversion, the lib is cleaning itself with all these blank paragraphs. Take a look at HtmlConverter.RemoveEmptyParagraphs()
In any cases, once the conversion is completed, it will appends everything inside your word document. But you still have full access to that document, and you can apply another transformation using OpenXml SDK on it.

New Post: List Paragraph Styles and Indentation

$
0
0
There have been several different threads on list paragraph styles, bullets, and indenting. One thing I have noticed among them is that the "List Paragraph" style itself seems to behave differently for different developers here.

Consider the current way nested lists are handled:
// Save the new paragraph reference to support nested numbering list.
Paragraph p = currentParagraph;
currentParagraph.InsertInProperties(prop => {
     prop.ParagraphStyleId = new ParagraphStyleId() { Val = htmlStyles.GetStyle("ListParagraph", StyleValues.Paragraph) };
     prop.SpacingBetweenLines = new SpacingBetweenLines() { After = "0" };
     prop.Indentation = new Indentation() { Hanging = "357", Left = (level  * 357).ToString(CultureInfo.InvariantCulture) };
     prop.NumberingProperties = new NumberingProperties
     {
          NumberingLevelReference = new NumberingLevelReference() { Val = level - 1 },
          NumberingId = new NumberingId() { Val = numberingId }
     };
});
For some, it appears the indentation works fine, but when I updated to the latest code for my project, I lost the indentation completely. The solution for me was to change the prop.Indentation to:
prop.Indentation = new Indentation() { Hanging = "357", Left = ((level + 1)  * 357).ToString(CultureInfo.InvariantCulture) };
I wonder if there's something obscure in the way my List Paragraph style is defined that forces me to change the level references. In an earlier version, I had to fix the indentation by removing this line entirely. I can't see anything weird about my list style, all it does is drop the font size slightly and indent by 0.5, but certainly I get different end results than others.

I just want to put this out there in case others are having similar issues with this. It seems that other, possibly local, conditions are in play and if the solutions in the other threads aren't working quite right for you adjusting the levels might help out.

New Post: Borders not appearing in table

$
0
0
Hi,

I have an html table as part of a larger document which I am trying to convert to OpenXml.

When viewed as html, the table appears as it should with the borders all in the correct places, but after converting to OpenXml, when I view the resulting file in Word, none of the borders are visible.

A sample of the code for the table is given below (the real one has a lot more rows).
Does anyone have any idea why the borders wouldn't be appearing when it is viewed in Word?

Thank you in advance.
<table style="border-collapse: collapse;">
    <tr>
        <td style="font-weight: bold; padding: 10px;">
            Heading 1a
        </td>
        <td style="font-weight: bold; padding: 10px;">
            Heading 1b
        </td>
        <td style="font-weight: bold; padding: 10px; border-left: 1px solid #000000;">
            Heading 2a
        </td>
        <td style="font-weight: bold; padding: 10px;">
            Heading 2b
        </td>
    </tr>
    <tr>
        <td style="font-weight: bold; padding: 10px; border-top: 1px solid #000000;">
            Value 1a
        </td>
        <td style="font-weight: bold; padding: 10px; border-top: 1px solid #000000;">
            Value 1b
        </td>
        <td style="font-weight: bold; padding: 10px; border-top: 1px solid #000000; border-left: 1px solid #000000;">
            Value 2a
        </td>
        <td style="font-weight: bold; padding: 10px; border-top: 1px solid #000000;">
            Value 2b
        </td>
    </tr>
</table>

New Post: Borders not appearing in table

$
0
0
I know the "border" attribute on a table needs the "Table Grid" style available in the Word Document, but I'm not sure about border-top or border-left.

I rely heavily on the table styles in Word to render the table borders for me rather than the style tags, but I'm fortunate in that I get to define a good portion of the HTML that I have to convert using this library.

New Post: colspan

$
0
0
I tried to upgrade to the latest commit to take advantage of recent bug fixes (a big thank you to all who have been working on them) but in doing so, colspans stopped working completely for my table headers. I have no rowspans, only colspans:
<tr class="TableHeaderCells">
     <th style="background-color:#FFFF99;" colspan="4"></th>
     <th style="background-color:#FFFF99;" colspan="7"></th>
     <th style="background-color:#FFFF99;" colspan="5">[Header Text]</th>
</tr>
<tr class="TableHeaderCells">
     <th style="background-color:#FFFF99;" colspan="4"></th>
     <th style="background-color:#FFFF99;" colspan="3">[More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="4">[Even More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="3">[Still Even More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="2">[So Much Header Text]</th>
</tr>
Looking at the document as XML it looks like the colspan attributes are being completely ignored but I can't pinpoint where I am losing them. Any thoughts on where to look?

New Post: colspan

$
0
0
To clarify, it seems like I'm losing the "GridSpan" element in the OpenXML:
<w:gridSpan w:val="3"/>
The "old way" of setting this works for me:
            int? colspan = en.Attributes.GetAsInt("colspan");
            if (colspan.HasValue && colspan.Value > 1)
            {
                styleAttributes.Add(new GridSpan() { Val = colspan });
            }
But in the latest build this code doesn't seem to set the colspan for me:
            int? colspan = en.Attributes.GetAsInt("colspan");
            if (colspan.HasValue && colspan.Value > 1)
            {
                properties.GridSpan = new GridSpan() { Val = colspan };
                tables.IndexColumn += colspan.Value - 1;
            }

New Post: Problem with tag not displaying

$
0
0
Hello, I've been trying to make use of an embedded / inline Base64 img tag to display into my OpenXml document.

Basically, what I've just done is I've copied and pasted the code from "How to Start" then replaced the HTML content provided with a sample Base64 inline image (the one provided in the "Image Processing" part on the documentation).

The main problem is that it is not displaying on the generated DOCX file. Additionally, the <hr> tag also is not displaying in the DOCX file.

I am currently using .NET 3.5, OpenXML SDK2.0, Html2OpenXml 1.4.1 (I also tried 1.4.2 to no avail) and finally, Office Professional Plus 2010.

Am I doing anything wrong? Thanks!

New Post: Links in footnotes

$
0
0
Is it possible to add a footnote that contains a link? This is possible with Word but I'm not seeing how it can be achieved here since only text can be put in the title attribute of the <abbr> tag.

Thanks

New Post: Apply Word style based on p class

$
0
0
Looking at the source code, this appears to work for Tables only? Am I wrong? I have HTML with a class, the class is defined in the Doc style sheet, and the classes are not being converted into doc styles.

New Post: Apply Word style based on p class

$
0
0
Thank you, onizet! You have made a great work.
I'm encountered this problem:
I have a .docx as template generated from Word2013.
In this template I have added 3 new style:
  • style_doc_1
  • style_doc_2
  • style_doc_3
This is the HTML I've tried to insert:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
</head>
<body>
    <p class="style_doc_2">Hello world!!!</p>
</body>
</html>
Then I've used this line of code:
var pars = converter.Parse(html)
with a delegate to HtmlStyles.StyleMissing.

Result: the style "style_doc_2" is missing!

I've discovered that the problem is in the TryGetValueIgnoreCase in the OpenXmlDocumentStyleCollection class at line:
int rc = String.Compare(name, keys[mid], StringComparison.OrdinalIgnoreCase);
Microsoft says at
https://msdn.microsoft.com/en-us/library/system.stringcomparison%28v=vs.110%29.aspx:
An operation that uses word sort rules performs a culture-sensitive comparison wherein certain nonalphanumeric Unicode characters might have special weights assigned to them. Using word sort rules and the conventions of a specific culture, the hyphen ("-") might have a very small weight assigned to it so that "coop" and "co-op" appear next to each other in a sorted list.
So the special character "_" (underscore) in "style_doc_2" is not considered in the comparison.

I've modified that line in:
int rc = String.Compare(name, keys[mid],System.Globalization.CultureInfo.CurrentCulture, System.Globalization.CompareOptions.IgnoreCase);
and everithing is fine.

New Post: Apply Word style based on p class

$
0
0
Many thanks for providing such a fix. I really appreciate.
I have created a work item and commit your changes.

New Post: Problem with tag not displaying

$
0
0
Your version of Html2OpenXml lib is too old.
Please, while waiting till v1.6 comes out, download the source.
Sorry for trouble

New Post: Links in footnotes

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

New Post: Links in footnotes

$
0
0
I added several comments to that work item. Not sure if that's monitored so I'm posting here as well.

New Post: heading tag and font name changes are not applied to open xml document

$
0
0
onizet wrote:
Hi,


I've just committed a patch submitted by davide about the font-family attribute that was missing.
For the headings, this is a recurrent question :)
Don't create a new DOCX from scratch but load an existing one. The reason is simple: I don't provide all the theme/style for all the tags.
Finally, since begin of march, I finally decide to embed the default style inside the lib.

So just download the latest source code, recompile and you are done.

Cheers :)
Hi ,
I am facing same problem(heading tag and font name changes are not applied to open XML document).
I checked the patch(Id 15945),Downloaded latest source code,added Converter Utility class explicitly,added GetAsFont method in Converter Utility class as you have asked to do in Patch.
But in Converter Utility class For HtmlFont there is no namespace available (e.g public HtmlFont GetAsFont(String name)).
I want my heading tag and font name changes as it is in word document.

Could you please let me know if this is supported or not? Or am I missing anything?

New Post: Links in footnotes

$
0
0
hello, yes indeed you did well in posting here because I didn't receive the traditional mail alerting...

In fact, I first started coding by accepting both text and links. But I finally think to keep the original HTML cleaner and if you really want an advanced footnote version, maybe I should introduce a new unofficial html tag (say <footnote> for example).
Just imagine what a table should give inside the <abbr> ?
<abbrtitle="<table><tr><td><a href='www.google.be'>link to google</a></td></tr></table>">some text</abbr>
It's starting to be quite ugly and the HTML parser will not like it...

Can you stick with your own custom code to add footnote, using plain OpenXML SDK ?

New Post: heading tag and font name changes are not applied to open xml document

$
0
0
Yes there is really a bug :-(

I have to test more and check against TFS to find why I have not handled this case until now.
But for now and if it's urgent, add this line :
htmlStyles.Paragraph.ApplyTags(currentParagraph);
to ProcessSpan() just before if (newParagraph)

New Post: heading tag and font name changes are not applied to open xml document

$
0
0
Ok now I have committed the changes.
Thanks for reporting :)
Viewing all 228 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>