Free Support Forum - groupdocs.com

Space is coming in a table cell and while converting it into the pdf by using groupdoc.viewer

I am creating a word doc by the below code:-

private void OpenWordDocument(DataTable dataTable, string xlsxFilePath, string xlsxReportTitle, ArrayList dataTypes, int policyId, int claimId, int eventId, int claimantId, Dictionary<string, string> objDictionary)
        {
            string notesText = string.Empty;
            try
            {
                using (WordprocessingDocument doc = WordprocessingDocument.Create(xlsxFilePath, WordprocessingDocumentType.Document))
                {
                    //// Defines the MainDocumentPart            
                    MainDocumentPart mainDocumentPart = doc.AddMainDocumentPart();
                    mainDocumentPart.Document = new Document();
                    Body body = mainDocumentPart.Document.AppendChild(new Body());

                    
                    //add main table                    
                    DocumentFormat.OpenXml.Wordprocessing.Table tbl = new DocumentFormat.OpenXml.Wordprocessing.Table();
                    tbl.Append(new TableWidth() { Type = TableWidthUnitValues.Dxa, Width = "9300" });
                    tbl.Append(new TableLayout() { Type = TableLayoutValues.Fixed });

                    TableProperties tblProperties = new TableProperties();
                    TableBorders tblBorders = new TableBorders();

                    DocumentFormat.OpenXml.Wordprocessing.TopBorder topBorder = new DocumentFormat.OpenXml.Wordprocessing.TopBorder();
                    topBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    topBorder.Color = "Black";
                    tblBorders.AppendChild(topBorder);

                    DocumentFormat.OpenXml.Wordprocessing.BottomBorder bottomBorder = new DocumentFormat.OpenXml.Wordprocessing.BottomBorder();
                    bottomBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    bottomBorder.Color = "Black";
                    tblBorders.AppendChild(bottomBorder);

                    DocumentFormat.OpenXml.Wordprocessing.RightBorder rightBorder = new DocumentFormat.OpenXml.Wordprocessing.RightBorder();
                    rightBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    rightBorder.Color = "Black";
                    tblBorders.AppendChild(rightBorder);

                    DocumentFormat.OpenXml.Wordprocessing.LeftBorder leftBorder = new DocumentFormat.OpenXml.Wordprocessing.LeftBorder();
                    leftBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    leftBorder.Color = "Black";
                    tblBorders.AppendChild(leftBorder);

                    InsideHorizontalBorder insideHBorder = new InsideHorizontalBorder();
                    insideHBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    insideHBorder.Color = "Black";
                    tblBorders.AppendChild(insideHBorder);

                    InsideVerticalBorder insideVBorder = new InsideVerticalBorder();
                    insideVBorder.Val = new EnumValue<BorderValues>(BorderValues.Thick);
                    insideVBorder.Color = "Black";
                    tblBorders.AppendChild(insideVBorder);

                    tblProperties.AppendChild(tblBorders);     // Add the table borders to the properties
                    tbl.AppendChild(tblProperties);      // Add the table properties to the table

                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        string altChunkId = "AltChunkId" + i;

                        DocumentFormat.OpenXml.Wordprocessing.Run run = new DocumentFormat.OpenXml.Wordprocessing.Run();

                        // 1st row start
                        DocumentFormat.OpenXml.Wordprocessing.TableRow tr1 = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
                        tr1.Append(new TableRowHeight() { Val = 500, HeightType = HeightRuleValues.Auto });

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr1c1 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["data1_field"].Trim() + ":"))));
                        tr1c1.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr1c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c1.Append(new TableCellProperties(new TableCellMargin(new TopMargin() { Width = "230" })));
                        tr1c1.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr1c1val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(dataTable.Rows[i]["data1_value"].ToString()))));
                        tr1c1val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr1c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr1c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c1val.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr1c2 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["data2_field"] + ":"))));
                        tr1c2.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr1c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c2.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr1c2val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(dataTable.Rows[i]["data2_value"].ToString()))));
                        tr1c2val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr1c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr1c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr1c2val.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));
                        tr1c2val.Append(new TableCellProperties(new TableCellMargin(new RightMargin() { Width = "100" })));

                        tr1.Append(tr1c1, tr1c1val, tr1c2, tr1c2val);
                        tbl.AppendChild(tr1);

                        // Second row starts.
                        DocumentFormat.OpenXml.Wordprocessing.TableRow tr2 = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
                        tr2.Append(new TableRowHeight() { Val = 300, HeightType = HeightRuleValues.Auto });

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr2c1 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["data3"].Trim() + ":"))));
                        tr2c1.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr2c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c1.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr2c1val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(dataTable.Rows[i]["data3_field"].ToString()))));
                        tr2c1val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr2c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr2c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr2c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c1val.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr2c2 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["subject_field"] + ":"))));
                        tr2c2.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr2c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr2c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c2.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr2c2val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(dataTable.Rows[i]["subject_field"].ToString()))));
                        tr2c2val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr2c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr2c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr2c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr2c2val.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));
                        tr2c2val.Append(new TableCellProperties(new TableCellMargin(new RightMargin() { Width = "100" })));

                        tr2.Append(tr2c1, tr2c1val, tr2c2, tr2c2val);
                        tbl.AppendChild(tr2);

                        // 3rd row(start)
                        DocumentFormat.OpenXml.Wordprocessing.TableRow tr3 = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
                        tr3.Append(new TableRowHeight() { Val = 300, HeightType = HeightRuleValues.Auto });

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr3c1 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["dateEntered_field"] + ":"))));
                        tr3c1.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr3c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr3c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr3c1.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr3c1val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(dataTable.Rows[i]["dateEntered_field"].ToString()))));
                        tr3c1val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr3c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr3c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr3c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.BottomBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr3c1val.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));


                        // 4th row(start)
                        DocumentFormat.OpenXml.Wordprocessing.TableRow tr4 = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
                        tr4.Append(new TableRowHeight() { Val = 300, HeightType = HeightRuleValues.Auto });

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr4c1 = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                        tr4c1.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr4c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr4c1.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr4c1.Append(new TableCellProperties(new TableCellMargin(new LeftMargin() { Width = "100" })));

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr4c1val = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                        if (dataTable.Columns.Contains("data4Trimmed_field"))
                        {
                            tr4c1.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["data4Trimmed_field"] + ":"))));
                            notesText = "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /></head>" + dataTable.Rows[i]["noteMemoTrimmed_field"].ToString() + "</html>";
                        }
                        else
                        {
                            tr4c1.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.RunProperties(new DocumentFormat.OpenXml.Wordprocessing.Bold()), new DocumentFormat.OpenXml.Wordprocessing.Text(objDictionary["data4T_field"] + ":"))));
                            //notesText = "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /></head>" + dataTable.Rows[i]["noteMemoCareTech_field"].ToString() + "</html>";
                            notesText = "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /></head>" + dataTable.Rows[i]["noteMemoCareTech_field"].ToString().Replace("&apos;", "'") + "</html>"; 
                        }

                        //notesText = CommonFunctions.HTMLCustomDecode(notesText);// commented for 26121 changes , as PDF and Word files were not holding the HTML tags as text unlike Excel files.
                        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(notesText));
                        AlternativeFormatImportPart formatImportPart = mainDocumentPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Html, altChunkId);  // Create alternative format import part.
                        formatImportPart.FeedData(ms);   // Feed HTML data into format import part
                        AltChunk altChunk = new AltChunk();
                        altChunk.Id = altChunkId;
                        tr4c1val.Append(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(altChunk)));
                        tr4c1val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr4c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr4c1val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        TableCellProperties tr4c1ValProperties = new TableCellProperties();
                        HorizontalMerge horizontalMerge = new HorizontalMerge()
                        {
                            Val = MergedCellValues.Restart
                        };
                        tr4c1ValProperties.Append(horizontalMerge);
                        tr4c1val.Append(tr4c1ValProperties);

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr4c2 = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(string.Empty))));
                        tr4c2.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr4c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr4c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.RightBorder() { Val = BorderValues.Dashed, Color = "white" })));
                        tr4c2.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        TableCellProperties tr4c2Properties = new TableCellProperties();
                        HorizontalMerge horizontalMerge2 = new HorizontalMerge()
                        {
                            Val = MergedCellValues.Continue
                        };
                        tr4c2Properties.Append(horizontalMerge2);
                        tr4c2.Append(tr4c2Properties);

                        DocumentFormat.OpenXml.Wordprocessing.TableCell tr4c2val = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new DocumentFormat.OpenXml.Wordprocessing.Text(string.Empty))));
                        tr4c2val.Append(new TableCellProperties(new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
                        tr4c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.LeftBorder() { Val = BorderValues.None })));
                        tr4c2val.Append(new TableCellProperties(new TableCellBorders(new DocumentFormat.OpenXml.Wordprocessing.TopBorder() { Val = BorderValues.None })));
                        tr4c2val.Append(new TableCellProperties(new TableCellMargin(new RightMargin() { Width = "100" })));
                        TableCellProperties tr4c2ValProperties = new TableCellProperties();
                        HorizontalMerge horizontalMerge3 = new HorizontalMerge()
                        {
                            Val = MergedCellValues.Continue
                        };
                        tr4c2ValProperties.Append(horizontalMerge3);
                        tr4c2val.Append(tr4c2ValProperties);

                        tr4.Append(tr4c1, tr4c1val, tr4c2, tr4c2val);
                        tbl.Append(tr4);
                    }

                    body.AppendChild(tbl);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }

