Pdf size optimization

Hi,


We have some data which can be downloaded in word or PDF. When we download them, we have noticed that the size of the PDF file is exponentially higher than the size of PDF. For example the variation is like 23 kb to 1Mb.

To solve this I have gone through the aspose documents for optimisation. However,I am not able to acess the method OptimizeResources() .

The code snippet used in vb.net is here:

Dim pdfDocument As Words.Document = New Words.Document()
_builder = New DocumentBuilder(_document)
WriteTitle(Name)
DisplaySummary()
BuildTableOfContents()
Writedocument()
Finalizedocument()

Return pdfDocument

Here I am not able to acces the optimiseresources method. Please let me know how do I use the method and reduce the size of the PDF file generated.

Thanks,
Varsha

Hi Varsha,

Thanks for your inquriy. Please note OptimizeReoruces is Aspose.PDF for .NET class to optimize PDF file size. You can pass resultant PDF document from Aspose.Words to Aspose.PDF DLL as following for your requirement, it will help you to accomplish the task.

Dim document As New Aspose.Pdf.Document("input.pdf")

' Optimzie the file size by removing unused objects
document.OptimizeResources(New Aspose.Pdf.Document.OptimizationOptions() With {_
    Key.LinkDuplcateStreams = True, _
    Key.RemoveUnusedObjects = True, _
    Key.RemoveUnusedStreams = True, _
    Key.AllowReusePageContent = True, _
    Key.UnembedFonts = True, _
    Key.CompressImages = True, _
    Key.ResizeImages = True, _
    Key.MaxResoultion = 150, _
    Key.ImageQuality = 60 _
})

' Save the updated file
document.Save("out.pdf")

Please feel free to contact us for any further assistance.

Best Regards,