[SalesForce] Visualforce PDF not showing styles in Community

I have a visualforce page which renders PDF OK when viewing in Salesforce. However, the same page doesn't renders the styles in PDF when viewing through a Salesforce community site. Any idea what is going wrong with the PDF generation from community site?? The page is given below:

<apex:page renderAs="pdf" applyBodyTag="false" 
    showHeader="false" sidebar="false" standardStylesheets="false" >
    <head>
        <style>
            .grad{
            Width:600px;
            Height:600px;
            background: #0098d5; /* Old browsers */

            }
            #tst{
            color:red;
            font-size:60pt;
            }
        </style>
    </head>
    <body>
        <div class="grad">
            <span id="tst"> Hello Salesforce</span>
        </div>
    </body>
 </apex:page>

Thanks.

Best Answer

Add applyHtmlTag="false" to your page and enclose the content of your page in html tags.

Issue is because, when you see the page as a community user. It adds style to your HTML: <html style="display:none !important;">

Just tried in my dev org and it worked:

<apex:page renderAs="pdf" applyBodyTag="false"
    applyHtmlTag="false" 
    showHeader="false" sidebar="false" standardStylesheets="false" >
    <html>
    <head>
        <style>
            .grad{
            Width:600px;
            Height:600px;
            background: #0098d5; /* Old browsers */

            }
            #tst{
            color:red;
            font-size:60pt;
            }
        </style>
    </head>
    <body>
        <div class="grad">
            <span id="tst"> Hello Salesforce</span>
        </div>
    </body>
    </html>
 </apex:page>