This is a migrated thread and some comments may be shown as answers.

PDF export from DOCX is not working properly

1 Answer 422 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Vipul
Top achievements
Rank 1
Vipul asked on 23 Jul 2020, 06:58 AM

In one of the application, we are using Telerik Pdf Processing library to convert docx template into pdf. For a few docx templates, exported PDFs are not identical to docx templates.

I've attached both files - template and generated pdf. In the generated pdf, a table is moved into right side and a few portion of right side is cut (Can't see complete table in pdf).

Template: https://drive.google.com/file/d/1u0geoIkSzT3iRAg3xJaSlNsOmC00_078/view?usp=sharing

Generated PDF Output: https://drive.google.com/file/d/1ceNyE4vUxxafaVOZr7zSwDfUm111eu2L/view?usp=sharing

 

Following code, we are using to generate pdf from docx

 

Can anybody tell us what is missing here in code? 

Why a table is cut from right side in the generated pdf? Are there any ways to fix this issue?

 

It would be a great help if anyone could help to fix this issue.

 

[TestMethod]
        public void TelerikPdfConversionTest()
        {
            string templatePath = Path.Combine(_telerikTemplateDirectory, $@"DependentNearing19.docx");
            byte[] data = File.ReadAllBytes(templatePath);
            var provider = new DocxFormatProvider();
            RadFlowDocument doc = provider.Import(data);
 
            string templateName = Path.GetFileNameWithoutExtension(templatePath);
            string pdfPath = Path.Combine(_telerikTemplateDirectory, $@"{templateName}-output.pdf");
            if (File.Exists(pdfPath))
            {
                File.Delete(pdfPath);
            }
            var pdfProvider = new PdfFormatProvider();
            using (Stream output = File.OpenWrite(pdfPath))
            {
                pdfProvider.Export(doc, output);
            }
            Assert.IsTrue(File.Exists(pdfPath));
        }

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Jul 2020, 01:12 PM

Hi Vipul,

Thank you for the provided documents and feedback.

It seems this behavior is caused by a wrongly exported table width when the table preferred width is set to fixed and it is greater than the available page width. I logged an item in our backlog to fix this issue: WordsProcessing: PdfFormatProvider: Wrongly exported table width when table preferred width is set to fixed and it is greater than the available page width. You can follow the item in order to receive updates when its status changes. 

In appreciation for bringing this to our attention, I updated your Telerik points.

As a possible solution until this bug is fixed, I would like to suggest to check the provided in the Bug Report workaround.

Regards,
Martin
Progress Telerik

Tags
PdfProcessing
Asked by
Vipul
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or