I'm trying to convert DOCX to PDF with "Microsoft Print to PDF" in C#. Some objects of my document are drawings and i can't "Save As" without destructuration.
With a printing "Microsoft Print to PDF", all is fine so I want to do this action with my C# program. I've 3000 files to process.
I'm trying this code. It executes a PDF printing and create the wrong file but, it's only blank pages.
//path is my docx path
Application appWord = new Application();
wordDocument = appWord.Documents.Open(path);
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = pdf_path;
pd.Print();
I'm thinking I miss something by I don't understand what.
And I don't know if the wordDocument
can be the streamReader
in some examples on Internet.
Thanks for your help !
PrintDocument
. You opened Word itself withappWord
but then try to print in your application without sending any content to the printer. If you opened Word intentionally you can also print from it, with Document.Printout – Panagiotis Kanavos