For anti-plagiarism check, you can use urllib2 to do a google search including a quoted text of what you want to check:
import urllib2
response = urllib2.urlopen('https://www.google.co.in/search?q="python+curl"')
html = response.read()
Read this SO link for more details.
For pdf-printing part, what I normally do is create an html template of my text/document and then use the xhtml2pdf python library to generate the pdf:
f=open('template.htm','r')
sourceHtml = unicode(f.read(), errors='ignore')
f.close()
sourceHtml = template.render(tvals)
sourceHtml = sourceHtml.replace('__name__',sname)
sourceHtml = sourceHtml.replace('__address__',saddress)
sourceHtml = sourceHtml.replace('__occupation__',soccupation)
packet = StringIO.StringIO() #write to memory
pisa.CreatePDF(sourceHtml,dest=packet)
Within the html template, you can use <code>
or <pre>
tags to format your scripts. Read my complete article to understand more about this method of gerating pdfs in python.