To customise Confluence's PDF output, you can edit the CSS stylesheets used by the PDF exporter. See Customising Exports to PDF.
To customise the HTML output, you will need to modify the file confluence-x.y.z-jar/com/atlassian/confluence/pages/Page.htmlexport.vm
. See Editing Files within JAR Archives to learn how to repackage this file.