I have a word document and it’s contain table structure. While converting into pdf in .net it’s contain double line space between two rows… any solution
I am creating word doc with table structure code as mentioned
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("'", "'") + "</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;
}
}
With the hep of above code we are creating word document and converting the word doc with groudoc.viwer dll as mentioned code below:-
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();
}
}
And
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 in pdf
image.png (20.9 KB)
so space is coming more between two rows while converting.
Might you attach your source word document? When I generated word document with your code I got a document with spacing between lines (table rows) and I reset it by adding before “body.AppendChild(tbl);”
with the following code:
foreach (object row in tbl.ChildElements)
{
TableRow rowObj = row as TableRow;
if (rowObj != null)
{
// cells
foreach (object cell in rowObj.ChildElements)
{
TableCell cellObj = cell as TableCell;
if (cellObj != null)
{
foreach (object par in cellObj.ChildElements)
{
Paragraph parObj = par as Paragraph;
if (parObj != null)
{
parObj.ParagraphProperties = new ParagraphProperties();
parObj.ParagraphProperties.AppendChild(new SpacingBetweenLines() { Line = "240", LineRule = LineSpacingRuleValues.Auto, Before = "0", After = "0" });
}
}
}
}
}
}
This code reset default spacing in table cells paragraphs.
@mikhail.evgrafov.aspose its work for me… thanks a lot and test my if i found any issue will discuss over here.
@mikhail.evgrafov.aspose I found one more issue that when I have a table in one fields (notesText in OpenWordDocument method) when the converting the document then giving an error index out of bound.
table structure as below
"
Platform Team | Platform Team |
the code break on objViewerImageHandler.GetPdfFile(sWordDocPath); in GetPDFFromWord method.
Error details : Index was outside the bounds of the array.
at .( , [] )
at .( )
at .( )
at . ()
at . ()
at .( )
at .( )
at .( )
at .( )
at .( , Int32 , Boolean )
at .()
at .( , Int32 , Boolean , Boolean )
at . ()
at .( , Int32 )
at .( )
at .()
at .( )
at .(Boolean )
at .(Boolean )
at . ()
at .(Document , )
at . (GroupDocsOutputStream )
at .(GroupDocsOutputStream )
at .()
at .(FileDescription , PdfFileOptions )
Hi @gaurav90
We will investigate this issue too. In next time when you want to report new issue, please create it in new topic.
Topic with your issue:
@mikhail.evgrafov.aspose I am attaching a document where I get an error while converting into pdf.Report_temp.docx (13.0 KB)
And table structure also I have attached which is being used in the document. table_structure.docx (11.9 KB)
Hi @gaurav90
Let’s continue discussion in Error index out of bound when converting PDF from docx
I will close this topic.