Export Docx to PDF - Data truncation

Hi
When we have export docx to PDF, data was truncated in PDF. We have attached exported PDF with docx.
Let us know solution if any.
Regard
Rathinam

Hi Rathinam,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your document to Pdf using MS Word, you will get the same output.

In your word document, the table’s contents are outside the right margin. Please check the attached image for detail. Please make sure that you have shared the correct document. Please share your expected output Pdf file. Please also share the page number of output Pdf file which shows the undesired output. I will investigate the issue on my side and provide you more information.

Hi
Thanks for your reply.I have attached PDF and Docx for your review earlier. when you expand the cell, whole data available but truncated in PDF.Pl find the attached doc for cell expand in docx.
Regards
Rathinam

Hi Rathinam,

Thanks for sharing the detail. Please share the document for which you have expanded the cells. If you are expanding the cell using code, please share the code. I will investigate the issue on my side and provide you more information.

Hi
Thanks for your reply. we have manually expanded the cell.It is in 4th page of the docx.
Regards
Rathinam

Hi Rathinam,

Thanks for sharing the
detail. I have expanded the table’s cell (at 4th page) using MS Word and have converted the modified document to Pdf using Aspose.Words. I have not found any issue with output document. I have attached the modified document and output Pdf file with this post for your kind reference.

Please let us know if you have any more queries.

Hi,
Thanks for the reply. However there are few points to be considered.
The docx content cannot be modified maunally or programatically in our case as this the input for us. So we require a solution to convert the docx to pdf as it is. We are facing the truncation in this case.
Please find the expected output from the docx.
Encl:

  1. Discharge summary aspose.docx - Input in docx format
  2. Discharge summary expected.pdf - Expected output in PDF format.
  3. discharge summarry.pdf - Truncated output from ASPOSE (Pls Refer page 4)

Hi Rathinam,

Thanks for your inquiry. In your case, I suggest you please use the Table.AutoFit method as shown below to get the required output. I have attached the output Pdf file with this post for your kind reference.

Document doc = new Document(MyDir + "Discharge+summary+aspose.docx");
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.AllowAutoFit = true;
    table.AutoFit(AutoFitBehavior.AutoFitToContents);
}
doc.Save(MyDir + "Out.pdf");

Please let us know if you have any more queries.

Hi, Thanks for your suggestion.
We tried this code. But, the suggested code is modifying all the tables in the document.
Our expectation is to solve the truncation issue for that particular table without distrubing other table’s alignment.
Any possibilities please?
Thanks in adavace.

Hi Rathinam,

Thanks for your inquiry.
Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your document to Pdf using MS Word, you will get the same output for this specific table.

Please use the following code example to achieve your requirements. Hope this helps you.

Document doc = new Document(MyDir + "Discharge+summary+aspose.docx");
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    if (table.ToString(SaveFormat.Text).Trim().Contains("finasteride"))
    {
        table.AllowAutoFit = true;
        table.AutoFit(AutoFitBehavior.AutoFitToContents);
        break;
    }
}
doc.Save(MyDir + "Out.pdf");

Hi
The data “finasteride” is dynamically loaded in the table. We will get data anywhere in the table. This will not solve the problem. I have attached document difference with Origin and aspose recommandation PDF.
Regards
Rathinam

Hi Rathinam,

Thanks for your inquiry. The tables in your document are out of the page at right side. So, you need to set the left indent of table. Please set the left indent of table as shown below.

*rshanmugam21:

The data “finasteride” is dynamically loaded in the table. We will get data anywhere in the table. This will not solve the problem.*

The width of second column of table at page number 4 is not according to the contents. In this case, please update cell width of table according to the cell contents. To get the required output, you need to use AutoFitBehavior.AutoFitToContents for this table.

In your case, Table.AutoFit(AutoFitBehavior.AutoFitToContents) corrupt the table’s cell layout. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10208. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Document doc = new Document(MyDir + "Discharge+summary+aspose.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Paragraph para = new Paragraph(doc);
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.LeftIndent = 10;
    if (table.ToString(SaveFormat.Text).Trim().Contains("finasteride"))
    {
        table.AutoFit(AutoFitBehavior.AutoFitToContents);
    }
}
doc.Save(MyDir + "Out.pdf");

Thanks Tahir.
Is there any approx expected time for this fix ? So that we can plan accrodingly from our end.

Hi Rathinam,

Thanks for your inquiry.

I would
like to share with you that
issues are addressed and resolved based on first come first serve
basis. Currently, your issue is pending for analysis and is in the
queue. I am afraid, I can’t provide you any reliable estimate at the
moment. Once your issue is analyzed, we will then be able to provide you
an estimate.

Thank you for your patience.

Hi Rathinam,

Thanks for your patience.

It
is to update you that our development team has completed the
analysis of this issue and has come to a conclusion that this issue has
been closed with ‘‘Won’t Fix’’ resolution.

As a workaround, please use the following code example to achieve your requirements.

Document doc = new Document(MyDir + "Discharge+summary+aspose.docx");
Node[] tables = doc.GetChildNodes(NodeType.Table, true).ToArray();
foreach (Table table in tables)
{
    // Check if the next node after the table is another table.
    if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Table)
    {
        Table nextTable = (Table)table.NextSibling;
        // Append all rows form the current table to the next.
        while (table.HasChildNodes)
            nextTable.Rows.Insert(0, table.LastRow);
        table.Remove();
    }
    if (table.HasChildNodes && table.LeftIndent > 400)
        table.LeftIndent = 10;
}
// Only this table needs to be fixed.
((Table)tables[10]).AutoFit(AutoFitBehavior.AutoFitToContents);
doc.Save(MyDir + "out.pdf");

Moreover, It seems your document was created using some third-party tool. If you add a single space in input document using MS Word and save it. Aspose.Words generates the correct output for this modified document.