set QuelltextAllerSeiten to ""
set QuelltextAllerSeitenOhneReturn to ""
tell application "Safari"
set alleLinks to do JavaScript "var l='';for (var i = 0; i < document.links.length; i++){ l = l + document.links[i].href+ ',';}" in front document
set AppleScript's text item delimiters to ","
set alleLinks to every text item of alleLinks
repeat with i from 1 to (number of items of alleLinks) - 1
set URL of front document to item i of alleLinks
--set Quelltext to do JavaScript "document.body.innerHTML;" in front document
--set QuelltextAllerSeiten to QuelltextAllerSeiten & Quelltext
set Ueberschrift to do JavaScript "document.getElementsByTagName('h2')[0].firstChild.data;" in front document
set Ueberschrift to "<h2>" & Ueberschrift & "</h2>"
set Bild to do JavaScript "document.images[0].src;" in front document
set Bild to "<img src=\"" & Bild & "\"><br>"
set QuelltextAllerSeiten to QuelltextAllerSeiten & Ueberschrift & Bild
end repeat
end tell
set QuelltextAllerSeitenOhneReturn to austauschen(ASCII number 10, "", QuelltextAllerSeiten)
do shell script "echo '" & QuelltextAllerSeitenOhneReturn & "' > ~/temp.html"
do shell script "/System/Library/Printers/Libraries/convert -f ~/temp.html -o ~/übersicht.pdf; rm ~/temp.html"
--tell application "Safari"
-- drucken über Safari
-- do JavaScript ("document.open();document.write('" & QuelltextAllerSeitenOhneReturn & "'); document.close();") in front document
-- print the front document with print dialog -- with properties {target printer:"PDFWriter"} without print dialog
-- end if
on austauschen(suchen, ersetzen, theString) -- Parameters: search, replace, the String
--http://www.betabug.ch/austauschen.html
set olddelis to my text item delimiters
set my text item delimiters to (suchen)
tell me to set theList to (every text item of theString)
set my text item delimiters to (ersetzen)
set theString to theList as string
set my text item delimiters to olddelis
return theString
end austauschen