My current challenge involves exporting html pages to pdf using wkhtmltopdf. However, the object-fit
I am utilizing to force my images into a square shape is not functioning as expected; instead of being cropped properly, the images are stretched to fit the square box.
I have discovered that object-fit
does not work with wkhtmltopdf and have been searching for alternative solutions (refer to Object-fit: cover; alternative? ), but I am faced with the following obstacles:
- I do not have direct access to the image since it is used within a template for the background method.
- I lack an easy way to distinguish between horizontal and vertical images.
Below is the snippet of code that is currently causing me frustration as it does not work (although it functions fine in html):
.class .img-box {
width: 44px;
height: 44px;
margin-right: 10px;
display: inline-block;
vertical-align: middle;
}
.class .img-box img {
width: 100%;
height: 100%;
object-fit: cover;
}
I am reaching a point of annoyance with this issue, so if anyone has a viable solution, please share. Thank you.