PdfImage.jpegStream constructor

PdfImage.jpegStream(
  1. PdfDocument pdfDocument, {
  2. required int width,
  3. required int height,
  4. required int length,
  5. required PdfImageStreamWriter write,
  6. PdfImageOrientation orientation = PdfImageOrientation.topLeft,
})

Creates a JPEG image whose encoded bytes are supplied only when the PDF is serialized. This avoids retaining a copy of the JPEG in the document object graph.

The supplied bytes must be an RGB JPEG with the stated dimensions. The callback is synchronous because PDF object serialization is synchronous. Streamed JPEGs cannot be used with document encryption because encryption requires the complete stream contents to be available as a byte array.

Implementation

factory PdfImage.jpegStream(
  PdfDocument pdfDocument, {
  required int width,
  required int height,
  required int length,
  required PdfImageStreamWriter write,
  PdfImageOrientation orientation = PdfImageOrientation.topLeft,
}) {
  final image = PdfImage._(
    pdfDocument,
    width,
    height,
    orientation,
    streamLength: length,
    streamWriter: write,
  );
  image.params['/BitsPerComponent'] = const PdfNum(8);
  image.params['/Name'] = PdfName(image.name);
  image.params['/Intent'] = const PdfName('/RelativeColorimetric');
  image.params['/Filter'] = const PdfName('/DCTDecode');
  image.params['/ColorSpace'] = const PdfName('/DeviceRGB');
  return image;
}