Webpart OpenXML docx chunk HTML BOM

I am inserting html text into a docx word document. All works okay except the end result docx file has a BOM at the beginning of the document.xml. I do not understand this although I suspect an encoding issue. Example code below. Would appreciate anyone's
thoughts on this.
        void AddAltChunkHTML(MainDocumentPart mainPart, Word.SdtElement sdt, SPFile filename)
            string altChunkId = "AltChunkId" + id;
            id++;
            // read insert data
            byte[] byteArray = filename.OpenBinary();
            AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Xhtml, altChunkId);
            // load the insert data into the chunk
            using (MemoryStream mem = new MemoryStream())
                mem.Write(byteArray, 0, (int)byteArray.Length);
                mem.Seek(0, SeekOrigin.Begin);
                chunk.FeedData(mem);
            Word.AltChunk altChunk = new Word.AltChunk();
            altChunk.Id = altChunkId;
            //Replace content control with altChunk information
            OpenXmlElement parent = sdt.Parent;
            parent.InsertAfter(altChunk, sdt);
            sdt.Remove();

Hello Coolsweety,
Maybe this technet article is useful, at the end I see how they specify the width property:
http://msdn.microsoft.com/en-us/library/office/cc850841(v=office.15).aspx
- Dennis | Netherlands | Blog |
Twitter

