Save to PDF -> header new lines parsed wrong

Using Aspose.Cells 8.3.2.1





Create a workbook with a worksheet and set the header like so:





sheet.PageSetup.SetHeader(0, “line1” + Environment.NewLine + “line2” Environment.NewLine + “line3”);





If you save the file with workbook.Save(some_file, Aspose.Cells.SaveFormat.Xlsx); the headers have proper line spacing where Environment.NewLine = 1 new line.





If you save the file with workbook.Save(some_file, Aspose.Cells.SaveFormat.Pdf); the headers have incorrect spacing with each Environment.NewLine resolving to 2 new lines. The conversion to Pdf is changing the \r\n of Environment.NewLine into \n\n.





However, converting that first file into Pdf from Excel works properly… or loading that saved file back into a new workbook object and saving it to Aspose.Cells.SaveFormat.Pdf will work as well.





A temporary work around is to replace Environment.NewLine with \n in the string to set the header text.

Hi Michael,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue after running the following sample code using the latest version: Aspose.Cells
for .NET v8.3.2.3
. We found NewLine is resolving to 2 lines in the output PDF.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43410 - Incorrect spacing with each Environment.NewLine resolving to 2 new lines in output PDF

I have attached the output Excel and PDF files for a reference.

C#

Workbook workbook = new Workbook();


Worksheet sheet = workbook.Worksheets[0];


sheet.Cells[“C3”].PutValue(“Welcome to Aspose!”);


string txt = “line1” + Environment.NewLine + “line2” + Environment.NewLine + “line3”;


sheet.PageSetup.SetHeader(0, txt);


workbook.Save(“output.xlsx”);


workbook.Save(“output.pdf”);

Thank you for your speedy reply. I think I have found another similar bug with header spacing.





To recreate use the following:





Workbook wb = new Workbook();



Worksheet sheet = wb.Worksheets[0];





sheet.PageSetup.SetHeader(0, “header line 1\nheader line 2\nheader line 3”);



sheet.PageSetup.SetFooter(1, “some centered footer text”);





sheet.PageSetup.FitToPagesWide = 1;





sheet.Cells[“A1”].Value =“some text for cell A1”;



sheet.Cells[“A2”].Value = “some text for cell A2”;





sheet.Cells[“C6”].Value = “Jan”;



sheet.Cells[“D6”].Value = “Feb”;



sheet.Cells[“E6”].Value = “Mar”;



sheet.Cells[“F6”].Value = “Apr”;



sheet.Cells[“G6”].Value = “May”;



sheet.Cells[“H6”].Value = “Jun”;



sheet.Cells[“I6”].Value = “Jul”;



sheet.Cells[“J6”].Value = “Aug”;



sheet.Cells[“K6”].Value = “Sep”;



sheet.Cells[“L6”].Value = “Oct”;



sheet.Cells[“M6”].Value = “Nov”;



sheet.Cells[“N6”].Value = “Dec”;



sheet.Cells.SetColumnWidth(14, 2);



sheet.Cells[“P6”].Value = “Annual”;





int textboxIndex2 = sheet.TextBoxes.Add(62, 0, 100, 916);



Aspose.Cells.Drawing.TextBox textbox2 = sheet.TextBoxes[textboxIndex2];



textbox2.Text = “some text goes in this box here”;



textbox2.Font.Size = 10;



textbox2.Font.IsBold = false;



textbox2.Font.IsItalic = false;



textbox2.HasLine = false;



textbox2.TextVerticalAlignment = TextAlignmentType.Top;





wb.Save(“text.xlsx”);



wb.Save(“test.pdf”);







The gap between the header and the body is different in the pdf and the xlsx. The pdf has much more space. I’ve tried fixing this by playing with sheet.PageSetup.TopMarginInch but the whitespace is never the same between the output pdf and xlsx files.

Hi Michael,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue after running your sample code with the latest version. Gap between the header and the body is different in the pdf and the xlsx.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43414 - Gap between the header and the body is different in the pdf and the xlsx

I have attached the output Excel and PDF files for a reference

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.3.2.4 and let us know your feedback.

CELLSNET-43410 appears to be fixed, thank you.



CELLSNET-43414 still appears to be broken.

Hi Michael,


Thank you for the confirmation on CELLSNET-43410. The other ticket (CELLSNET-43414) is currently unresolved, and work is in progress. We will let you know once we have more updates in this regard.

Hi,

Thanks for your using Aspose.Cells.

We have fixed the issue CELLSNET-43414.

Please download and try the latest fix: Aspose.Cells for .NET v8.3.2.5 and let us know your feedback.

CELLSNET-43414 appears to be resolved, thank you.

Hi Michael,

Thank you for the confirmation on CELLSNET-43414. Please feel free to get in touch if you require any further assistance with Aspose APIs.

The issues you have found earlier (filed as CELLSNET-43414;CELLSNET-43410) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as CELLSNET-43414;CELLSNET-43410) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)