I'm trying to replace all dependencies in Office (interop) libraries. As OpenXML does not allow the conversion of Winword documents to PDF, I decided to try DocIO ...
Using your example in full, for converting a winword document to PDF, an exception occurs stating that the ConvertToPdf method does not exist.
In the initial 'Notes', we are informed that this functionality does not work with UWP, WinRT, ... do the exceptions apply also to Windows 10?
All the assemblies required are referenced, as reported in "assemblies required".
I am using Visual Studio 2017 Community on Windows 10.
Thanks in advance.
English is not my native language, as you may have noticed ... anyway, I'll try to explain how I solved the problem:
Using your example, I got the same error in the converter's ConvertToPDF statement (ConvertToPDF method not found). I removed the references involved and added them again. I ran the sample project that you kindly sent me and 'presto', the pdf was generated! Then I tried the same in my project and everything went well. I could not figure out what happened, but it was solved ...
Now I'm trying to figure out how to save the generated pdf in A5 format, but that's another 'battle.'
Thank you very much for your help.
// Loads an existing Word document.
WordDocument wordDocument = new WordDocument("Template.docx");
// Sets page size as A5 for each sections.
foreach (IWSection iWSection in wordDocument.Sections)
iWSection.PageSetup.PageSize = PageSize.A5;
DocToPDFConverter converter = new DocToPDFConverter();
// Convert word document into PDF document.
PdfDocument pdfDoc = converter.ConvertToPDF(wordDocument);
// Save the pdf file.
Thanks for your reply.
The document content is shrunken to A5, but the page size remains as A4...
"PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
pdfDocument.PageSettings.Size = PdfPageSize.A5;"
but nothing changed.
PDF without PageSize
PDF with PageSize.A5
| || |
| || |
Sorry for my bad English. When I ask"how do I convert a document in A5", what I really wanted to ask was: "how do I convert a document in A5 page size and set up the printer to print on A5 paper size".
You do not need to answer; You've already been more than helpfull!
Thank you so much for everything.