Size issue after file storage by server

The file size stored in Windows was is 500 kb,
The file size stored in Linux was is 30mb.

Does the size of the storage change depending on the server version?

Please let me know if there are any options that I can solve.

Document doc = new Document();
Page page = doc.getPages().add();
PageInfo pageInfo = new PageInfo();
pageInfo.setMargin(new MarginInfo(10, 10, 10, 10));
page.setPageInfo(pageInfo);

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
HtmlFragment htmlFragment = new HtmlFragment(“…”);
htmlFragment.setHtmlLoadOptions(htmlLoadOptions);

// Set the font from the project
TextState textState = new TextState();
Font font = FontRepository.openFont(“font file”);
textState.setFont(font); // Use the font name if it’s in the project resources
htmlFragment.setTextState(textState);

page.getParagraphs().add(htmlFragment);

/*

  • I configured the page to put html of PDF 1 page content,
  • I’m going to generate a total of three page html
    */

PdfSaveOptions options = new PdfSaveOptions();
doc.save(“C:/A.pdf”, options);

@OH_JUNG_EUN

The difference in file size when storing a PDF on Windows versus Linux can be influenced by several factors, including the way the file is saved, the file system used, and the specific configurations of the server environments.

To address the issue of the significantly larger file size on Linux (30 MB compared to 500 KB on Windows), consider the following options:

  1. Optimize the PDF Document: You can optimize the PDF to reduce its size. This involves removing unnecessary data, compressing images, and eliminating redundant information. Aspose.PDF provides an Optimize method that can be used to achieve this. Here’s a simple example of how to optimize a PDF document:

    // Load the document
    Document pdfDocument = new Document("path/to/your/document.pdf");
    
    // Optimize the document
    pdfDocument.optimize();
    
    // Save the optimized document
    pdfDocument.save("path/to/your/optimized_document.pdf");
    
  2. Check Font Embedding: Ensure that fonts are embedded correctly. Sometimes, different systems handle font embedding differently, which can lead to increased file sizes. You can control font embedding settings when creating the PDF.

  3. Review Image Compression: If your PDF contains images, check the compression settings. Higher quality images can significantly increase file size. You may want to adjust the image quality or use different compression settings.

  4. File System Differences: The underlying file system on Windows and Linux can also affect how file sizes are reported. For example, certain file systems may have different overheads or block sizes that can lead to discrepancies in reported file sizes.

  5. Server Configuration: Ensure that the server configurations are consistent across both environments. Differences in libraries, versions, or settings can lead to variations in how files are processed and stored.

By following these steps, you should be able to reduce the file size on Linux and achieve a more consistent file size across different operating systems.

If you need further assistance, feel free to ask!

Sources:
[1]: Optimize PDF Document | Aspose.PDF for .NET API Reference