/chrome/community?hl=en
This content is likely not relevant anymore. Try searching or browse recent questions.
-
9/10/19
PDF documents not viewed in 100% of browser height 0 Recommended Answers 12 Replies 44 Upvotes
1 Recommended Answer
$0 Recommended Answers
We have started getting reports today that users is not showed the full PDF file in Chrome.
This happens to some of our uses but not all of them.

We who get the problem is viewing the PDF file in a view of150px of height (But our browser window is more then 1000px).
It seems like the internal CSS rule in Google Chrome is ignored.

The version Im running is: Version 76.0.3809.132 (Officiell version) (64 bitar) on Windows 10.

Not all people with the same version of chrome and Windows is getting this error.

Screenshot 1 (showing problem in Google Chrome 76):


Screenshot 2 (showing working in Google Chrome 76):
All Replies (12)
9/10/19
I am experiencing this issue as well. What's strange is that the PDFs are full height on my test server but not in production. The code is exactly the same on both servers.
marked this as an answer
Helpful?
9/11/19
We have run into this also. While it works on my machine OSX 10.14.6, chrome:  76.0.3809.132 (Official Build) (64-bit). There are other OSX computers where it is not working.  Disabling extensions doesn't help.
marked this as an answer
Helpful?
-
9/11/19
we seem to get CSP errors (In Console window) when this happens, is it the same for you?
marked this as an answer
Helpful?
9/11/19
I do think it is a CSP issue. I just realized why it works on my test server but not production. On the test server I do not have CSP enabled. Apparently Chrome is using inline CSS to style the PDF.

I have created a workaround where if the user is using Chrome, instead of linking directly to the PDF file, I link to a page where the PDF is embedded as an <object>, and then I use jQuery to style the object.

$(function() {
    
    //style our html, body, and object elements
    $("html").css("height", "100%");
    $("body").css({"height": "100%", "margin": "0", "overflow": "hidden"});
    $("object").css({"height": "100%", "width": "100%"});
    
    //check if the pdf has loaded yet
    checkPdf();

});

function checkPdf() {
    var checkPdf = setInterval(function() {
        if ($("object").length) {
            var body = $($($("object")[0].contentDocument).children("html")[0]).children("body");
            if (body.length) {
                if (body[0].children.length) {
                    
                    //the pdf has loaded, now style it!
                    stylePdf();
                    
                    clearInterval(checkPdf);
                }
            }
        }
    }, 1);
}

function stylePdf() {
    var html = $($("object")[0].contentDocument).children("html")[0];
    $(html).css({"height": "100%", "overflow": "hidden"});
    $($(html).children("body")[0]).css({"height": "100%", "margin": "0"});
}
Last edited 9/11/19
marked this as an answer
Helpful?
9/11/19
We have recently added csp protections, but I get the CSP errors on machines where it works and where it doesn't work. So I didn't think it was related.
marked this as an answer
Helpful?
10/19/19
Same problem running Chrome Version 77.0.3865.90 (Official Build) (64-bit) in Ubuntu 18.04.3 LTS. I have to either manually download PDFs or change this setting: https://support.google.com/chrome/answer/6213030
marked this as an answer
Helpful?
10/24/19
Hello,
I have the same problem too. 

We have the server using Server Manager with IIS by Microsoft. 

And when I try to open the pdf file from this server in Chrome 77.0.3865, then the window has a height 150 px instead of full size.
Last edited 10/28/19
marked this as an answer
Helpful?
11/1/19
Hi, I'm facing same issues. We are running an Avaya AACC server with multimedia contact center and when the agents try to open the e-mail attachments already stored on the servers HDD (its via hyperlink such as: http://10.0.0.240/inboundattachment/2019-010/TestRabbit620557004516.pdf ) It opens in 150px window. But When I try to open the same attachment with a "local path" such as:  file:///G:/Avaya/Contact%20Center/Email%20Attachments/Inbound/2019-010/TestRabbit620557004516.pdf  then it opens just fine, regardless of the Chrome version (tested 77, 78, even the latest Version 78.0.3904.87 (Official Build) (64-bit) the behavior is still the same. 
Can anyone please advise where the problem could be and how to resolve this? Other than set up the agents default web browser to be something else the Chrome :) or setting to download PDF instead of opening it directly in Chrome. 
Thank you
marked this as an answer
Helpful?
11/6/19
For us, if we open a PDF as the root of a web page, then it displays fullscreen. However, if we try to open it within an iframe, it doesn't take up the full available height. Digging into the outputted code, it appears that the `html` tag on the html document that appears inside the `iframe` does not have `height:100%`. If I manually change that in the JS console, then it takes up the full height in the iframe.

