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

New Post: Table bgcolor is not working.

$
0
0
When I am creating a table with setting a back ground color for it and creating the openxml corresponding its html, background color disappears.
Can you please help me on fixing it.
I am using htmltoopenxml 1.4 version.

New Post: Table bgcolor is not working.

$
0
0
Upgrade to v1.5. It has been fixed in changeset #83083 (Mar 26, 2013) or recompile yourself from latest source-code

New Post: Table bgcolor is not working.

$
0
0
Does v1.5 supports Dot net frame work 3.5? We are using this solution in an existing solution which is using Dot net frame work 3.5 .

New Post: Rowspan is not working as expected

$
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: Table bgcolor is not working.

$
0
0
so download the latest source code and build yourself.
Only v1.5 stick with .Net 3.5, the source code still targets .Net 3.0

New Post: Style not used to convert

$
0
0
I put <span style="font-family: Arial; font-size: 8px"> (using ver 1.5)

This did not work at all. I can use <font family="Arial" size="12pt"> but only Arial is applied, not the 12pt size.

New Post: converter parse img returns nothing

$
0
0
Hi drabiu,

I have just committed a fix for local file.
Thanks to daviderapicavoli which has submitted the patch

Hope that fix your bug

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

$
0
0
Hi,
Thanks for the wonderful HtmlConverter code. I'm using the version 1.5 in my application to convert html content to open xml and download a document out of it.

Below is the code that I have,
using (var stream = new MemoryStream())
            {
                // Create a Wordprocessing document.
                using (WordprocessingDocument myDoc = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document, true))
                {
                    // Add a new main document part. 
                    // Create DOM tree for simple document. 
                    MainDocumentPart mainPart = myDoc.MainDocumentPart;
                    if (mainPart == null)
                    {
                        mainPart = myDoc.AddMainDocumentPart();
                        new Document(new Body()).Save(mainPart);
                    }

                    HtmlConverter converter = new HtmlConverter(mainPart);
                    Body body = mainPart.Document.Body;

                    // Append elements appropriately after converting the html to openxml format. 
                    var paragraphs = converter.Parse(htmlContent);
                    for (int i = 0; i < paragraphs.Count; i++)
                    {
                        body.Append(paragraphs[i]);
                    }

                    // Save changes to the main document part. 
                    mainPart.Document.Save();

                    myDoc.Close();
                }

                stream.Position = 0;
                stream.CopyTo(Response.OutputStream);
                Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + docName + ".docx");
                Response.Flush();
                Response.End();
            }
Here, htmlContent that I pass into the parse method looks like below
<h1 style=\"text-align:left;\">This is heading 1</h1>
<h2 style=\"text-align:left;\">This is heading 2</h2>
<h3>This is heading 3</h3>
<p><span style=\"font-family:Georgia,serif;\">This text is in Georgia&nbsp;font</span></p>
<p><span style=\"font-family:Arial,Helvetica,sans-serif;\">This text is in Arial font</span></p>
<p><span style=\"font-family:'Times New Roman',Times,serif;\">This text is in Times New Roman font</span></p>
But none of the above heading levels or the font name changed texts are getting displayed in the downloaded Open XML document.

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

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

$
0
0
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 :)

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

$
0
0
Thank you very much for the updated source code. Now I'm able to see the heading styles and different font-name texts properly in my generated document.

Also, it would be great if you wouldn't mind to provide some pointers on the below two minor issues,
  1. Why is that all the heading level texts are getting displayed in Bold font by default. Could this be changed to normal headings?
  2. When text-align property is set to the heading tag through inline-style, I'm not able to see them in the document. I also tried to add the below highlighted code to the ProcessHeading method, but still it is not getting properly aligned.
    Image

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

$
0
0
Hi Baala,


For the headings in Bold, this is like that in the default theme of Word 2010. If you want to customize your headings, I can only propose you to open Word, set the theme as you need and then save your document.
Embed that document inside a resx and use it inside your code:
using (MemoryStream generatedDocument = new MemoryStream())
{
     byte[] data = Demo.Properties.Resources.template;
     generatedDocument.Write(data, 0, data.Length);
     generatedDocument.Position = 0L;
     using (WordprocessingDocument package = WordprocessingDocument.Open(generatedDocument, true))
     {
          ....
     }
}
For the inline style, at the time being, no style are supported. I will commit this feature soon but I need to finish other step.
But you can already now support text-align by adding this code in ProcessHeading:
List<OpenXmlElement> styleAttributes = new List<OpenXmlElement>();
htmlStyles.Paragraph.ProcessCommonAttributes(en, styleAttributes);

AlternateProcessHtmlChunks(en, "</h" + level + ">");
Paragraph p = new Paragraph(elements);
p.InsertInProperties(prop =>
                prop.ParagraphStyleId = new ParagraphStyleId() { Val = htmlStyles.GetStyle(clsName, StyleValues.Paragraph) });

htmlStyles.Paragraph.ApplyTags(p);
htmlStyles.Paragraph.EndTag("<h" + level + ">");

