You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Docx file generated with OpenXML isn't able to be exported by soffice in linux (has something to do with the content)
To Reproduce
using (MemoryStream memoryStream = new MemoryStream())
{
using (var doc = DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(memoryStream, DocumentFormat.OpenXml.WordprocessingDocumentType.Document, true))
{
MainDocumentPart mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
var table = new Table();
TableProperties tableProperties = new TableProperties();
tableProperties.TableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };
table.AppendChild(tableProperties);
TableGrid tableGrid = new TableGrid(
new GridColumn(),
new GridColumn()
);
table.AppendChild(tableGrid);
TableRow tableRow = new TableRow();
TableCell tc1 = new TableCell(
new TableCellProperties(new TableCellWidth() { Width = "2500", Type = TableWidthUnitValues.Pct }),
new Paragraph(new Run(
new RunProperties(new FontSize() { Val = "56" }, new RunFonts() { Ascii = "Times New Roman" }),
new Text("Patient Hours Detail")
)
)
);
TableCell tc2 = new TableCell(
new TableCellProperties(new TableCellWidth() { Width = "2500", Type = TableWidthUnitValues.Pct }),
new Paragraph(new ParagraphProperties(new Justification() { Val = JustificationValues.Right }), new Run(new RunProperties(new FontSize() { Val = "34" }, new RunFonts() { Ascii = "Times New Roman" }), new Text(model.CaseName))),
new Paragraph(new ParagraphProperties(new Justification() { Val = JustificationValues.Right }), new Run(new RunProperties(new FontSize() { Val = "26" }, new RunFonts() { Ascii = "Times New Roman" }), new Text($"{model.StartDate.ToString("MM/dd/yyyy")} through {model.EndDate.ToString("MM/dd/yyyy")}")))
);
tableRow.Append(tc1);
tableRow.Append(tc2);
table.AppendChild(tableRow);
body.Append(table);
doc.Save();
memoryStream.Position = 0;
var byteArray = memoryStream.ToArray();
return byteArray;
then save the byteArray as "sdfomsef.docx" locally
then soffice --headless --convert-to pdf sdfomsef.docx
Error: source file could not be loaded
Expected behavior
If I try remove the 2nd table cell this works (this line tableRow.Append(tc2);)
Desktop (please complete the following information):
OS: Docker mcr.microsoft.com/dotnet/aspnet:6.0
Office version [e.g. 16.0.15427.20178]
.NET Target: .net6
DocumentFormat.OpenXml Version: 3.0.1
The text was updated successfully, but these errors were encountered:
Hi @cjalex1313, I'm able to recreate the issue and error you see with soffice, but removing the 2nd table cell doesn't fix it for me. I even created a .docx with no table using Word and tried to convert it to a PDF with soffice, but it also got the same error. I'm using Ubuntu SSL on Windows, so it's not the same environment. Are you able to use soffice to convert any docx to pdf?
Describe the bug
Docx file generated with OpenXML isn't able to be exported by soffice in linux (has something to do with the content)
To Reproduce
then save the byteArray as "sdfomsef.docx" locally
then soffice --headless --convert-to pdf sdfomsef.docx
Error: source file could not be loaded
Expected behavior
If I try remove the 2nd table cell this works (this line tableRow.Append(tc2);)
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: