0

I am able to use the visualforce page as a button totally fine to convert some information from a custom object into PDF format, but my users get the chrome error "This content is blocked. Contact the site owner to fix the issue. I have tried changing their browser settings to no avail and I have looked for the salesforce session settings described in this post (Cookie error with embedded VisualForce page in Chrome) - Require secure connections (HTTPS), Require secure connections (HTTPS) for all third-party domains. I can't find them. I will include my code below but I believe this is a settings issue. Some text has been changed so as not to identify the company and the code is currently not pretty because I have been messing with it to try and fix this issue.


<apex:page showHeader="false" applyBodyTag="false" standardController="Merchandise_Order__c" renderAs="pdf">
<head>
        <style>
            body { font-family: 'serif'; }
        </style> 
</head>
<body>
        <div style="display:inline-block;position:relative;right:40px;bottom:25px">
<apex:image url="{!$Resource.CompanyLogo}" width="200" height="100" alt="Text"/>
        </div>
        <div style="display:inline-block;position:relative;left:225px;bottom:25px">
       <table border="solid;.5">
           <tr>
               <td>Invoice Date</td>
               <td>{!Merchandise_Order__c.Invoice_Date__c}</td>
           </tr>
           <tr>
               <td>Invoice Number</td>
               <td>{!Merchandise_Order__c.Name}</td>
           </tr>
           <tr>
               <td>Account ID</td>
               <td>{!Merchandise_Order__c.Contact__r.Account.ID}</td>
           </tr>
            </table>
        </div>

