Class PdfObjectSizeCalculationUtil

java.lang.Object
com.itextpdf.pdfoptimizer.util.PdfObjectSizeCalculationUtil

public final class PdfObjectSizeCalculationUtil extends Object
Util class for calculating the size of an PdfObject in bytes, which it will take in PDF.
  • Method Details

    • calculateImageStreamLengthInBytes

      public static long calculateImageStreamLengthInBytes (com.itextpdf.kernel.pdf.xobject.PdfImageXObject imageXObject, com.itextpdf.kernel.pdf.PdfDocument pdfDocument)
      Calculates the length of an PdfImageXObject stream in bytes, which it will take in PDF.

      Some important notes:

      • This method doesn't change the original PdfImageXObject which passed to this method, because a copy is being created.
      • The length of an PdfImageXObject stream is calculated without taking into account internal fields.
      Parameters:
      imageXObject - an image whose stream length in bytes will be calculated
      pdfDocument - the PDF document into which, as a result, the original imageXObject will be written
      Returns:
      the passed image stream length in bytes