You need to sign in to do that
Don't have an account?
Sudhan Kanade
PDF generation failed, Check the page markup is valid. Even though visualforce page is working fine.
I am trying to display product cross reference table for competitor products and also I need to display the table in transposed format. Column should be the rows and rows should be the column.
e.g
Categories Product 1 Product 2 Product 3 Product 4
Name xyz abc efg pqr
Code 007 339 333 444
Price $10 $12 $15 $9
Now the each product information is stored as a custom object. I have a apex class which basically fetches the data from these custom objects. My problem is that I am able to display the data in visualforce page, but when I try to do renderAs="pdf" its giving me "PDF generation failed. Check the page markup is valid." Somebody take a look at what is going wrong with the markup and why its not able to convert the visualforce page into pdf ?
e.g
Categories Product 1 Product 2 Product 3 Product 4
Name xyz abc efg pqr
Code 007 339 333 444
Price $10 $12 $15 $9
Now the each product information is stored as a custom object. I have a apex class which basically fetches the data from these custom objects. My problem is that I am able to display the data in visualforce page, but when I try to do renderAs="pdf" its giving me "PDF generation failed. Check the page markup is valid." Somebody take a look at what is going wrong with the markup and why its not able to convert the visualforce page into pdf ?
<apex:page controller="ProductCrossRefWrapperController" tabstyle="Account" renderAs="pdf"> <apex:pageBlock title="PRODUCT CROSS REFERENCE CHART"> <table class="list" border="0" cellpadding="0" cellspacing="0"> <tr class="headerRow"> <apex:repeat value="{!headWrap.values}" var="heading"> <th class="headerRow "> {!heading} </th> </apex:repeat> </tr> <apex:repeat value="{!rowWrappers}" var="row"> <tr> <apex:variable var="index" value="{!0}" /> <apex:repeat value="{!row.values}" var="value"> <apex:outputPanel rendered="{!(index==0)}"> <th class="headerRow "> {!value} </th> </apex:outputPanel> <apex:outputPanel rendered="{!(index!=0)}"> <td> {!value} </td> </apex:outputPanel> <apex:variable var="index" value="{!index+1}" /> </apex:repeat> </tr> </apex:repeat> </table> </apex:pageBlock> </apex:page>
<apex:outputPanel generates a <span> tag which means that trs and tds when rendered will be surrounded by a <span> tag.
I.e. : <span><td>text</td></span>
This is a invalid markup. Moreover, if you get no results in any of your iterations it will not generate the html properly and you will get the same error as well. I recommend you to use apex:pageBlockTable, it will be easier to get the desired result or if you are looking for a non-styled table you can opt for using apex:dataTable
Find out more here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm (http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm" target="_blank)
http://www.salesforce.com/docs/developer/pages/Content/pages_compref_dataTable.htm (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_dataTable.htm" target="_blank)
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
<apex:outputPanel generates a <span> tag which means that trs and tds when rendered will be surrounded by a <span> tag.
I.e. : <span><td>text</td></span>
This is a invalid markup. Moreover, if you get no results in any of your iterations it will not generate the html properly and you will get the same error as well. I recommend you to use apex:pageBlockTable, it will be easier to get the desired result or if you are looking for a non-styled table you can opt for using apex:dataTable
Find out more here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm (http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm" target="_blank)
http://www.salesforce.com/docs/developer/pages/Content/pages_compref_dataTable.htm (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_dataTable.htm" target="_blank)
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Thanks for explaining me about the boilerplate code being added with outputPanel and totally that makes sense when it tries to generate a PDF file.
I had earlier used pageBlockTable / dataTable but the requirement for me is to display the records column-wise and not row-wise (transposing column with rows). I tried various options with these two components, but could not succeed in creating even a prototype. So finally got some pointers from other thread on this forum and used apex:repeat which allowed me to display data column-wise instead.
Do you know if I can display transposed table in either of these two options.
Once again thanks for replying back to my questions.
Regards,