You need to sign in to do that
Don't have an account?
Opportunity Name and Opportunity.Account.Address is not displaying in the PDF
My Requirement is to create
VF Page: PDF that should have Opportunity Name, Opportunity.Account Billing Address in the header, Body should have Table with Opportunity Products, Footer should have Organization details.
Button in the Opportunity view page that will open the above pdf (pdf will have the values of the above fields of each record).
I'm able to acheieve this, but still has a problem.
My Problem is few records are not displaying the details of opportunity name, account billing address (these records still has the opportunity name, Account billing address etc). Can anyone about this..like account has the content, opportunity has the content too, but not displaying the content.
Anilt just remove you code once put the code whic i have written below......
<apex:page standardController="Opportunity">
<head>
<style>
@page {
Padding-top:30px;
@top-center {
content : element(header);
}
@bottom-right {
content : element(footer);
}
}
div.header {
position : running(header) ;
padding: 10px;
}
div.footer {
position : running(footer) ;
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
</style>
</head>
<div class="header" width="96%">
{!Opportunity.Name Opportunity.Account.BillingStreet Opportunity.Account.BillingCity Opportunity.Account.BillingCountry Opportunity.Account.BillingState Opportunity.Account.BillingPostalCode}
</div>
<div class="footer">
{!$Organization.Name $Organization.Street $Organization.City $Organization.State $Organization.Country $Organization.State $Organization.PostalCode}
</div>
<apex:dataTable value="{!opportunity.opportunityLineItems}" var="Opportunities" border="3" cellpadding="10">
<apex:column value="{!Opportunities.OpportunityId}" headerValue="Name"/>
<apex:column value="{!Opportunities.Quantity}" headerValue="Quantity"/>
<apex:column value="{!Opportunities.TotalPrice}" headerValue="TotalPrice"/>
</apex:dataTable>
</apex:page>
All Answers
Do you have access to these records? If you are using a standard/standard set controller, that will respect sharing rules.
I can tell you, yes I have access to these records...as I'm able to make changes to these records like adding new products etc.
I'm using standardcontroller in VF Page to access the values of the records.
If you change the page to not render as PDF, do the record fields display? I.e. is it a PDF issue or a more general issue?
When I've taken out that render as pdf and observed that header (Opportunity name, Opportunity.Account Billing Address), footer values (Organizational info) are not displaying in the page for the records that has displayed when it is rendered as PDF.
So in your words, it is a more general issue
Please suggest me a solution.
Please go through the below code..for your reference.
<apex:page standardController="Opportunity">
<head>
<style>
@page {
margin : 70pt .5in .5in .5in;
@top-center {
content : "{!Opportunity.Name} {!Opportunity.Account.BillingStreet} {!Opportunity.Account.BillingCity} {!Opportunity.Account.BillingCountry} {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}";
}
@bottom-center {
content : "{!$Organization.Name} {!$Organization.Street} {!$Organization.City} {!$Organization.State} {!$Organization.Country} {!$Organization.State} {!$Organization.PostalCode}";
}
}
div.header {
position : running(header) ;
}
</style>
</head>
<apex:dataTable value="{!opportunity.opportunityLineItems}" var="Opportunities" border="3" cellpadding="10">
<apex:column value="{!Opportunities.OpportunityId}" headerValue="Name"/>
<apex:column value="{!Opportunities.Quantity}" headerValue="Quantity"/>
<apex:column value="{!Opportunities.TotalPrice}" headerValue="TotalPrice"/>
</apex:dataTable>
</apex:page>
Just check are you able to see information when you render you page HTML doucment only(remove renadaras once)..If you able to see there it means this is the problem with pdf css.
One more thing if you have some approvel process on this pdf...and other fields are filled later.
I've taken out renderas and observed that it is not displaying the header and footer in the html and it is displaying when I have renderas PDF in the VF Page Code.
I dont have approval processes on this pdf
So as per your words, I can conclude that it is not problem with pdf css.
You have gone through my code..So can you please have a deep look into it and confirm me that there is no problem in the code that I've written.
Anilt just remove you code once put the code whic i have written below......
<apex:page standardController="Opportunity">
<head>
<style>
@page {
Padding-top:30px;
@top-center {
content : element(header);
}
@bottom-right {
content : element(footer);
}
}
div.header {
position : running(header) ;
padding: 10px;
}
div.footer {
position : running(footer) ;
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
</style>
</head>
<div class="header" width="96%">
{!Opportunity.Name Opportunity.Account.BillingStreet Opportunity.Account.BillingCity Opportunity.Account.BillingCountry Opportunity.Account.BillingState Opportunity.Account.BillingPostalCode}
</div>
<div class="footer">
{!$Organization.Name $Organization.Street $Organization.City $Organization.State $Organization.Country $Organization.State $Organization.PostalCode}
</div>
<apex:dataTable value="{!opportunity.opportunityLineItems}" var="Opportunities" border="3" cellpadding="10">
<apex:column value="{!Opportunities.OpportunityId}" headerValue="Name"/>
<apex:column value="{!Opportunities.Quantity}" headerValue="Quantity"/>
<apex:column value="{!Opportunities.TotalPrice}" headerValue="TotalPrice"/>
</apex:dataTable>
</apex:page>
Shiv Shankar...Thanks for your valuable time...Itz resolved now..
But small change is,
{!Opportunity.Name Opportunity.Account.BillingStreet Opportunity.Account.BillingCity Opportunity.Account.BillingCountry Opportunity.Account.BillingState Opportunity.Account.BillingPostalCode}
Above code has shown the error that Opportunity.Name is not found
So I've changed to
{!Opportunity.Name} {!Opportunity.Account.BillingStreet} {!Opportunity.Account.BillingCity} {!Opportunity.Account.BillingCountry} {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}
i.e., every field has to be in expression..thats it...other than that your code has fulfilled my requirement
Thanks a lot once again for your effort Shiv Shankar..
I just want to know,
@top-center {
content : element(header);
}
div.header {
position : running(header) ;
padding: 10px;
}
The above 2 scenarios where you have used header having the reference in the below scenario....right?
<div class="header" align="center">
{!Opportunity.Name} {!Opportunity.Account.BillingStreet} {!Opportunity.Account.BillingCity} {!Opportunity.Account.BillingCountry} {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}
</div>