<p style="height: 2000px">
This text in the main frame should not be printed
when the sub frame (scroll down to see it) initiates printing.
</p>
<iframe srcdoc="
<p>This <a href='#target'>link</a> in the subframe should be printed.</p>
<button onclick='print()'>Print</button>
<p>In the saved pdf, clicking the above link should navigate to the page containing 'TARGET'</p>
<div style='height: 2000px'></div>
<a name='target'>TARGET</a>
<div style='height: 2000px'></div>
<script>
setTimeout(function() { window.print(); }, 500);
</script>">
</iframe>