TIF to PDFA conversion using Aspose JAVA API is giving big filesize output(pdfa)

Hi Team,

When I try to convert a multi-page TIFF file to PDF/A using Aspose Java code, the input TIFF file size is 174 KB, but the generated PDF/A file size is 441 KB. The output file is almost four times larger than the original. We need the PDF/A file size to be equal to or smaller than the TIFF file size. Below is the code I’m using for the conversion. Can you please help us to compress the pdfa with best quality.

I am using 25.5 version jar files.

import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.PdfOptions;
import com.aspose.pdf.ConvertErrorAction;
import com.aspose.pdf.Document;
import com.aspose.pdf.License;
import com.aspose.pdf.PdfFormat;

public class TiffToPdfAConverter {
    public static void main(String[] args) throws Exception {
    	 License pdfLicense = new License();
         pdfLicense.setLicense("C:\\Users\\ayyappa.reddy\\Downloads\\Aspose.Total.Product.Family 2.lic"); // your license path
         System.out.println(" Aspose license applied successfully.");
    	String inputFile = "F:\\DRS\\OneDrive Success\\20191226000349\\20191226000349.tif";
        String tempPdf = "F:\\DRS\\OneDrive Success\\20191226000349\\20191226000349_temp.pdf";
        String outputPdfA = "F:\\DRS\\OneDrive Success\\20191226000349\\20191226000349_actual.pdf";

        // Step 1: Convert TIFF  normal PDF
        try (Image image = Image.load(inputFile)) {
            PdfOptions options = new PdfOptions();
            image.save(tempPdf, options);
        }
    	// Open document
    	Document document = new Document(tempPdf);

    	// Convert to PDF/A compliant document
    	// During conversion process, the validation is also performed
    	document.convert("F:\\DRS\\OneDrive Success\\20191226000349\\" + "log.xml", PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);

    	// Save output document
    	document.save(outputPdfA);
    	document.close();

    	
    }
}

Regards,
Ayyappa.

@ayyappa.reddy

Summary
When a multi‑page TIFF is saved as PDF/A the library embeds each page as a full‑resolution raster image and adds PDF/A‑required objects (ICC profile, XMP metadata, etc.). If image compression is not enabled, the resulting PDF/A can be several times larger than the original TIFF.

Why it happens

  1. Image handlingImage.save(..., new PdfOptions()) creates a PDF where every TIFF page is stored as an image. Without explicit compression the image data are written uncompressed (or with a low‑efficiency compression).
  2. PDF/A requirements – PDF/A conversion forces the embedding of an ICC profile and additional metadata, and may convert the colour space to RGB, which also increases the file size.
  3. Default settings – In the current Aspose.Imaging/Aspose.PDF releases the compression‑related properties of PdfOptions and PdfSaveOptions are disabled unless you turn them on.

What to do next

  1. Compress the images while creating the intermediate PDF
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.PdfOptions;
import com.aspose.imaging.imageoptions.PdfImageCompression;

// license initialization omitted for brevity

String tiffPath = "F:/DRS/OneDrive Success/20191226000349/20191226000349.tif";
String tempPdf = "F:/DRS/OneDrive Success/20191226000349/20191226000349_temp.pdf";

try (Image img = Image.load(tiffPath)) {
PdfOptions pdfOpts = new PdfOptions();
// JPEG compression works well for colour scans; use CCITT for pure B&W
pdfOpts.setImageCompression(PdfImageCompression.Jpeg);
pdfOpts.setJpegQuality(80); // 0‑100, higher = better quality, larger size
pdfOpts.setResolution(150); // down‑sample high‑DPI scans
pdfOpts.setCompress(true); // enable PDF stream compression
img.save(tempPdf, pdfOpts);
}
  1. Convert the intermediate PDF to PDF/A with additional optimisation
import com.aspose.pdf.Document;
import com.aspose.pdf.PdfAConformanceLevel;
import com.aspose.pdf.PdfAConversionOptions;
import com.aspose.pdf.PdfSaveOptions;
import com.aspose.pdf.PdfImageCompression;
import com.aspose.pdf.PdfColorDepth;

String outputPdfA = "F:/DRS/OneDrive Success/20191226000349/20191226000349_actual.pdf";

// Load the PDF created in step 1
Document doc = new Document(tempPdf);

// Set up PDF/A conversion options
PdfAConversionOptions aOpts = new PdfAConversionOptions();
aOpts.setConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
// If ICC profile size is a concern, you can disable embedding:
// aOpts.setEmbedIccProfile(false);

// Convert to PDF/A (the conversion is performed in‑place)
doc.convert(aOpts);

// Optimise the final PDF/A when saving
PdfSaveOptions saveOpts = new PdfSaveOptions();
saveOpts.setCompress(true); // overall stream compression
saveOpts.setImageCompression(PdfImageCompression.Jpeg);
saveOpts.setJpegQuality(80);
saveOpts.setRemoveUnusedObjects(true); // strip objects not needed for PDF/A
saveOpts.setOptimizeImage(true); // down‑sample if resolution > 150 dpi
saveOpts.setColorDepth(PdfColorDepth.Depth8); // 8‑bit colour is sufficient for most scans

doc.save(outputPdfA, saveOpts);
doc.close();
  1. Additional size‑reduction techniques
  • Down‑sample further – If 150 dpi is more detail than required, set pdfOpts.setResolution(100) (or lower) before step 1.
  • Use a B&W‑specific compression – For monochrome documents, replace the JPEG settings with
pdfOpts.setImageCompression(PdfImageCompression.Ccitt4);

which yields very small files.

  • Strip unnecessary metadata – After conversion you can remove XMP metadata:
doc.getInfo().setMetadata(null);
  • Upgrade the library – Later Aspose.PDF releases introduce extra flags in PdfAConversionOptions (e.g., disabling ICC profile embedding) that can shave a few kilobytes.
  1. Validate the result
  • Open the generated PDF/A in a PDF/A validator (such as the free veraPDF tool) to confirm compliance.
  • Compare the file size with the original TIFF; with the settings above the PDF/A is typically comparable to or smaller than the source image for standard scanned documents.

If the file is still larger than desired, you can lower the JPEG quality (e.g., to 60) or reduce the resolution further, keeping an eye on the visual quality that meets your requirements.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

Now i am getting the (
import com.aspose.imaging.imageoptions.PdfImageCompression)package reference errors . Can you please tell me how to enable the properties of PdfOptions and PdfSaveOptions. I need proper steps to achieve this.

Can you Provide the response ASAP.