Skip to content

Commit 584e5f6

Browse files
committed
Update the readme about bitmap form of PDF
1 parent b861de1 commit 584e5f6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ imageView.sd_setImage(with: url)
8686

8787
For firmware which is below iOS/tvOS 11+, `UIImage` && `UIImageView` does not support vector image rendering. Even you can add PDF image in Xcode Asset Catalog, it was encoded to bitmap PNG format when compiled but not support runtime scale.
8888

89-
For `UIImageView`, we will only parse PDF with a fixed image size (from the PDF cropBox information). But we also support you to specify a desired size during image loading using `PDFImageSize` context option. And you can specify whether or not to keep aspect ratio during scale using `PDFImagePreserveAspectRatio` context option.
89+
For `UIImageView`, we will only parse PDF with a fixed image size (from the PDF cropBox information). But we also support you to specify a desired size during image loading using `.pdfImageSize` context option. And you can specify whether or not to keep aspect ratio during scale using `.pdfImagePreserveAspectRatio` context option.
90+
91+
Note: Even you're on iOS/tvOS 11+, you can also use the `.pdfPrefersBitmap` context option to force us to generate the bitmap form of PDF, instead of the vector format. This can be used for some general image processing code.
9092

9193
+ Objective-C
9294

@@ -95,7 +97,7 @@ SDImagePDFCoder *PDFCoder = [SDImagePDFCoder sharedCoder];
9597
[[SDImageCodersManager sharedManager] addCoder:PDFCoder];
9698
UIImageView *imageView;
9799
CGSize PDFImageSize = CGSizeMake(500, 500);
98-
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextPDFImageSize : @(PDFImageSize)];
100+
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextPDFPrefersBitmap : @YES, SDWebImageContextPDFImageSize : @(PDFImageSize)];
99101
```
100102
101103
+ Swift
@@ -105,14 +107,14 @@ let PDFCoder = SDImagePDFCoder.shared
105107
SDImageCodersManager.shared.addCoder(PDFCoder)
106108
let imageView: UIImageView
107109
let PDFImageSize = CGSize(width: 500, height: 500)
108-
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.pdfImageSize : PDFImageSize])
110+
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.pdfPrefersBitmap : true, .pdfImageSize : PDFImageSize])
109111
```
110112

111113
## Export PDF data
112114

113115
`SDWebImagePDFCoder` provide an easy way to export the PDF image generated from framework, to the original PDF data.
114116

115-
Note: For firmware which is below iOS/tvOS 11+, UIImage does not support PDF vector image as well as exporting.
117+
Note: For firmware which is below iOS/tvOS 11+, UIImage does not support PDF vector image as well as exporting. The bitmap form of PDF does not support PDF data export as well.
116118

117119
+ Objective-C
118120

0 commit comments

Comments
 (0)