0

I should create a PDF file from a Word document in C#. I'm using DocumentFormat.OpenXml for creating or reading a document like

// create a new docx
using (var document = WordprocessingDocument.Create(
            "test.docx", WordprocessingDocumentType.Document))
{
    document.AddMainDocumentPart();
    document.MainDocumentPart.Document = new Document(
                new Body(new Paragraph(new Run(new Text("some text")))));
}

In this document I must add an image and then create a PDF. I can't find a way to create it. Do you have any advice? Thanks

Enrico
  • 3,592
  • 6
  • 45
  • 102
  • 2
    *PDF* has nothing to do with Word, docx or the Open Office XML format. Essentially you are asking "How can I create a PDF file in C#"? Search for a library that creates PDF documents, eg iText. There are a lot of similar questions. – Panagiotis Kanavos Mar 08 '18 at 10:55
  • MigraDoc and PdfSharp are also pretty good for making PDFs –  Mar 08 '18 at 10:58
  • Possible duplicate of [How do I convert Word files to PDF programmatically?](https://stackoverflow.com/questions/607669/how-do-i-convert-word-files-to-pdf-programmatically) – mjwills Mar 08 '18 at 11:39

0 Answers0