Convert to pdf - table extends out of document

I have a requirement to convert Word documents to pdf and am evaluating Aspose.Words. However, the first document I have tried, tables extend off the right hand side of the document. This does not happen when opening the original document in Word.

I have attached the original and converted pdf documents.

If Aspose.Words cannot convert this properly then it’s a show stopper for us.

The code I am using is

Aspose.Words.Document convert = new Aspose.Words.Document(stream);
convert.Save(response, Path.GetFileNameWithoutExtension(document.AttachmentName) + “.pdf”, ContentDisposition.Attachment, null);
response.Flush();


Thanks,
Richard

Hi there,

Thanks for your inquiry.

Are you editing the table at all when the Document is loaded in Aspose.Words? It seems strange that this issue is occuring from a document template. It would be helpful if you attach the original template here so we can figure out why this is happening with the table.

Most likely to fix this you can either choose to fit the table to the page using the method described in this post here or you can rebuild the tables in the entire document using Document.UpdateTableLayout before rendering to PDF. Please note that the UpdateTableLayout method may change the layout of other tables in your document if there are any.

Thanks,

Thanks for the quick reply Adam.

I haven’t got the original template. I’m interfacing with a document storage component and only have access to the original document I attached.

UpdateTableLayout works to fix the layout as a workaround, but obviously any extra call adds a processing overhead, so I’d like to avoid that if possible. I don’t make any changes to the document, literally just load then save to pdf, so it shouldn’t really be necessary.

Thanks,
Richard

Hi Richard,

Thanks for the additional information.

In that case are you able to export the document that you recieve into the original format (if known) using Aspose.Words? i.e export it as .doc instead of .pdf. This will at least help to try reproduce the issue.

If speed is an issue than the code on the first link may help. The implementation should not have any impact on speed.

Please note the .XML file you attached is not a document but is a stack trace, just incase there was any confusion.

Thanks,

I've back on pdf conversion again now after a break. I've attached the document causing the problem and a test harness for it. I've tried with the latest version (9.5.0.0) and am still getting the same problem.

Thanks,

Richard

Hi Richard,

Thanks for this additional information.

I managed to reproduce the issue on my side, your request has been logged. We will inform you when a fix is ready.

In the mean time you can use the work arounds I suggested above or simple resave in MS Word seems to cause the issue to disappear.

Thanks,

The issues you have found earlier (filed as WORDSNET-4236) have been fixed in this Aspose.Words for .NET 23.8 update also available on NuGet.