Optimize PDF Files
GroupDocs.Viewer for Node.js via Java 24.5 lets you reduce the file size or prepare PDFs for web browsers with various options like removing annotations, compressing images, and more. Please check out the following coding sample, which highlights how to enable the available PDF optimization options.
const viewer = new groupdocs.viewer.Viewer("invoice.pdf")
const viewOptions = new groupdocs.viewer.PdfViewOptions()
const optimizationOptions = new groupdocs.viewer.PdfOptimizationOptions()
optimizationOptions.setLinearize(true) // Optimize PDF for web-browsers
optimizationOptions.setOptimizeSpreadsheets(true) // Optimize spreadsheets for a smaller size
optimizationOptions.setSubsetFonts(true) // Keep the characters that actually used
optimizationOptions.setRemoveAnnotations(true) // Remove annotations
optimizationOptions.setRemoveFormFields(true) // Remove form fields
optimizationOptions.setConvertToGrayScale(true) // Convert images to grayscale
optimizationOptions.setCompressImages(true) // Enable images compression
optimizationOptions.setResizeImages(true) // Enable resize images with lower resolution
optimizationOptions.setMaxResolution(150) // Set resolution for images, default value is 300
optimizationOptions.setImageQuality(30) // Set image quality, default value is 100
viewOptions.setPdfOptimizationOptions(optimizationOptions)
viewer.view(viewOptions)
Source*
Retrieve View Info
Developers can effortlessly access details about the generated PDF file, including the number of pages and their sizes, using the latest Node.js document viewing API release. This code example shows how to retrieve the output PDF document information.
const viewer = new groupdocs.viewer.Viewer("resume.docx")
const viewInfoOptions = new groupdocs.viewer.ViewInfoOptions.forPdfView()
const viewInfo = viewer.getViewInfo(viewInfoOptions)
//Get number of pages and pages size
Source*
In this version of GroupDocs.Viewer for Node.js, we have resolved the issues causing high memory usage and long processing times for specific file types like spreadsheets and PST files.
Deprecated APIs
The PdfViewOptions#setJpgQuality
and PdfViewOptions#setOptimize
API members are now deprecated. Use the new PdfOptimizationOptions
class for image quality and spreadsheet optimization.
Bug Fixes
- Fixed memory consumption issues during thumbnail creation for spreadsheets.
- Addressed exceptions encountered when viewing PST and DOCX files as PDFs.
- Resolved incorrect image and character positioning in DOCX files.
- Fixed an issue preventing license renewal from working correctly.
- Improved handling of the password-protected 7z archives.
- Addressed rendering issues for presentations with 3D text effects on Linux.
- Resolved various exceptions encountered while converting specific file formats to HTML and PDF.
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting GroupDocs.Viewer for Node.js via Java 24.5 Release Notes.