Free Support Forum - aspose.com

Printing bug

Please find attached a sample project and a photo of my print and the spreadsheet used to render them with. The sheet was generated too using Cells.

I am using the 7.0.1 release and haven’t bothered including my license file when compiling the sample although we do have a full license.
When the sheet is going to the printer, it overprints the totals from page 1 onto page 2 and refuses to fit to one page tall even though the options explicitly state it.
Trying to create an image of the sheet also fails to show the totals or the second page.

Is there anything I am doing wrong or is this a bug with the renderer which is what it looks like to me.

Thanks
Jon

Hi,


I tested you scenario a bit using my sample code (below) with v7.0.1, it works fine using your file. I have attached my output image for the first sheet:
Sample code:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(“e:\test2\printing_bug\tmpSyle.xls”);
workbook.CalculateFormula();
Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];
//Apply different Image and Print options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
//Set Horizontal Resolution
options.HorizontalResolution = 300;
//Set Vertical Resolution
options.VerticalResolution = 300;
//Set TiffCompression
options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionLZW;
//Set Autofit options
options.IsImageFitToPage = true;
options.OnePagePerSheet = true;
//Set Image Format
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
//Set printing page type
options.PrintingPage = Aspose.Cells.PrintingPageType.Default;
//Render the sheet with respect to specified image/print options
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);
//Render/save the image for the sheet
for (int i = 0; i < sr.PageCount; i++)
{
sr.ToImage(i, “e:\test2\printing_bug\Img_” + sheet.CodeName + “_” + i + “.tif”);
}

Thank you.

Hi there,

If you look on my sample, you will notice that I am using the WorkbookRender object, not the sheet render. Rendering a single sheet also works for me but sadly that was not the issue raised.
The main issue raised was actually about an overprinting of the bottom totals on page 2 - I tried to save it as an image to help with diagnosing and to see if that had a problem too which it seems to (albeit a different one of pages not fitting regardless of the setting)
Please run my version of the code (changing the name of the printer to one of yours) and see what it produces…

Thanks

Jon

Hi,


Your code line:
Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(wb, iop);

should be written after all the modifications of PageSetup, otherwise, the changes of PageSetup will not be taken effect fine.

We use the following code and it works fine.
e.g


//…
Workbook wb = new Workbook(“m:\tmpSyle.xls”);

//iop.HorizontalResolution = 200;
//iop.VerticalResolution = 200;
//iop.OnePagePerSheet = true;
foreach (Aspose.Cells.Worksheet sheet in wb.Worksheets)
{
sheet.PageSetup.FitToPagesTall = 1;
sheet.PageSetup.FitToPagesWide = 1;
sheet.PageSetup.PaperSize = Aspose.Cells.PaperSizeType.PaperA4;
sheet.PageSetup.IsPercentScale = false;
}
ImageOrPrintOptions iop = new ImageOrPrintOptions();
iop.ImageFormat = ImageFormat.Tiff;
iop.OnePagePerSheet = true;
Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(wb, iop);
//Print the sheet.

wr.ToImage(@“m:\supportImage.tif”);

Thank you.

Hi there,

Perhaps I am missing something but that code produces only a single page sheet (attached)? Where is the other page or does workbook render ToImage() only render a single page (and if so how is it different to sheet render)? I would be expecting a large image with all the pages concatenated into it.
Also, if as per your comment, there is a dependency that an object must be created at the end of a process to work, this should be included in your documentation…

Regardless, my original problem (and the reason for trying to see how it came out as an image) is that when printing the book, page 2 totals are overwritten with page 1 totals. I have circled them in a photograph of the image uploaded previously.

Thanks
Jon

Hi,


The reason for rendering a single page per sheet is due to your lines of code e.g
//…
sheet.PageSetup.FitToPagesTall = 1;
sheet.PageSetup.FitToPagesWide = 1;
ImageOrPrintOptions iop = new ImageOrPrintOptions();
iop.OnePagePerSheet = true;

etc.


If you still find any issue or confusion, create a sample console application with v7.0.1.xm zip it and post it here to show the issue (with all the output files), we will check your issue soon.

Thank you.

Hi there, apologies but I am a little bit confused… When sending a sheet with sheet renderer to an image, I am expecting the sheets to fit one per page. When I am sending a book to Workbook Renderer, I expect the rendered image to contain all the sheets in one image (since ToImage() indicates creating a single image from the workbook not individual sheets)

Attached at the start of this help request is the sample application as requested along with the screenshots and example data. The principle issue is that it is overprinting the totals on page 2 with those of page 1. Trying to get it to print to an image was just to help diagnose the problem by seeing if that had the same issue although it seems to have raised it’s own in the process!

Hi,


We still could not find the issue. For your information, MS Excel will change text wrapping according to the default font set. You can check the print preview in Excel for each default font set.

Thank you.

Hi there, I am not sure what text wrapping has to do with copies of the totals over printing on page 2 from page 1 (see the photograph in the first message). When you print the worksheet on paper using the sample code sent does it print correctly (please for the moment ignore all the rendering to image issues since they are just confusing the issue)

Hi,

1) For "overprinting the totals on page 2 with those of page 1":
This issue is caused by we cannot make the same default page breaks for certain default fonts similar to what Excel does. You can use the following as a workaround:
sheet.PageSetup.FitToPagesTall = 1;
sheet.PageSetup.FitToPagesWide = 1;

2) For "WorkbookRender" :
It can only be used when saving to Tiff image, XPS or printer.
All worksheets will be saved to single multi-page Tiff image, one sheet will be saved in a Tiff Page.
Your can view each page in Tiff using Microsoft Picture viewer tool.
The size of Tiff image is decided by the largest Tiff Pages.

3) For "OnePagePerSheet property":
IF this property is true, it will change size of the output image size, because all data needs to be rendered to a single image. And if OnePagePerSheet is true, the page size setting of PageSetup will not take effect (mind you), I think for this issue or case, you should set OnePagePerSheet to false, for you do not want to change size of the output image.

Thanks for your understanding!

Hi there,

-For the overprinting, I think it is because I had it in trial mode. Putting in the license key sorted it and the page fitting on one sheet. If possible can you change the way that the evaluation works to overprint your warning message rather than moving everything down. Has the same effect but doesn’t screw the settings up.
-Workbook render doesn’t work as you described. It only adds one sheet
-Sorry, I don’t quite understand your last point… :slight_smile:
Thanks
Jon