We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextWrap is lost on save to PDF

Hello,

I have a simple spreadsheet with 1 column. Column A is fixed width and formatted to wrap text and top-align. Adding long strings of text to the cells in Column A results in proper display when save as .xlsx. But when save as .pdf there is no wrap of the text.

What am I doing wrong?

Attached is a solution demonstrating the issue as well as the two different output files that clearly show the loss of wrap.

Thank you!
Rick

Hi,


Thanks for the sample project with template files.

Please autofit the rows before you render the workbook to PDF file format. The line of code is compulsory to auto-extend the row heights based on the contents in the cells. Please add a line of code (in bold) to your code segment:
e.g
Sample code:

Workbook wb = new Workbook(txtWBIn.Text);<o:p></o:p>

Worksheet ws = wb.Worksheets["Sheet1"];

for(int i = 1; i <= 5; i++)

{

Cell cl = ws.Cells[i, 0];

cl.Value = lorem;

}

ws.AutoFitRows(true);

string outpath = txtOutpath.Text + @"\sampleOut.xlsx";

SaveFormat saveFormat = SaveFormat.Xlsx;

wb.Save(outpath, saveFormat);

outpath = txtOutpath.Text + @"\sampleOut.pdf";

saveFormat = SaveFormat.Pdf;

wb.Save(outpath,
saveFormat);


Hope, this helps a bit.

Thank you.

Works like a charm! Thank you!!

Hi,


Good to know that your issue is sorted out by the suggested line of code. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.