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.
Unfortunately, activation email could not send to your email. Please try again.

Converting WordDocument to PDF.

Thread ID:

Created:

Updated:

Platform:

Replies:

131331 Jul 5,2017 06:50 AM Jul 13,2017 11:40 PM Windows Forms 7
loading
Tags: DocIO
Fausto
Asked On July 5, 2017 06:50 AM

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.


Sethumanikkam Yogendran [Syncfusion]
Replied On July 6, 2017 02:54 AM

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


Fausto
Replied On July 7, 2017 12:43 PM

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.


Sethumanikkam Yogendran [Syncfusion]
Replied On July 10, 2017 05:35 AM

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


Fausto
Replied On July 10, 2017 03:02 PM

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.


Sethumanikkam Yogendran [Syncfusion]
Replied On July 12, 2017 04:43 AM

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


Fausto
Replied On July 13, 2017 03:17 PM

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



Sethumanikkam Yogendran [Syncfusion]
Replied On July 13, 2017 11:40 PM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;