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

2
  • @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! Sep 4, 2018 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, 2018 at 16:08

1 Answer 1

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!

2
  • Its working....Thankyou so much @Khushboo Dua :-)
    – chinmay
    Sep 5, 2018 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. Sep 6, 2018 at 7:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .