0

Component Code :

<apex:attribute required="true"  type="string" name="type" description="specify header and footer type" />
<apex:stylesheet value="{!$Resource.dynamicStylePdf1}"/>
<div class="{!type}">
 <apex:componentBody/>
</div>                                 

Style-sheet Code :

@page {
@bottom-left{
    content: element(footer);
}
@top-center
    content: element(header);
        }
}
div.header {
position: running(header);
}
div.footer {
display: block;
position: running(footer);
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
@page :first {
    @bottom-right {
        }
    @top-center {
        }
@top-left {
        }
    @bottom-left {
        }
}

Apex Code : Image

  • @chinmay, At first it appears to be a margin measurements issue in style tag used in VF page. Try to adjust that, if used; else please share the code so that we can help! – Khushboo Dua Sep 4 '18 at 8:42
  • Please do not add any Answer posts below this Question post unless you actually mean to answer your own question. If you have clarifications to add, edit this post. – Adrian Larson Sep 4 '18 at 16:08
0

Can you try update the CSS as:

<style>
    @page {
        margin-top: 4cm;
        margin-bottom: 3cm;
        @top-center {
            content: element(header);
        }
        @bottom-left {
            content: element(footer);
        }
    }

    div.header {
        padding: 10px;
        position: running(header);
    }
    div.footer {
        display: block;
        padding: 5px;
        position: running(footer);
    }
    .pagenumber:before {
        content: counter(page);
    }
    .pagecount:before {
        content: counter(pages);
    }
    div.content {
        border-style:dotted;
        float: left;
        width: 100%;
    }
</style>

Please try and let me know!

| improve this answer | |
  • Its working....Thankyou so much @Khushboo Dua :-) – chinmay Sep 5 '18 at 11:22
  • @chinmay If the post helped you, please mark it as best solution, so that others can be helped if they get the same issue and also, so that we can close this thread. – Khushboo Dua Sep 6 '18 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.