Similar Messages

  • Reg:Convert DOCX to HTML

    Hi,
    I want to convert a microsoft word document(docx) to html using code. Can anyone help me in this context ... The doc which I am trying to convert will have Bullets,bold,italic,Images etc ...
    I am able to get the text but not the images and bullets ..
    And also I need to convert the Whole Document whichj includes pictures,images,......etc.. to HTML as I need to embed that HTML while sending an EMAIL.
    Please help me in this context
    Thanks

    Hi Vijay,
    Thanks for the info.
    I am using DOCX4J to convert the DOCX to HTML .I have successfully done the conversion and got the html format.I will be using the html format to embed it as EMAIL body to send an email.But I have some issues which are listed below....
    Unable to display Images in EMAIL Body
    Losing the Spaces and Bullets
    Please find the code I used below,
    WordprocessingMLPackage wordMLPackage;
    wordMLPackage = Docx4J.load(new java.io.File(resourcePath2));
    HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
    htmlSettings.setImageDirPath(imageFolder + resourcePath2 + "_files");
    htmlSettings.setImageTargetUri(imageFolder +resourcePath2.substring(resourcePath2.lastIndexOf("/")+1) + "_files");
    htmlSettings.setWmlPackage(wordMLPackage);
    OutputStream os;
    os = new ByteArrayOutputStream();
    Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
    Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_SAVE_FLAT_XML);
    DOCX = ((ByteArrayOutputStream)os).toString();
    Please help me in this as this is very urgent.
    Thanks..

  • Using .docx-to-.html dashboard widget converter

    I've downloaded docx-converter.wdgt from the apple site in order to be able to read .docx files created by windows office 2007 and sent to me as attachments. The widget has installed fine on the dashboard. However, it seems that to use the widget, I need to drag the file onto the widget icon in the dashboard, and the dashboard fades when I click on the desktop to grab & drag the file icon. I've tried dragging the icon directly onto the dashboard icon with no luck.
    Thanks in advance for any advice.

    I've got the same problem. I found the PF12 method in the "how-to" on the converter's web page. However, when I push PF12 on my Mac, the "eject" symbol appeared, not the dashboard. Dashboard preferences are set to PF12 being dashboard. No helper keys helped. So, I set the Dashboard preferences temporarily to use the middle mouse button for Dashboard and then was able to get the file to drag to the widget. The conversion didn't work, however. I think that the .docx file I was sent isn't any good. Thanks Microsoft.
    JanG

  • How to Convert Doc or Docx File to HTML?

    Is there any API in java is avilbale to convert doc/docx into HTML?

    Mr Babakishiyev wrote:
    Not in the JDK.
    But you can use POI for working excel and doc filesBut not to fulfill the requirement.
    The only thing I can think of if you must use Java (which tends to not be the best choice when having to work with Microsoft file formats) is to see if the OpenOffice API can do what you need. But then get ready for some reading.

  • Converion of Doc,Docx,pdf,odt to Html

    Hi,
    I have a requirement like conversion of  Doc,Docx,pdf,odt to Html  without any lose of format ,then storing html content into database.
    can any one suggest is there any open source tool for achieving this.
    it is very urgent please reply as soon as possible.

    Hi
    Rajesh,
    #Convert Docx to HTML: 
    Using  PowerTools for Open XML just released a new HtmlConverter module that contains an open source.
    For more details, please refer to the following link.
    http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2014/01/30/transform-docx-to-html-css-with-high-fidelity-using-powertools-for-open-xml.aspx
    #Convert Pdf to HTML: 
    c# converting pdf to html [closed]
    #Convert Odt to HTML: 
    Convert ODT to HTML Command Line
    By the way, If you need to be able to perform operations like find and copy/pasting text. I would suggest converting the document to a .pdf, and displaying it inline, in whichever standard pdf viewer the client machine has installed.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Missing "Project Fields" webpart mystery

    This has to be the oddest thing I've ever encountered in years of Sharepoint administration, though I have less experience with Project Server administration.  Here goes.
    We've upgraded from Project Server 2010 to Project Server 2013 and have started UAT.  Other than an issue with the BI Center upgrade which was resolved, the upgrade test reported no errors.  The problem is with our Project Detail Pages.
    Any project detail pages that were using the "Project Fields" webpart are giving an error after the upgrade.  In the logs I found:
    - "System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Project.Server.Library, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies"
    -  "Microsoft.Office.Project.PWA.WebParts.ProjectFieldPart, Error: File Not Found"
    So first it appears these pages were not upgraded to use the new PWA library.  I wasn't able to find a way to properly upgrade the pages.  So, I began rebuilding them.
    I built one new page in the Project Detail Pages library using the "Project Fields" webpart successfully.  When I went to build a second page, the webpart is completely gone (the "Project Fields (Backwards Compatible)" webpart remains
    but it is not the same):
    Back in Project Server 2010, here's the webpart:
    Thinking this is an issue with the upgraded PWA, I went to our other test 2013 PWA (that is native 2013 with no content and wasn't an upgrade from 2010), and the webpart is missing there too!
    Then, I rebooted the farm because I was at a loss.  The webpart is still missing.  I was able to use it an hour ago, and the page I built with it still displays it, but I can't add it to any new pages (and tried Export and Upload with no success),
    and I'm stumped.  Has anyone experienced anything like this before?  Thank you for your insight.

    Find the web part referenced in the database and delete the reference. 
    http://troubleshooterms.blogspot.com/2010/01/deleting-webpart-from-page-using.html
    cheers!
    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

  • How to open a index.html page from document library rather than download

    Hi,
    I have uploaded a website template folder structure to Office 365. Like this 
     When i click index.html the file gets downloaded to my pc. What i am trying to do is:
    Open the index.html file in new tab so that i can show demo for my site template?

    Hi NirajZ,
    You can't view the html file that uploaded in the SharePoint document library or List as attachment.
    If you wanted to see the html file in the SharePoint, Create the Content Editor WebPart and copy the html url in the link.(Edit the Content Editor WebPart and Check the Properties)
    Murugesa Pandian | MCPD | MCTS | SharePoint 2010

  • Problems with document attachments

    I generally look at email as web mail. When senders send me Word documents they often don't show up as separate attachments. A strange detail is that the total size of the message, e.g., 120 KB, shows that the document is there somewhere, but is not visible.
    By contrast, .rtf files always work: they show up clearly.
    I would appreciate any thoughts, thank you in advance.

    Hi Karri,
    Believe what you are looking  at is a direct translation of Open XML Documents (.DOCX) to HTML, enabling access to the information in the Open XML format from any platform with a Web browser i.e, Document viewer in this case.A plug-in for Firefox, IE7 and IE8 is available  that allows users to view Open XML documents (.DOCX) within the browser on Windows and Linux platforms.
    Trust the below link will aid you resolve this:
    http://blogs.msdn.com/interoperability/archive/2009/05/17/openxml-document-viewer-v1-released-viewing-docx-files-as-html.aspx
    Regards,
    Pradeepkumar Haragoldavar

  • XML attachment in Document Viewer

    Hi,
    I am having problems with XML attachments with Document Viewer. I already posted a thread in the general application server forum, but thought that there might be interested people in this forum also.
    Document Viewer and XML Stylesheet
    Sorry for the possible inconvenience of the double post.
    Regards,
    Karri

    Hi Karri,
    Believe what you are looking  at is a direct translation of Open XML Documents (.DOCX) to HTML, enabling access to the information in the Open XML format from any platform with a Web browser i.e, Document viewer in this case.A plug-in for Firefox, IE7 and IE8 is available  that allows users to view Open XML documents (.DOCX) within the browser on Windows and Linux platforms.
    Trust the below link will aid you resolve this:
    http://blogs.msdn.com/interoperability/archive/2009/05/17/openxml-document-viewer-v1-released-viewing-docx-files-as-html.aspx
    Regards,
    Pradeepkumar Haragoldavar

  • How to obtain date of creation if image is obtained using getImage()

    When Image is obtained using getImage() method , how to
    obtain date of creation or another header value if image is
    obtained using getImage method.

    Actually, some formats do indeed have creation or modification dates built in. e.g. http://www.w3.org/TR/PNG-Chunks.html#C.tIME. (Of course since most programs save a new copy of the file every time, the two dates are the same.) However, just because formats have this data doesn't mean it's reliable or even present. Your best bet is to pass creation dates in an Applet param tag for applets (assuming you were referring to Applet.getImage()) or to parse out a filename from a classloader URL and use a File object to check (assuming you were instead referring to Toolkit.getImage(URL)). That's the best answer I have without knowing more about what you are trying to accomplish.

  • How do I convert a document created in pages into a pdf document?

    I created a document in pages of my macbookpro, and now I need to convert into a pdf or doc,docx,htm,html,odt,pdf,rtf,tif,tiff,txt > Help will be apreciated.

    You can also Export as PDF or Word. Gives you a few PDF/Word conversion options as well:
    http://support.apple.com/kb/HT3705

  • I have an index page that does not correctly load css, but css works on all other pages in the site.

    http://www.boulderridgecondos.com/ does not load the css correctly, but ALL other pages in the site do load the css correctly. There is nothing different (that I can identify) between the pages.
    http://www.boulderridgecondos.com/news.htm
    I am guessing that there is something wrong in the css, I inherited this site and have gone over the css but can't find a issue that would cause this to occur.
    Any help or suggestions to research something would be appreciated.

    That page is saved as UTF-16 (Content-Type: text/html (BOM UTF-16, litte-endian)) in your text editor. The CSS file is send as ISO-8859-1. Firefox likes to see all files in the same encoding. The other pages are send as ISO-8859-1 and thus use that CSS file. You will have to re-save that page as ISO-8859-1 and upload that corrected version.

  • Trying to display a PNG or JPEG on dashboard in Project server 2010 BI

    I am trying to display a PNG or JPEG in project server 2010 BI in a webpart page.  I have tried just using a pdf, etc.  I cannot get it to work; it says the it cannot find the URL.  I created a new page in another sharepoint site i have,
    put a media webpart on it, put a url in it and it finds it fine.  However, when I put this page in a dashboard it says it cannot find it?  How do I do this?  What is a simple easy way to just put a picture on a dashboard in BI. 
    Cletus51

    Have you tried using an Image Viewer Webpart (or) a Content Editor Web part?
    If you use a content editor webpart, Click on Edit HTML Source, and you can use the HTML below:
    <img src="<url>" alt="Smiley face" width="42" height="42">
    Prasanna Adavi,PMP,MCTS,MCITP,MCT http://thinkepm.blogspot.com

  • WebLogic returns funny characters in XML

    Hi,
    I have an application developed on Tomcat that includes a servlet that receives and XML post, processes the XML, then constructs an XML response packet (using JDOM) and flushes the response packet back to the calling process. This worked great under Tomcat, however now that I have ported it to WebLogic 6.1sp3, WebLogic appears to be adding some funny characters at the beginning and end of the XML response packet. Here's what it looks like.
    00ae
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE scansresponse SYSTEM "scansresponse.dtd">
    <scansresponse>
    <transferresult>failure</transferresult>
    </scansresponse>
    0000
    Any ideas on what might be causing this and how I can correct this problem? I've tried many different things and am stumped.
    Thanks,
    Chris

    Your funny characters are from http "chunking". See the following link for more info: http://ken.coar.org/slides/HTTP/Chunking.html .
    Each chunk is a hex number that indicates how big the chunk is. This can be a good thing! Processing the xml in chunks is faster than looping through it line by line.

  • Sharepoint 2013 : Css for Content in WP

    Hello,
    I Would like to change the colors of the text that is exist in  the Web Part.
    I use F12 But every Value has different Class .
    Is ther any class that is general for all content that is displayed in WP ?
    Thanks!
    Css for Content in WP

    Hi Nikita
    Please chek the below links
    http://anilspicyspace.blogspot.in/2013/04/modify-webpart-title-color-background.html
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/f48746c8-f01b-4a66-ae9c-1f523da58d6a/how-to-make-the-web-part-title-bold-and-increase-the-font-size-and-change-colour?forum=sharepointgeneralprevious
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/45223c5e-d75c-482c-9584-56bb133c6907/sharepoint-2013-coloring-the-web-part-title-background-and-changing-font-color?forum=sharepointdevelopment
    Please remember to click 'Mark as Answer' on the answer if it helps you

Maybe you are looking for

  • Acrobat Pro and Reader 9.4.4 to 9.4.5 Updates Fail

    I was unable to get a satisfying answer via phone support, and after connecting with a supervisor, I was disconnected. So here goes... (Mac OS X 10.6.8) Adobe Updater 6  began notifying me recently that updates were available for Adobe Reader from 9.

  • Re: Clustering & JNDI

    The JNDI documentation says that only Remote objects can be replicated.           Excerpts from WL jndi doc:           Note that you cannot reliably use the naming service to replicate objects.           For example, if you bind an RMI object "myRepl

  • Can't Launch Final Cut Pro

    HI. I deleted an old copy (unlicensed) and installed my newly purchased FinalCutExpress 4 (HD). I fille din the icense info, it finished installing... but I cannot launch it. LOg info is below. I tried reinstalling, repairing permissions, rebooting t

  • Uh I Think I Did Something Crazy

    Ok here's the scenario.  I saw two emails listed in the Hub from my designer and decided to read the first one.  I was then replying to her first message and it became sent prior to finishing my message composition.  So you know how it takes awhile t

  • Help! - New to Java3D

    Hi, I am new to java3D (also refreshing my basic java) and was trying to run the example code that I obtained from http://java.sun.com/products/java-media/3D/collateral/examples1_6.jar.zip As you can see it is a zipped jar file. When I tried to open