+ Start a Discussion

Visualforce Component overlap

Hi All,

I need to create a PDF that must show two copies of the same document: one copy for the customer and one copy for the company.
These two documents are the same except for the header: into the header is specified if the copy is for the customer or for the company.

During my fisrt attempt I structured the page in this way:
<apex:page renderAs="pdf">
    <div class="header"></div>
    <div class="content">
        <!-- content for the customer's copy -->
        <div style="page-break-after: always;"></div>
        <!-- same content for the company's copy -->
    <div class="footer"></div>

But in this way the header it's the same for all the pages.

So, I created a Visualforce Component with a dynamic header, like this:
    <apex:attribute name="isCustomerCopy" description="Specify if this copy is for the Customer" type="Boolean" required="true"/>

    <div class="header>
        <apex:outputLabel value="Customer's copy" rendered="{!isCustomerCopy}"/>
        <apex:outputLabel value="Company's copy" rendered="{!NOT(isCustomerCopy)}"/>
    <div class="content"> <!-- content only once --> </div>
    <div class="footer"></div>

Then I modified the visualforce page like this:
<apex:page renderAs="pdf">
    <c:MyComponent isCustomerCopy="true"/>
    <c:MyComponent isCustomerCopy="false"/>

Now the header it's correct, but the two components result overlapped.

Does anyone have a solution for my problem?

Thanks in advance
How are you determining the user type? Profile, Role, email address, etc?