none
How to save Word as PDF using Open XML SDK 2.0 RRS feed

  • Question

  • How do we use Open XML SDK 2.0 to save word files as a PDF? 


    Thomas Abruzzo thomas@tampsystems.com
    Wednesday, April 13, 2011 1:38 PM

All replies

  • Hi Thomas,

    Open XML is not a erplacement of Object model hence it doesnt contain any method to save the file as pdf. The main use of it to read and write into the document.

    Yuo can use Word automation Services (part of SharePoint 2010) in order to convert a Word document into pdf.

    Thanks
    Ankush,
    ankushbhatia.wordpress.com

     

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Ankush Microsoft Online Community Support
    Wednesday, April 13, 2011 2:31 PM
  • Our clients require that we can product word files and pdf files.  Is there any other work around?

     

    Word automation services will require MS office to be installed on the server.  Also, is using word automation services thread safe?  We have numerous users generating word documents. 

     

    We invested so much time into developing and understanding Open XML and now to find out that it can’t produce a pdf file, we are very disappointment.


    Thomas Abruzzo thomas@tampsystems.com
    Wednesday, April 13, 2011 2:39 PM
  • Word automation Service doesnt require Office to be installed but they need SharePoint 2010.

    Have a look at this one for more information : http://msdn.microsoft.com/en-us/library/ee558830.aspx

    Thanks,
    Ankush


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Ankush Microsoft Online Community Support
    Wednesday, April 13, 2011 2:42 PM
  • This sounds worse, so I have to have SharePoint 2010 installed and configured?

     

    I think some of our servers are on windows 2003 r2 - 32bit, will sharepoint even install on this os?

     

    My boss is going to be pissed.


    Thomas Abruzzo thomas@tampsystems.com
    Wednesday, April 13, 2011 2:59 PM
  • Do we have to install SharePoint 2010 on the server in order to use the Word Automation Service?
    Thomas Abruzzo thomas@tampsystems.com
    Wednesday, April 13, 2011 5:59 PM
  • Hi Thomas,

    I think it need to install SharePoint 2010 on the server in order to use Word automation service.

    Please take a look at these articles:

    http://www.zimmergren.net/archive/2010/08/30/sp-2010-developing-with-the-word-automation-services-in-sharepoint-server-2010.aspx

    http://blog.petergerritsen.nl/2010/01/13/codeplex-project-for-word-automation-services/

    They all use SharePoint product.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Bruce Song Friday, April 29, 2011 5:55 AM
    Monday, April 18, 2011 9:05 AM
  •  

    Hi Thomas,

    Have you figured out your problem yet and does the suggestion help you? If you still have any concern on the thread, feel free to follow up. 

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 25, 2011 3:37 AM
  • Have a look up at Spire.Doc, It can save Word(Doc, Docx) to PDF WITHOUT OLE AUTOMATION.

    using System;
    using Spire.Doc;
    using Spire.Doc.Documents;

    namespace WordToPDF
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Create a new document
                Document document = new Document();
                //Load word 2007 file from disk.
                document.LoadFromFile("WordFile.docx");

                //Save doc file to pdf.
                document.SaveToFile("Sample.pdf", FileFormat.PDF);

            }
        }
    }

    • Proposed as answer by AlanLira Tuesday, January 28, 2014 1:40 PM
    • Unproposed as answer by AlanLira Tuesday, January 28, 2014 1:40 PM
    Friday, July 1, 2011 6:29 AM
  • The SDK doesn't save to PDF. You'll have to get a commercial component that can write to PDF (what I would recommend in your case), or  automate Word, or get SharePoint 2010.
    ClosedXML - Create Excel files in .Net
    Thursday, July 7, 2011 7:08 PM
  • Docx4J can convert to PDF and HTML without Word Automation.  It has a friendly Apache Licence as well.

    http://www.docx4java.org/trac/docx4j

    The sample-docs folder in the downloaded package contains a number of complex docx files. i.e embedded images, tables, shading, idents etc...

    If you need to call it from .NET run it as a command line application or for heavy utilisation wrap the call in a web service around it and host it in web server such as Tomcat

    Tuesday, October 16, 2012 3:56 PM
  • Hi, I would suggest you to try some other approach, for example with this alternative to Word Automation in C#. It is much simpler to use its content model then to manipulate with XML through OpenXML SDK and it can enable you to generate your users Word document or to create a PDF document in .NET:

    // Create new document.
    var doc = new DocumentModel();
    
    // Add content.
    doc.Sections.Add(
        new Section(doc,
            new Paragraph(doc, "Sample text.")));
    
    // Save as PDF file.
    doc.Save("Sample.pdf");

    Also converting an existing documents to a PDF is a straightforward task:

    DocumentModel.Load("Sample.docx").Save("Sample.pdf");

    Wednesday, April 9, 2014 9:24 AM