The itemData must be present and thats where the record is stored so if you will compare you must compare the itemData.fieldKey to something and then set or use hide or show. In your code you have the same conditions on both rows to check !== null which seem wrong. Always try to use the !== null or === null if you want to compare with different outcome.
$w("#myRepeater").forEachItem( ($w, itemData, index) => {
// the itemData holds the database record
if (itemData.fieldKey === "value") {
$w("#viewPDF").show();
}
} );
And also the first time the page loads it wont execute the forEachItem code for a repeater.
Then it will execute the
$w("#myRepeater").onItemReady( ($w, itemData, index) => {
});
But you can add the same code in that. So first time the repeater gets ready it will loop using onItemReady and then of you want to loop through it again when a button is clicked or something else use the forEachItem.