Want to get the PDF size

HI Aspose Team,

My requirement is to get the size of pdf document, based on the pdf size i want to compress it lets say if the pdf size is more than 700 KB then i will go for compress, if size is less then 700 KB then i wont compress. Please send me complete code of how to get the size the document in MB/KB?

@yahi

Thanks for contacting support.

I am afraid that Aspose.PDF does not provide any direct method to determine file size of page size of a PDF document. A feature request as PDFNET-43073 is already logged in our issue tracking system for the sake of implementation. As soon as the feature is available, we will surely inform you. Please spare us little time.

Furthermore, you can use following workaround to get size of page before making compression decision:

Document inputPdfDocument = new Document(dataDir + "input.pdf");
Document doc = new Document();
// Add page which size is required to be determined
doc.Pages.Add(inputPdfDocument.Pages[1]);
MemoryStream ms = new MemoryStream();
doc.Save(ms);
long filesize = ms.Length;
// Compare the filesize with MBs
if ((filesize / (1024 * 1024)) < 46)
{
 // Do stuff
}