<div style="position:relative;top:25px">
  <table border="solid;1px" width="40%">
      <tr>
        <th>Remit To</th>
      </tr>
      <tr>
          <td>
              Company<br/>
              Attn: Employee<br/>
              Address <br/>
              Address<br/>
          </td>
      </tr>
    </table>  
    </div>
    <div style="position:relative;top:50px">
  <table border="solid;1px" width="100%" style="position:relative">
    <tr>
      <th>Description</th>
      <th>Invoice Amount</th>
    </tr>
    <tr>
      <td>Men's Tee Quantity: {!FLOOR(Merchandise_Order__c.Men_s_Tee_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Men_s_Tee_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Women's Tee Quantity: {!FLOOR(Merchandise_Order__c.Women_s_Tee_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Women_s_Tee_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Men's Hood Quantity: {!FLOOR(Merchandise_Order__c.Men_s_Hood_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Men_s_Hood_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Women's Piper Hood Quantity: {!FLOOR(Merchandise_Order__c.Women_s_Hood_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Women_s_Hood_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Men's Dated Zone Navy Quantity: {!FLOOR(Merchandise_Order__c.Men_s_Dated_Zone_Navy_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Men_s_Dated_Zone_Navy_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Men's Dated Zone White Quantity: {!FLOOR(Merchandise_Order__c.Men_s_Dated_Zone_White_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Men_s_Dated_Zone_White_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Towel Quantity: {!FLOOR(Merchandise_Order__c.Towel_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Towel_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Official Logo Eco Tote Quantity: {!FLOOR(Merchandise_Order__c.Official_Logo_Eco_Tote_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Official_Logo_Eco_Tote_Subtotal__c}</td>
    </tr>
    <tr>
      <td>Official Logo Water Bottle Quantity: {!FLOOR(Merchandise_Order__c.Official_Logo_Water_Bottle_Quantity__c)}</td>
        <td>{!Merchandise_Order__c.Official_Logo_Water_Bottle_Subtotal__c}</td>
    </tr>
    <tr>
        <td>Tax</td>
        <td>{!Merchandise_Order__c.Tax__c}</td>
      </tr>
    <tr>
        <td>Total Amount Due</td>
        <td>${!Merchandise_Order__c.Total_Amount__c}</td>
      </tr>
  </table>
    </div>
  <div style="position:relative;top:50px"> 
    <p>
        <strong>ALL SALES ARE FINAL</strong>
    </p>
    <p>
        <strong>Payment must be received before delivering merchandise</strong>
    </p>
    <p>
        <strong>Please note that the Company only accepts checks</strong>
    </p>
    <p align="center">
        For questions regarding your invoice, please call (XXX) XXX-XXXX.
    </p>
    <hr width="75%" align="center"/>
    <p align="center">
        <i>Please Remit This Portion With Payment</i>
    </p>
    <table width="100%">
        <tr>
        <th>Please Make Check Payable to:</th>
        <th></th>
        </tr>
        <tr>
          <td>Company, Inc.</td>
          <td>Account ID: {!Merchandise_Order__c.Contact__r.Account.ID}</td>  
        </tr>
        <tr>
          <td>Address</td>
          <td>Customer Name: {!Merchandise_Order__c.Contact__r.FirstName} {!Merchandise_Order__c.Contact__r.LastName}</td>
        </tr>
        <tr>
          <td>Address</td>
          <td>Invoice Number: {!Merchandise_Order__c.Name}</td>
        </tr>
        <tr>
          <td></td>
          <td>Invoice Date: {!Merchandise_Order__c.Invoice_Date__c}</td>
        </tr>
        <tr>
        <td></td>
        <td>Due Date: Upon Receipt</td>
        </tr>
    </table>
    <p align="right">
        Total Amount Due: ${!Merchandise_Order__c.Total_Amount__c}
    </p>
        </div>

    <div style="position:relative;top:100px">
    <table width="100%" border="solid;1px">
    <tr>
      <th>Size Summary</th>
      <th></th>
    </tr>
    <tr>
      <td>Men's Tee:</td>
      <td>{!FLOOR(Merchandise_Order__c.Men_s_Tee_Small__c)} Small,&nbsp; <apex:outputField value="{!Merchandise_Order__c.Men_s_Tee_Medium__c}"/> Medium,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Tee_Large__c)} Large,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Tee_X_Large__c)} X-Large,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Tee_XX_Large__c)} XX-Large
      </td>
    </tr>
    <tr>
      <td>Women's Tee:</td>
      <td>{!FLOOR(Merchandise_Order__c.Women_s_Tee_Small__c)} Small,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Tee_Medium__c)} Medium,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Tee_Large__c)} Large,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Tee_X_Large__c)} X-Large,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Tee_XX_Large__c)} XX-Large
      </td>
    </tr>
    <tr>
      <td>Men's Call Back Club Hood:</td>
      <td>{!FLOOR(Merchandise_Order__c.Men_s_Hood_Small__c)} Small,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Hood_Medium__c)} Medium,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Hood_Large__c)} Large,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Hood_X_Large__c)} X-Large,&nbsp; {!FLOOR(Merchandise_Order__c.Men_s_Hood_XX_Large__c)} XX-Large
      </td>
    </tr>
    <tr>
      <td>Women's Hood:</td>
      <td>{!FLOOR(Merchandise_Order__c.Women_s_Hood_Small__c)} Small,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Hood_Medium__c)} Medium,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Hood_Large__c)} Large,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Hood_X_Large__c)} X-Large,&nbsp; {!FLOOR(Merchandise_Order__c.Women_s_Hood_XX_Large__c)} XX-Large
      </td>
    </tr>
    </table>
    </div>
</body>
</apex:page>

2
  • 1
    Hi, welcome to SFSE. Please take a tour and read How to Ask. Could you please review your code as it looks like the formatting is broken? Also, the source might have been truncated, as I don't see the closing tag for apex:page. Jun 29, 2021 at 13:59
  • I've reviewed the code and I think I've fixed it, thank you for pointing that out. Is there anything else about the question that doesn't fit the How to Ask guide?
    – pmoore
    Jun 29, 2021 at 14:14

1 Answer 1

0

This can happen if the user's browser isn't set up to render PDFs directly in the browser. In Google Chrome under Privacy and security > Site settings > PDF documents they have it set to "Download PDFs" instead of "Open PDFs in Chrome".

If you want the file to always download to the user's machine and not display in the browser, you can try the suggestion from this Salesforce developer post which suggests adding a page in the middle that explicitly tells the browser that the response type will be a PDF file to download. https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS

<apex:page id="MainPage"
    showHeader="false" 
    cache="true"
    contentType="application/x-pdf#Here-is-your-filename.pdf">

    <!-- Here comes another page with a content to be converted to PDF -->
    <apex:include pageName="PageThatGeneratesPdf"/>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .