I'm assuming you meant the recent outbreak of 'Petya' that is also known as 'NotPetya', since it was based on the original 'Petya' but it is not 'Petya', hence the name 'NotPetya'
NotPetya was spread through an infected software update process for a software company in Ukraine called MeDoc, which make accounting software. NotPetya's authors exploited MeDoc's update system to create a backdoor, and then pushed their Malware through it. MeDoc is widely used (especially in Ukraine) which is why it spread pretty quickly.
The 'original' petya, most likely spread the same way many variants of ransomware do, through infected attachments on emails. An infected Word document will execute its code if the user can be tricked into clicking 'Enable Content', as this allows Word to execute the macros, which is a set of programming instructions, emmbedded into the document.
Regarding PDFs, as far as I understand (and I'm not an expert) PDfs can contain dynamic content, such as Javascript executable code, which executes when the document is opened.
The way you asked makes me think you're concerned about getting infected by a similar malware in the future. The best way to fight back against this, or any ransomware, is not to get infected in the first place, while this wasn't completely applicable in this instance, since it was an infected supplier higher up the chain. But aside from that, use antivirus, keep your software up to date (Yes I can see the irony with this advice), don't open attachments from senders you don't completely trust, check urls, double check the sender of emails (addresses can be spoofed), and don't click enable content!
If the worst comes to the worst and you get hit by ransomware, keep separate backups so you can recover, don't pay unless you really really need the data back- and be sure to check that other people who paid actually got their data back, since those who paid NotPetya, did not.