Disappearance of box shadow observed after converting webpage to PDF using shortcut key 'Ctrl + P'

Currently, I am developing a webpage where I have added a box shadow to an element using the following CSS

.pill-shap {
    width: 100%;
    height: 147px;
    border-radius: 100px;
    box-shadow: 0px 5px 5px 1px rgba(49, 49, 49, 0.3);
    display: flex;
    padding: 0;
}

The box shadow appears perfectly on the screen in the browser. However, when attempting to save the webpage as a PDF by pressing Ctrl + P, the box shadow mysteriously vanishes in both the print preview and the final PDF document.

I've experimented with adjusting the box-shadow properties but unfortunately haven't had any success. How can I make sure that the box shadow remains visible in the printed PDF version?

screenshot of boxes in chrome

screenshot of boxes in print view

Any guidance or assistance would be highly appreciated!

Edit: I have verified it's not working in both Chrome and Firefox

Answer №1

Every web browser's printing engine has its unique ways of converting HTML CSS text into PDF vectors. The programmers behind Chromium have dedicated countless hours experimenting with various methods and permutations to achieve the desired results.

While I won't delve into suggesting specific styles, it is worth noting that Chromium's capabilities enable it to generate outputs that may not always align perfectly with PDF standards. Nevertheless, it gets the job done.

https://i.sstatic.net/GP34u77Q.png

Why do some websites disable text shadows when printing? The primary reason is the significant strain it puts on system resources.

A seemingly insignificant 20-byte text without fonts can consume a whopping 3MB of memory during the rendering process.

https://i.sstatic.net/6m6Ee3BM.png

I deliberately adjusted the outer boundary to illustrate why this poses a challenge in PDF production.

To create a shadow effect, multiple images at varying opacities need to be layered to mimic a realistic shadow. While compression can alleviate the issue post-construction, each additional shadow increases memory usage during both writing and reading processes.

You might think this doesn't concern you, but the use of text shadows should be avoided as it adversely affects visually impaired individuals who rely on screen readers. They interpret shadows as multiple overlapping descriptions of the same text.

HHHEEELLLLLLOOOWWW   WWWOOORRRLLLDDD

If you require a box shape with text overlay, opt for a single repeatable image serving as the background. By using the same JPEG image at maximum quality, storage efficiency increases significantly after repeated use.

This amounts to 28.4 KB (29,155 bytes), only slightly larger than an individual image with overlays of translucent colors.

https://i.sstatic.net/LJGNhYdr.png

1 img = 25,947 bytes

https://i.sstatic.net/fSOoUq6t.jpg

https://i.sstatic.net/Jf1tUkJ2.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Methods for creating overlapping background images in breadcrumbs

