I am using aspose-cells version 8.4.2 to convert Excel to PDF. My code snippet is
// Load the document from disk.
Workbook workbook = new Workbook(sourceFile);
// Save the spreadsheet in PDF format.
workbook.save(destFile);
The xlsx file is 23MB, but the resulting PDF File is very large , almost 287 MB.
I’ve attached the source file for your reference.
I was unable to attach the converted file probably due to its size.
Please let me know how to resolve this issue.
Thanks.
Hi,
I am converted other formats with similar size source files but the resulting files are smaller:
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–>
File1.doc (23.7 MB) was converted to File1_doc.pdf (4.3 MB)
File2.txt (23.6 MB) was converted to File2_txt.pdf (5.1 MB)
Is there any options that can be set to get similar size for Excel to PDF Conversion? 23 MB to 220 MB seems to be excessive.
Thanks,
ragrawal:I am converted other formats with similar size source files but the resulting files are smaller:
File1.doc (23.7 MB) was converted to File1_doc.pdf (4.3 MB)
File2.txt (23.6 MB) was converted to File2_txt.pdf (5.1 MB)
ragrawal:Is there any options that can be set to get similar size for Excel to PDF Conversion? 23 MB to 220 MB seems to be excessive.
Using Acrobat, the file size is only 15.1MB. Is it possible to mimic the setting in this PDF to see if the file size reduces in Aspose?
The Acrobat-converted file is attached for your reference.
Thanks
Hi,
Hi again,
Workbook workbook = new Workbook(filePath);
//Get the count of the worksheets in the workbook
int sheetCount = workbook.getWorksheets().getCount();
//Make all sheets invisible except first worksheet
for (int i = 1; i < workbook.getWorksheets().getCount(); i++)
{
workbook.getWorksheets().get(i).setVisible(false);
}
//Initialize PdfSaveOptions for 1 PDF page per worksheet
// PdfSaveOptions options = new PdfSaveOptions();
// options.setOnePagePerSheet(true);
//Convert each worksheet to separate PDF
for (int j = 0; j < workbook.getWorksheets().getCount(); j++)
{
Worksheet ws = workbook.getWorksheets().get(j);
workbook.save(filePath + “_” + ws.getName() + “.pdf”/, options/);
if (j < workbook.getWorksheets().getCount() - 1)
{
workbook.getWorksheets().get(j + 1).setVisible(true);
workbook.getWorksheets().get(j).setVisible(false);
}
}