New Post: WebClient in ImageDownloader/ImageProvisioningProvider doesn't get disposed

$
0
0
Hi, I just stumbled over a non-disposed WebClient while profiling my application.

In ImageProvisioningProvider/ImageDownloader (your class names don't match your file names ;) ) there's this starting in line 99:
System.Net.WebClient webClient = new System.Net.WebClient();
if (proxy != null)
{
    if (proxy.Credentials != null)
        webClient.Credentials = proxy.Credentials;
    if (proxy.Proxy != null)
        webClient.Proxy = proxy.Proxy;
}

try
{
    imageInfo.RawData = webClient.DownloadData(imageUrl);

    // For requested url with no filename, we need to read the media mime type if provided
    imageInfo.Type = InspectMimeType(webClient);
}
catch (System.Net.WebException)
{
}
The first line should be:
using (var webClient = new WebClient())
Also seeing that empty catch block, it occurs to me that it'd be nice to have the possibility to inject a logger.

Thanks for your work on this nifty library! :)

New Post: ul and ol tag

$
0
0
hi there,

I downloaded the version 1.4.2 and I still have issues with ol-tags. In Word 2010, the numeration isn't restarted after each block and if I use the same numeration type on different levels, the html converter didn't recognize the difference.

Example 1:
<ol><li>1</li><li>2<ol><li>3</li></ol></li><li>4<ol><li>5<ol><li>6</li><li>7</li></ol></li></ol></li></ol> Example 2:
<ol><li>Asd</li><li>Asd</li><li>Asd<ol style="list-style-type:lower-alpha"><li>Asd</li><li>Asd</li><li>Asd<ol style="list-style-type:lower-roman"> <li>As</li><li>Dasd</li><li>Asd</li><li>oiiuiuiu</li> </ol></li></ol></li><li>Asd</li><li>Ads</li><li>asdsad</li></ol> The conversion result is: RESULT.

Thanks in advance for your help.

Best regards.

New Post: WebClient in ImageDownloader/ImageProvisioningProvider doesn't get disposed

$
0
0
Hello,

I'm ashamed for the name of the class :)
But for the Dispose() of WebClient, I'm not agree with you:

WebClient inherits from Component and need a Dispose() if you attach it via the designer into a Windows Form for example.
But WebClient didn't override Dispose(bool disposed) and thus, no resources will be claimed.

About the empty catch, I already think about a logger. But I think people would want a more verbose logging (about the tag processed, style applied, ...) and the hard and long work it will generate to me.
So I drop the idea but after your post, yes I should implement one. I will read again the MSDN about TraceSource & TraceSwitch ....

New Post: Image not inserted in resulted docx document.

$
0
0
Hi all,
I have a problem regarding images in resulted docx by converting from html.

As i saw, when converting " var paragraphs = converter.Parse(htmlText); ", paragraphs.count = 0.
So, that converter does not even see my paragraphs with image/images.. It sees my html empty.
MemoryStream generatedDocument = new MemoryStream();

            using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document))
            {
                MainDocumentPart mainPart = package.MainDocumentPart;
                if (mainPart == null)
                {
                    mainPart = package.AddMainDocumentPart();
                    new DocumentFormat.OpenXml.Wordprocessing.Document(new Body()).Save(mainPart);
                }

                HtmlConverter converter = new HtmlConverter(mainPart);
                Body body = mainPart.Document.Body;

                var paragraphs = converter.Parse(htmlText);
                for (int i = 0; i < paragraphs.Count; i++)
                {
                    body.Append(paragraphs[i]);
                }

                mainPart.Document.Save();

                return generatedDocument;
            }
I notice that i use version 1.5 HtmlToOpenXml.
How can i show you my htmlText because i cannot paste it here, characters limited.

Obs1: it really doesn't matter what image extension i use (png,jpeg.. etc)
Obs2: checked that htmlBody in IE/Chrome and it works great.

New Post: ul and ol tag

$
0
0
Hi rfeitor,


Yes I'm aware of that bug. It's just not as easy to fix as it sounds.
The lack of good document on OpenXml stuck me :-(

New Post: Image not inserted in resulted docx document.

$
0
0
Hi Erik,


This is a recurring error that occurs with image.
Do you check the documentation? You are probably behind a proxy and thus you need to provide your credentials.

Do not hesitate to come back if the documentation doesn't help you.


Olivier

New Post: Image not inserted in resulted docx document.

$
0
0
Hi Oliver,
Yes i do read the documentation and also i do read the others's image problem. I downloaded yesterday the latest dll and still does not work. However, i found only one image that is rendering ok, but the rest don't. This makes me think is not a problem with a proxy or smthing else. In my html i have the bytes (inline base 64) of the image/images , so there is nothing to do with uploading from computer.
In order to prove this give me an email or smthing else to send you the html....

Erik

New Post: ul and ol tag

$
0
0
Thanks anyway, hope you find a solution. :)

New Post: WebClient in ImageDownloader/ImageProvisioningProvider doesn't get disposed

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Viewing all 228 articles
Browse latest View live


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