We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Converting WordDocument to PDF.

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.


7 Replies

SY Sethumanikkam Yogendran Syncfusion Team July 6, 2017 06:54 AM UTC

Hi Fausto,

Thank you for contacting Syncfusion support.

We are unable to reproduce the mentioned issue with the given details. Please find the below sample which we have tried at our end to reproduce the issue.
Sample link

If you’re still facing the same issue means, then kindly provide us sample or modified sample of above along with input template, and product version of Essential Studio which will helpful to reproduce the issue at our end and to provide you the appropriate solution at the earliest.

Please refer the following links to know more about Word to PDF conversion.
Converting Word document to PDF
Unsupported elements and Limitations in Word to PDF conversion

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



FA Fausto July 7, 2017 04:43 PM UTC

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.



SY Sethumanikkam Yogendran Syncfusion Team July 10, 2017 09:35 AM UTC

Hi Fausto,

Thank you for your update.

We are glad to know that your issue has been resolved and mentioned issue might occurred due to referenced assemblies missed/not added properly at your end.

How to save the generated pdf in A5 format:
To meet your requirement, you can set the page size from page setup for each section in the Word document as A5 before converting it into PDF. Please refer the below code snippets, and let us know if this helps you.
 
// 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.
pdfDoc.Save("DoctoPDF.pdf");
 

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



FA Fausto July 10, 2017 07:02 PM UTC

Thanks for your reply.

The document content is shrunken to A5, but the page size remains as A4...

I Tried:

"PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);

pdfDocument.PageSettings.Size = PdfPageSize.A5;"

but nothing changed.



SY Sethumanikkam Yogendran Syncfusion Team July 12, 2017 08:43 AM UTC

Hi Fausto,

Thank you for your update.

We are unable to reproduce the mentioned issue with the given details. Please find the below sample which we have tried at our end to reproduce the issue.

Sample link
Note: You can find the resultant PDF files in “Output” folder inside the sample application.

Please refer the below screenshot for the resultant PDF files with and without PageSize modification in Word to PDF conversion.
 
PDF without PageSize 
PDF with PageSize.A5 
 
 
 
 

If you’re still facing the same issue means, then kindly provide us sample or modified sample of above along with input template, and product version of Essential Studio which will helpful to reproduce the issue at our end and to provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



FA Fausto July 13, 2017 07:17 PM UTC

Hi Sethumanikkam.

Thanks again. 

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.

Regards, 

Fausto Luís




SY Sethumanikkam Yogendran Syncfusion Team July 14, 2017 03:40 AM UTC

Hi Fausto,

Thank you for your update.

We are glad to know that your issue has been fixed.

Please let us know if you need any further assistance. We are happy to assist you as always.

Regards,
Sethumanikkam.Y


Loader.
Up arrow icon