Content is cut when printing


#1

Hi,

we are having an issue with printing an excel sheet via Aspose. The content from the footer is cut and not fully visible on the printed sheet.
I attached you an example excel sheet and a PDF with scans. First page is printed with Aspose, seconds page is saved to PDF (with Aspose) and printed PDF, third page is printed with Excel.
You can clearly see, that all three sheets are printed differently and cells do not have the same height and width sometimes. This results in missing content when printing with Aspose.

Code used to print the document:

var lic = new License();
lic.SetLicense(@"S:\Aspose.Total.lic");

var workbook = new Workbook(@"S:\ims-6737.xls");

var wbr = new WorkbookRender(workbook, new ImageOrPrintOptions() {PrintingPage = PrintingPageType.Default});
wbr.ToPrinter(new PrinterSettings().PrinterName);

If you print each sheet with a Sheetrenderer, you will have the same problem.

PDF was generated with the following code:

var lic = new License();
lic.SetLicense(@"S:\Aspose.Total.lic");

var workbook = new Workbook(@"S:\ims-6737.xls");
workbook.Save(@"S:\out.pdf");

This issue is reproducable on different printers for us.

example.zip (783.3 KB)

Kind Regards,
Daniel


#2

@Serraniel,

Thanks for the template file, sample code and details.

I am afraid, I could not find the issue on my end. I am using our latest version/fix: Aspose.Cells for .NET v19.9.x (please try it if you are not already using it). I used “Microsoft XPS Document Writer” as printer on my pc. Here is the sample code that I used and please find attached the printout in .xps file format:
e.g
Sample code:

 var workbook = new Workbook("e:\\test2\\ims-6737.xls");
            var wbr = new WorkbookRender(workbook, new ImageOrPrintOptions() {PrintingPage = PrintingPageType.Default});
            wbr.ToPrinter("Microsoft XPS Document Writer");

files1.zip (193.6 KB)


#3

Hi @Amjad_Sahi,

I checked the results when printing to XPS and with using a PDF printer and get correct results using them, too. So I assume that is something related to the Sharp printer we use and to the printer our customer who reported the bug uses.
I noticed, that the document has a 1.2 cm top margin, but printed with Aspose it hast 1.6 cm on the actual sheet. If I configure 0.8 cm (via code) I get 1.2 cm margin in the printed result, so there somehow seems to be a 4 mm offset. So I investigated a bit further and noticed, that the “hardware printer” in C# has hard margins set:
image.png (9.5 KB)

That property uses hunmdreths of an inch as unit, so that value 16 converts to 4.064 mm. That might be the cause as it matches exactly those 4 mm offset I get on the paper.

Now my question is: Is that something we have to handle at our side to adjust the margins in the pagesetup of each page? Are there any best practices for this? Or is this something which will be rated as a bug in the WorkbookRender?
I did a comparison to Aspose.Words: The AsposeWordsPrintDocument seems to be aware of those hard margins and to handle them correctly as the margins on the printed documents are correct and the same as with printed via Word.

You may have a look into that. I personally would expect Aspose to generate the same output as excel does when printing to a printer with hard margins and it seems like excel “fixes” this during printing.

Kind Regards,
Daniel


#4

@Serraniel,

Thanks for the image and further details.

I have logged an investigation ticket with an id “CELLSNET-46953” for your issue. We will evaluate your issue and try to test on different printers. We will try to figure out issue (if found) soon.

Once we have an update on it, we will let you know.