none
How to programmatically find out if a document can be saved as a pdf RRS feed

  • Question

  • I'm saving Word documents in PDF format in a C# application. I need to find out prior to saving whether the Word extensions that enable saving to PDF is installed. Trying to save to PDF whithout the extensions cause serious issues.


    Ockert
    Thursday, October 27, 2011 1:32 PM

Answers

  • Hello,

     

    You could make a separate method that does only SaveAsPDF, incapsulated in a try-catch. That way calling the method will generate in worse case scenario at most a message informing that the extension is not installed.

     

    PS: By extension, you ment the add-in that allows conversion to PDF, right?

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    Friday, October 28, 2011 5:05 AM
  • Hello,

     

    You could make a separate method that does only SaveAsPDF, incapsulated in a try-catch. That way calling the method will generate in worse case scenario at most a message informing that the extension is not installed.

    Thanks for Silviu for your suggestion;) Using try-cath statement would be a good approach to avoid application crashing.

    In addition, Ockert, would you like to tell me which Office version are you working with, which method are you using to convert office file to PDF?

    As far I know, Office 2010 has shipped with this feature, you can call this feature by using ExportAsFixedFormat method

    For Office 2007, you might need to install "Microsoft Save as PDF" add-in to enable this feature:

    http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=9943

     

    I hope this helps


    Best Regards, Calvin Gao [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.

    Friday, October 28, 2011 6:02 AM
    Moderator

All replies

  • Hello,

     

    You could make a separate method that does only SaveAsPDF, incapsulated in a try-catch. That way calling the method will generate in worse case scenario at most a message informing that the extension is not installed.

     

    PS: By extension, you ment the add-in that allows conversion to PDF, right?

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/
    Friday, October 28, 2011 5:05 AM
  • Hello,

     

    You could make a separate method that does only SaveAsPDF, incapsulated in a try-catch. That way calling the method will generate in worse case scenario at most a message informing that the extension is not installed.

    Thanks for Silviu for your suggestion;) Using try-cath statement would be a good approach to avoid application crashing.

    In addition, Ockert, would you like to tell me which Office version are you working with, which method are you using to convert office file to PDF?

    As far I know, Office 2010 has shipped with this feature, you can call this feature by using ExportAsFixedFormat method

    For Office 2007, you might need to install "Microsoft Save as PDF" add-in to enable this feature:

    http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=9943

     

    I hope this helps


    Best Regards, Calvin Gao [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.

    Friday, October 28, 2011 6:02 AM
    Moderator
  • I'm using Word 2010. I was under the impression that 2010 install the ability to save as a PDF by default but it does not. I'm using the Document.SaveAs method.

    I was hoping that I could avoid the generation of an exception by Word. 


    Ockert
    Friday, October 28, 2011 12:50 PM
  • Hello,

     

    Try using what Calvin suggested, ExportAsFixedFormat. This is a method that converts the document to a pdf/xps, it could be available in Office 2010 by default.

     

    As for the SaveAs, the method could trigger some undesired events. ExportAsFixedFormat is a cleaner approach.

     

    Best regards,

    Silviu.

     


    http://www.rosoftlab.net/
    • Edited by Lupu Silviu Friday, October 28, 2011 1:53 PM
    Friday, October 28, 2011 1:17 PM