function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shaan Khokhar 9Shaan Khokhar 9 

how to scale html table when rendering as pdf

Hi all,

I am trying to work with quote line items to generate a quote, i have around 26 columns that potentially might show at one time.

I want these columns to be all on one page, so it scales the data down. I have tried to use width but it doesn't work,

Here is my VF code:
<apex:page standardController="Quote" extensions="QLICon" standardStylesheets="false" showHeader="false" renderAs="pdf" applyBodyTag="false">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
        <apex:stylesheet value="{!$Resource.stylesheet}"/>
    </head>
    <body>
                    <div>  
                        <table id = "table" style="width:50%">
                            <thead>
                                <tr>
                                    <th>......</th>
                                </tr>
                                </thead>
                        <apex:repeat value="{!qli}" var="opp">
                            <tbody>
                                
                            <tr>
                                <td>
                                    .......
                                </td>

                            </tr>
                        </tbody>
                    </apex:repeat> 
                    </table>
                </div>  
    </body>
</apex:page>

css:
​​​​​​​  #table{
    max-width: 2480px;
    width:100%;
  }
  #table td{
    width: auto;
    overflow: hidden;
    word-wrap: break-word;
  }
Best Answer chosen by Shaan Khokhar 9
AbhishekAbhishek (Salesforce Developers) 
Shaan,

There are multiple developer blogs related to your query,

https://developer.salesforce.com/forums/?id=9060G000000Xj7wQAC

https://salesforce.stackexchange.com/questions/250361/repeat-html-table-in-render-as-pdf-vf-page

https://salesforce.stackexchange.com/questions/22191/issue-with-vf-pdf

Try the suggestions based on it.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.

All Answers

AbhishekAbhishek (Salesforce Developers) 
Shaan,

There are multiple developer blogs related to your query,

https://developer.salesforce.com/forums/?id=9060G000000Xj7wQAC

https://salesforce.stackexchange.com/questions/250361/repeat-html-table-in-render-as-pdf-vf-page

https://salesforce.stackexchange.com/questions/22191/issue-with-vf-pdf

Try the suggestions based on it.

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
This was selected as the best answer
Vishesh kant Aggarwal 17Vishesh kant Aggarwal 17

Hi Shaan, 

I am also facing the exact issue i have to display 22 columns in my vf page and render it as PDF. Can you please tell me what helped you in this?