And create a pdf by below code

public static void GetPDFFromWord(string sWordDocPath, string sPDFDocPath)
        {
            ViewerImageHandler objViewerImageHandler = new ViewerImageHandler(GroupDocUtilities.GetConfigurations());
            try
            {
                FileContainer objFileContainer = new FileContainer();
                objFileContainer = objViewerImageHandler.GetPdfFile(sWordDocPath);
                GroupDocUtilities.SaveFile(sPDFDocPath, objFileContainer.Stream);
            }
            catch (Exception ex)
            {

                throw(ex);
            }
            finally
            {
                objViewerImageHandler.ClearCache();
            }
        }

public static void SaveFile(String filename, Stream content)
        {
            FileStream fileStream;
            try
            {
                //ExStart:SaveAnyFile
                //Create file stream
                fileStream = File.Create(Path.Combine(Path.GetFullPath(OutputPath), filename), (int)content.Length);

                // Initialize the bytes array with the stream length and then fill it with data
                byte[] bytesInStream = new byte[content.Length];
                content.Read(bytesInStream, 0, bytesInStream.Length);

                // Use write method to write to the file specified above
                fileStream.Write(bytesInStream, 0, bytesInStream.Length);
                fileStream.Dispose();
                //ExEnd:SaveAnyFile
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                fileStream = null;
            }
        }

Now the Issue is in the word doc in the 4th row I have a text data and that data coming with space . And I need to remove those space by creating a PDF with groupdoc.viewer DLL

I have attached a word document here

I am attaching a word doc for sample where I am facing the issueREport_temp.docx (13.0 KB)

Hi @gaurav90

We investigating your issue, if any update you will be notified.

@mikhail.evgrafov.aspose Any suggestions

Hi @gaurav90

I want to clarify you want to remove space between these words?

(34.4 KB)

@mikhail.evgrafov.aspose yes I need to remove those space with double space in the above text also…with no space style… so extra space will not come

Hi @gaurav90

Unfortunately, we do not support such file modification as it is out of the scope of Viewer’s tasks. It looks like the best place to accomplish this would be creating Word document in OpenWordDocument without the space, so when there is no space in the source document the output PDF won’t have this space too.