I am having trouble with making the breadcrumb frame overlap the inside images. I attempted using z-index: -1, but it causes the images to disappear. Please refer to the attached image for a better understanding. Thank you. .breadcrumb { margin-botto ...

`Creating a HTML Table with Checkbox Options and PHP Variables`

My HTML table has 7 columns for data pulled from an XML feed and looped through for each item. PHP variables are assigned as follows: foreach ($xml->Game as $Game) { $Date = $Game->Date; $AwayTeam = $Game->AwayTeam; // Then, I assign arrays t ...

In HTML, a text input field can be converted into a multi-line field

I need to include a multi-line text box on my HTML page. Is it possible to create one without using the Textarea tag? ...

Is there a way to apply -webkit-line-clamp to this JavaScript content using CSS?

i have a random-posts script for my blogger website <div class="noop-random-posts"><script type="text/javascript"> var randarray = new Array(); var l=0; var flag; var numofpost=10; function nooprandomposts(json){ var total = ...

jQuery slider - display unlimited images

Currently, I am encountering issues with a Flickity carousel of images. When an image/slide is clicked, a modal window opens to display a zoomed-in version of the image. The problem arises when there are more or fewer than 3 images in the slider — my cod ...

Utilizing HTML5/CSS3: Exploring the Possibility of Using Pseudo Elements to Generate Nested Tags without the Need for Javascript

I've been searching for a reliable method to achieve my goal, but haven't found one yet. However, I thought I'd reach out to the experts here to see if they have any ideas. My aim is to develop a simpler way of styling that allows users to ...

Tips for ensuring uniform button height across all cards

I am seeking advice on how to align all the buttons in different cards, despite varying text lengths, to be in the same position at the end of each card. Here is an example of what I am aiming for. Below is my HTML and CSS code: * { margin: 0px; pad ...

How can I send data to a Python script from a web application?

I have a Python script that requires 6 parameters to run, provided through the command line. python_file.py param1, param2, param3, param4, param5, param6 My goal is to pass these parameters from a web application built with Flask and Bootstrap. I want e ...

The Bootstrap 4 DatePicker is malfunctioning and not functioning properly

This is my first attempt at implementing a datepicker in my project using Bootstrap. However, I am encountering an issue where the datepicker does not display when I click on the date form. I have tried adjusting the position of the CDN URLs inside the s ...

Ensure images are aligned horizontally with their captions positioned underneath

I need help with aligning two images horizontally with text below each image. This is the code I have so far: HTML <div class="selectGame"> <div id="computerIcon" class = "icon"> <img src="http://lorempixel.com" > <span cla ...

Ensuring consistent height for the initial div across separate columns (Bootstrap 4)

Here is the HTML structure that needs adjustment: <div class="container"> <div class="row"> <div class="col-12 col-sm-12 col-lg-4 col-md-4"> <div class="title">Some title</div> <ul&g ...

I aim to utilize vanilla JavaScript in order to remove the parent element of the button being clicked when the user interacts with it

My latest project involves a meme generator that allows users to input text and images, which are then combined to create a unique 'meme'. Each meme is assigned a unique ID and features buttons for deleting the meme upon hovering. To achieve this ...

What is the reason that the larrow image is not set against a yellow background?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> </head> <style type="text/css"> *{padding:0px;margin:0px;} .strip {width:1000px;border:1px solid red;clear:none;height:10 ...

Error with Angular: URL return error - The server could not find the requested URL

Hey there, I'm encountering an issue with my website. Whenever I try to return to the previous page, I get this error message: The requested URL was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ...

Tips on extracting values from HTML utilizing a CSS selector in instances where only class and style attributes are present. The class in question is generic and may be utilized elsewhere as well

''' 29/11/2021 ''' I have a code snippet that retrieves dates from a table on a webpage, but it also fetches other values along with the date. I am looking for a way to extract just the d ...

"Utilize the CSS inheritance feature to inherit properties from parent

I am looking to add a border-bottom to a header element with the same color as its child font. Can you please provide me with the HTML code and guide me on how to proceed? <header> <div class="cblt-panel"> <header> <a ...

Reading custom CSV files in PHP, with separate echoes for specific rows and columns

I have a basic CSV file with 6 columns. EDIT: I'm having trouble finding the error in the code below, specifically with selecting a key and using it as a variable: $handle = fopen('hire_pa_amps.csv',"r"); while($values = fgetcsv($handle)) ...

Pressing the icon will trigger a top-sliding dropdown mobile menu to appear

How can I ensure my mobile dropdown menu slides in from the top when the user clicks the "header-downbar-menu" icon and slides out to the top when clicked again? Currently, the button only shows the menu but I am struggling with writing the JavaScript for ...

Footer being covered by main content div

I've been exploring web design on my own after taking a web design class. I encountered an issue while working on setting up panels for my webpage, specifically with the footer. When the main body div starts to fill up and reaches the footer, it goes ...

Scrolling up with CSS3 news headlines auto feature

It has come to my attention that the marquee tag is deprecated in html5. I am trying to create a news headline display that scrolls automatically, starting from the top news and slowly moving upwards. Once the last news item disappears, the first one shoul ...