What I can't quite understand is that in the non-iframe version, the HTML output appears to be different. For example, when displayed in an iframe, the `html` tag has no attributes. But when displayed as the root of a document, it's got `dir="ltr" lang="en"`. Maybe those differences are red herrings, though.
marked this as an answer
Helpful?
11/14/19
You can also relax your CSP for styles by adding style-src 'self' 'unsafe-inline';
"content_security_policy": "default-src 'self' style-src 'self' 'unsafe-inline';"
This will allow you to keep using inline style in your extension.
marked this as an answer
Helpful?
11/25/19
I can confirm that for us this was a CSP issue.

Would be nice to have an interim fix that doesn't include using unsafe-inline for the whole site.
marked this as an answer
Helpful?
11/26/19
Just to confirm what has already been said. This definitely is a CSP problem. Probably one that you encounter after implementing CSP or changing your CSP. And, you'll probably only notice it in production, since on development most likely you have CSP disabled.

You can also tell it's CSP by what your browser console is telling you. To be honest it took me longer to actually see that console message than I care to admit.
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-qwerty...='), or a nonce ('nonce-...') is required to enable inline execution.
I can confirm that adding the 'unsafe-inline' to the style-src csp, fixes the problem.

@NeilHickman. You don't need to include 'unsafe-inline' for the whole site. You can use it just for a couple of routes where pdf's are requested. Here's how I've implemented it with Helmet and ExpressJS.

app.use(
    helmet({
        hsts: {
            maxAge: ONE_YEAR_IN_SECONDS,
            includeSubDomains: true,
            preload: true,
        },
        // ...
        contentSecurityPolicy: {
            directives: {
                // ...
                styleSrc: [
                    `'self'`,
                    (req, res) =>
                        req.url === '/route-to-some-pdf'
                            ? `'unsafe-inline'` // <---
                            : `'nonce-${res.locals.nonce}'`,
                ],
            },
        },
        referrerPolicy: { policy: 'same-origin' },
    })
);
marked this as an answer
Helpful?
This question is locked and replying has been disabled.
Discard post? You will lose what you have written so far.
Write a reply
10 characters required
Failed to attach file, click here to try again.
Discard post?
You will lose what you have written so far.
Personal information found

We found the following personal information in your message:

This information will be visible to anyone who visits or subscribes to notifications for this post. Are you sure you want to continue?

A problem occurred. Please try again.
Create Reply
Edit Reply
Delete post?
This will remove the reply from the Answers section.
Notifications are off
Your notifications are currently off and you won't receive subscription updates. To turn them on, go to Notifications preferences on your Profile page.
Report abuse
Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence. When you submit a report, we'll investigate it and take the appropriate action. We'll get back to you only if we require additional details or have more information to share.

Go to the Legal Help page to request content changes for legal reasons.

Reported post for abuse
Unable to send report.
This reply is no longer available.
/chrome/threads
//accounts.google.com/ServiceLogin
You'll receive email notifications for new posts at
Unable to delete question.
Unable to update vote.
Unable to update subscription.
You have been unsubscribed
Deleted
Unable to delete reply.
Removed from Answers
Marked as Recommended Answer
Removed recommendation
Undo
Unable to update reply.
Unable to update vote.
Thank you. Your response was recorded.
Unable to undo vote.
Thank you. This reply will now display in the answers section.
Link copied
Locked
Unlocked
Unable to lock
Unable to unlock
Pinned
Unpinned
Unable to pin
Unable to unpin
Marked
Unmarked
Unable to mark
Reported as off topic
/chrome/profile/0?hl=en