PdfConfiguration class
The parameters pageSize, pageFit, dpi and resamplingMethod interact in a complex way
when adding bitmap images (JPEG, PNG, or raw) to the PDF.
There are three cases to consider:
pageSizeisCUSTOM: in this casedpiis used as the conversion ratio to calculate both the physical page and image sizes in inches from the bitmap dimensions.resamplingMethodis ignored.pageSizeis notCUSTOMANDpageFitisNONE: in this casedpiis used as the conversion ratio to calculate only the physical image size in inches from the bitmap dimensions. The image is centered onto the page.resamplingMethodis ignored.pageSizeis notCUSTOMANDpageFitis notNONE: in this case the page has a pre-determined physical size and we want to stretch the image to fit the page in one of the ways described bypageFit. The image DPI is automatically calculated for each image from the given physical page size, page fit setting and image dimensions. There are two sub-cases to consider: a.resamplingMethodis NONE OR the calculated DPI is less than or equal todpi: in this case the image is added to the PDF without resampling, which means that the image rectangle is simply rescaled to fit into the page as specified bypageFitandpageSize. b.resamplingMethodis not NONE AND the calculated DPI is greater thandpi: in this case the bitmap of the image is resampled to matchdpiusing the selected method before adding it to the PDF. This will result in a bitmap that is smaller than the original image and hence, the resulting PDF will be smaller in size.
Constructors
- PdfConfiguration({PdfAttributes? attributes, PageSize pageSize = PageSize.A4, PageDirection pageDirection = PageDirection.PORTRAIT, PageFit pageFit = PageFit.FIT_IN, int dpi = 72, int jpegQuality = 80, ResamplingMethod resamplingMethod = ResamplingMethod.NONE})
-
PdfConfiguration.fromJson(Map<
String, dynamic> json) -
factory
Properties
- attributes ↔ PdfAttributes
-
Attributes.
getter/setter pair
- dpi ↔ int
-
The
dpiparameter has two different meanings depending on the value ofpageSizeandpageFit. If pageSize is CUSTOM or pageFit is NONE, thendpiis the conversion ratio used to convert from units of pixels to physical inches when adding bitmap images (JPEG, PNG, or raw) to the PDF. Otherwise, ifresamplingMethodis not NONE, then the image is downscaled if necessary (if the image after being fit to the page has a higher calculated DPI thandpi) to matchdpibefore adding it to the PDF. Otherwise, the setting is ignored and the calculated image DPI is used instead.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- jpegQuality ↔ int
-
JPEG quality for images.
Applies if an image is added as a cv::Mat and therefore needs to be encoded.
Also applies if
resamplingMethodnot NONE and the image being added needs to be downscaled. Otherwise, when adding JPEG files to the PDF, the files are copied directly into the PDF and not re-encoded, which is many times faster and also preserves the quality of the original.getter/setter pair - pageDirection ↔ PageDirection
-
Page direction.
getter/setter pair
- pageFit ↔ PageFit
-
How to fit the image into the page. Only used if
pageSizeis notCUSTOM. The image can either be stretched to fill the page, in one of three ways, or centered on the page without stretching.getter/setter pair - pageSize ↔ PageSize
-
Physical size of the page. If CUSTOM, the page size will be set as the image size at given dpi.
getter/setter pair
- resamplingMethod ↔ ResamplingMethod
-
Resampling method.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
{ToJsonConfiguration? config}) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited