I'm converting a docx file to pdf using Spire.doc. Conversion works fine except a strange behavior when using a page break inside a table.
Spire.Doc does not recognize such page break and the next page is being hidden inside the previous table cell. I've converted the same document successfully with MS Word, which has created a pdf very similar to the original docx.
I have attached 2 files : the original docx file and the PDF retrieved from a conversion with Spire.Doc. The page break is located at the end of page 5.
Is there a problem with my conversion code below, or does this come from Spire.Doc itself ?
I'm using latest version 8.5.9 but I also observed the same issue with older versions.
Thank you
- Code: Select all
using (var fileStream = await file.ReadAsStreamAsync())
{
var document = new Spire.Doc.Document();
document.LoadFromStream(fileStream, Spire.Doc.FileFormat.Docx);
using (var ms = new MemoryStream())
{
// Save it as PDF
document.SaveToStream(ms, Spire.Doc.FileFormat.PDF);
// Make the stream readable
ms.Position = 0;
var response = new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new ByteArrayContent(ms.ToArray())
};
response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
{
FileName = Utils.RenameFile(file.Headers.ContentDisposition.FileName, "pdf")
};
return response;
}
}