1

So this code down here works fine, it does the job, word -> PDF.

Only got a problem, when the word doc has tables with united cells, when converting the word doc to pdf the pdf show the united cells combine but with no value inside.

Someone knows why? Is the any solution for this?

NOTE: This is converting on server side.

  if (nomeDocTemplate == attachment)
                                {
                                    web.AllowUnsafeUpdates = true;
                                    string wordEdit =item2.Attachments.UrlPrefix + "Template" + item.ID + ".docx";
                                    string wordAutomationServiceName = "Word Automation Services";
                                    string filenamedest = web.Url + item.File.ServerRelativeUrl;
                                    SPFile attachmentFile = item2.Web.GetFile(wordEdit);

                                    using (MemoryStream destinationStream = new MemoryStream())
                                    {

                                        //Call the syncConverter class, passing in the name of the Word Automation Service for your Farm.                             

                                        SyncConverter sc = new SyncConverter(wordAutomationServiceName);

                                        ////Pass in your User Token or credentials under which this conversion job is executed.
                                        sc.UserToken = SPContext.Current.Site.UserToken;
                                        sc.Settings.UpdateFields = true;
                                        //Save format
                                        sc.Settings.OutputFormat = SaveFormat.PDF;


                                        ////Convert to PDF by opening the file stream, and then converting to the destination memory stream.
                                        ConversionItemInfo info = sc.Convert(attachmentFile.OpenBinaryStream(), destinationStream);

                                        var filename = Path.GetFileNameWithoutExtension(item.File.Name) + ".pdf";

                                        if (info.Succeeded)
                                        {
                                            //File conversion successful, then add the memory stream to the SharePoint list.
                                            SPFile newfile = web.Lists["Tramitar"].RootFolder.Files.Add(filename, destinationStream, true);

                                        }
                                        else if (info.Failed)
                                        {
                                            throw new Exception(info.ErrorMessage);
                                        }



                                    }

                                    //ConcatAndAddContent(anexosProcesso);

                                    return;
                                }

Here is the doc and the pdf, to understand better the problem I'm having:

WORD: enter image description here

PDF: enter image description here

Tiago dias
  • 133
  • 13

0 Answers0