Search code examples
c#-4.0pdf-generationoffice-interopword-2010

Convert only 1st Word document page to PDF


I'm using Office 2010 interop and C# 4. How can I convert just the 1st page of a word document to PDF? This question ("How do I convert Word files to PDF programmatically?") helped me to get started but it only shows me how to save the whole document as PDF.

Is there a way:

  • to save just the 1st page as PDF? (most ideal option)
  • delete all remaining pages and then save as PDF?

How do I go about doing it?


Solution

  • Use the SaveasPdf option and save the entire document to Pdf. To get the first page you can use PDFSharp opensource library for processing PDF using C#.

    Here is an example to split pdf documents.