I have two PDF files. If I select the second PDF (kfz) to print, the first PDF (bike) ends up printing anyway. Why is this? There are two different paths.
<script>
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
</script>
<tr>
<td>
Fahrrad Kaufvertrag
</td>
<td>
<%= Html.ActionLink("Download", "DownloadBikeContract", new { id = 1 }, new { @class = "SaveContract" })%>
</td>
<td>
<img src="../../Styles/Images/Buttons/printer.png" onclick="printTrigger('iFramePdf');" />
<iframe id="iFramePdf" src="../../Files/KaufvertragFahrrad.pdf" style="display: none;">
</iframe>
</td>
</tr>
<tr>
<td>
KFZ - Kaufvertrag
</td>
<td>
<%= Html.ActionLink("Download", "DownloadKFZContract", new { id = 2 }, new { @class = "SaveContract" })%>
</td>
<td>
<img src="../../Styles/Images/Buttons/printer.png" onclick="printTrigger('iFramePdf');" />
<iframe id="iFrame1" src="../../Files/KaufvertragKFZ.pdf" style="display: none;">
</iframe>
</td>
</tr>
Your second image says
onclick="printTrigger('iFramePdf');", but the ID of the second iframe isiFrame1, notiFramePdf. You just need to pass the right string to yourprintTrigger()call.