We are using Aspose.PDF version 21.11.0 to convert excel files to PDF. The settings for the excel worksheet are shown below in screenshot1. When this excel worksheet gets converted to PDF, the graph seems to be left-aligned and adds additional whitespace onto the right which looks like screenshot 2 below.
Here’s the code used to convert an excel document to PDF -
if (fileExtension.ToLower().Contains(".xls"))
{
//Convert Excel doc to PDF
var workbook = new Aspose.Cells.Workbook(mStream);
foreach (Aspose.Cells.Worksheet sheet in workbook.Worksheets.Where(worksheet => !worksheet.Name.StartsWith(“sheet_”)))
{
sheet.IsVisible = false;
}
if (workbook.Worksheets.Any())
{
var pdfStream = new MemoryStream();
workbook.Save(pdfStream, Aspose.Cells.SaveFormat.Pdf);
BlobContainerClient container = new BlobContainerClient(_settings.CloudStorageConnection, “containername”);
BlobClient blob = container.GetBlobClient($"/converted/{newFilePath}");
pdfStream.Position = 0;
blob.Upload(pdfStream, true);
pdfStream.Close();
}
}
We are not specifying any formatting explicitly using Aspose.
I want to make sure that the graph looks exactly the same in Excel’s print preview format without any whitespace. How can I accomplish this? Any help is greatly appreciated. Thank you in advance.
Please try our latest version/fix: Aspose.Cells for .NET 22.2. If you still find the issue with latest version/fix, kindly do zip and attach your template Excel file containing the underlying chart, we will it soon.
I downloaded your attachment (zipped archive). I extracted the zipped archive to some folder. I found it has a folder “excel sheet” which is empty. Could you please re-attach the zipped archive containing correct Excel file. We will check your issue soon.
Hi @Peyton.Xu. Thank you for your response. Please see the attached document on how it looks like on my end. After running our application, I verified in the blob storage container which has the same format as the attachment ( makes me think that the conversion didn’t happen properly).
PS: I am not able to share the complete output PDF document because it contains actual data. Also, the converted document itself isn’t formatted properly. So I wonder if merging is the issue.
You use Aspose.Cells to convert excel files to separated pdf files, and then use Aspose.Pdf to merge all the separated pdf files into one final pdf file. Aspose.Cells and Aspose.Pdf are two separated products.
To locate the possible issue in Aspose.Cells, you need to compare Aspose.Cells generated pdf files(before being merged into one final pdf file) with the source excel files. If there are some issues, please share the Aspose.Cells generated pdf file and the corresponding source excel file.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.