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

Word document convert to Pdf missing comments

Hi Syncfusion team,


Trying to convert the docx to pdf but the comments is missing. Please assist.

Attached sample docx and code below.

Code:

using (MemoryStream memWord = new MemoryStream(fileBytes))

                    {

                        var wordDocument = new WordDocument(memWord, Syncfusion.DocIO.FormatType.Automatic);

                        // Creates a new instance of DocIORenderer class.

                        DocIORenderer render = new DocIORenderer();

                        // Converts Word document into PDF document.

                        PdfDocument pdf = render.ConvertToPDF(wordDocument);

                        // Save the PDF document.

                        pdf.Save(stream);

                        using (FileStream file = new FileStream(Path.Combine(Path.GetTempPath(), "test.pdf"), FileMode.Create, FileAccess.Write))

                            stream.WriteTo(file);


                        render.Dispose();

                        pdf.Close();

                    }


Regards


Attachment: Lorem_9f7794b7.zip

1 Reply

AA Akash Arul Syncfusion Team March 8, 2023 09:49 AM UTC

Hi Jinchuan,

On further analyzing the given details, we found that your requirement is to preserve the comment in the converted PDF. To preserve the comment in converted PDF, please set the CommentDisplayMode API as ShowInBalloons and then convert the Word document to PDF. So that the comments will be preserved.

Code Snippet:

WordDocument wordDocument = new WordDocument(fileStream,FormatType.Docx)

//Sets ShowInBalloons to render a document comments in converted PDF document.

wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;

Please refer to the below UG documentation to know how to preserve comments in a generated PDF
https://help.syncfusion.com/file-formats/docio/word-to-pdf?cs-save-lang=1&cs-lang=csharp#comments-in-word-to-pdf-conversion

If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.

Regards,
Akash.


Loader.
Up arrow icon