text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
if skipFlag is false then | lns3.scpt |
{document template:template chosenTemplateName} | lns3.scpt |
set placeholderWordReplacementStringPairings to {{senderFirstNamePlaceholder, senderFirstName}, {senderLastNamePlaceholder, senderLastName}, {senderEmailAddressPlaceholder, senderEmailAddress}, {senderFullAddressPlaceholder, senderAddress}, {senderPhoneNumberPlaceholder, senderPhoneNumber}, {recipientFirstNamePlacehold... | lns3.scpt |
with timeout of 600 seconds -- allow up to 10 minutes to process really long documents | lns3.scpt |
repeat with i from 1 to the count of placeholderWordReplacementStringPairings | lns3.scpt |
copy item i of placeholderWordReplacementStringPairings to ¬ | lns3.scpt |
{placeholderWord, replacementString} | lns3.scpt |
my replaceWordWithStringInBodyText(placeholderWord, replacementString) | lns3.scpt |
set the targetExportFileHFSPath to (thisDirectoryHFSPath & exportDocName) | lns3.scpt |
if usePDFEncryption is true then | lns3.scpt |
export thisDocument to file targetExportFileHFSPath ¬ | lns3.scpt |
as PDF with properties {password:providedPassword} | lns3.scpt |
export thisDocument to file targetExportFileHFSPath as PDF | lns3.scpt |
set thisMessage to make new outgoing message with properties ¬ | lns3.scpt |
{subject:outgoingMessageSubject, visible:true} | lns3.scpt |
tell thisMessage | lns3.scpt |
make new to recipient with properties ¬ | lns3.scpt |
{address:recipientEmailAddress, name:(recipientFirstName & space & recipientLastName)} | lns3.scpt |
make new attachment at end of paragraphs of content with properties ¬ | lns3.scpt |
{file name:file targetExportFileHFSPath} | lns3.scpt |
set the end of createdMessages to thisMessage | lns3.scpt |
move document file targetExportFileHFSPath to the trash | lns3.scpt |
if attemptMailSend is true then | lns3.scpt |
repeat with i from 1 to the count of the createdMessages | lns3.scpt |
set thisMessage to item i of the createdMessages | lns3.scpt |
send thisMessage | lns3.scpt |
set the errorLog to errorLog & return & ¬ | lns3.scpt |
"Attempt at sending messages failed." & space & errorMessage | lns3.scpt |
tell application "Mail" to activate | lns3.scpt |
if the (count of paragraphs of errorLog) is greater than 1 then | lns3.scpt |
make new document with properties {document template:template "Blank"} | lns3.scpt |
set body text of thisDocument to errorLog | lns3.scpt |
display notification "Process completed." with title "Mail Merge with Contacts Group" | lns3.scpt |
set errorNumber to "OPEN DOCUMENTS" | lns3.scpt |
"Please close all documents before running this script." | lns3.scpt |
set errorNumber to "NO USER TEMPLATES" | lns3.scpt |
"There are no Pages user templates installed on this computer." | lns3.scpt |
set errorNumber to "MAIL MERGE ERRORS" | lns3.scpt |
"The open document lists the errors occuring during the Mail Merge." | lns3.scpt |
if errorNumber is in {10002} then | lns3.scpt |
display notification "Errors occured." with title "Mail Merge with Contacts Group" | lns3.scpt |
on replaceWordWithStringInBodyText(searchWord, replacementString) | lns3.scpt |
repeat with i from the (count of paragraphs) to 1 by -1 | lns3.scpt |
if exists searchWord then | lns3.scpt |
set (last word where it is searchWord) to replacementString | lns3.scpt |
end replaceWordWithStringInBodyText | lns3.scpt |
property defaultTopMarginHeight : 36 | lns3.scpt |
property defaultBottomMarginHeight : 36 | lns3.scpt |
property defaultLeftMarginWidth : 36 | lns3.scpt |
property defaultRightMarginWidth : 36 | lns3.scpt |
property defaultColumnGutterWidth : 12 | lns3.scpt |
property defaultRowGutterHeight : 12 | lns3.scpt |
property defaultColumnCount : 3 | lns3.scpt |
property defaultRowCount : 6 | lns3.scpt |
property paperSizeNames : {"US Letter", "US Legal", "A3", "A4", "A5", "JIS B5", "B5", "Envelope #10", "Envelope DL", "Tabloid", "Tabloid Oversize", "ROC 16K", "Envelope Choukei 3", "Super B/A3"} | lns3.scpt |
property paperSizeDimensions : {{612, 792}, {612, 1008}, {842, 1191}, {595, 842}, {420, 595}, {516, 729}, {499, 709}, {297, 684}, {312, 624}, {792, 1224}, {864, 1296}, {558, 774}, {340, 666}, {936, 1368}} | lns3.scpt |
tell application id "com.apple.iWork.Pages" | lns3.scpt |
set paperSizePrompt to "What is this document’s paper size?" | lns3.scpt |
set chosenPageSize to (choose from list paperSizeNames with prompt paperSizePrompt default items (item 1 of paperSizeNames)) | lns3.scpt |
if chosenPageSize is false then error number -128 | lns3.scpt |
set chosenPageSize to chosenPageSize as string | lns3.scpt |
set thisPageDimensions to item (my indexOfItemInList(chosenPageSize, paperSizeNames)) of paperSizeDimensions | lns3.scpt |
set orientationPrompt to "Is the page orientation set to landscape or portrait?" | lns3.scpt |
display dialog orientationPrompt buttons {"Cancel", "Landscape", "Portrait"} default button 3 | lns3.scpt |
if the button returned of the result is "Landscape" then | lns3.scpt |
set thisPageDimensions to the reverse of thisPageDimensions | lns3.scpt |
copy thisPageDimensions to {documentWidth, documentHeight} | lns3.scpt |
set objectTypePrompt to "Do you want to create just images, just text items, or both image and text items as pairs?" | lns3.scpt |
display dialog objectTypePrompt buttons {"Images", "Text Items", "Both"} default button 3 | lns3.scpt |
set the objectType to the button returned of the result | lns3.scpt |
set topMarginPrompt to "Enter the size of the TOP page margin to use (in pixels):" | lns3.scpt |
set topMarginHeight to my promptForIntegerValue(topMarginPrompt, 0, documentHeight div 2, defaultTopMarginHeight) | lns3.scpt |
set bottomMarginPrompt to "Enter the size of the BOTTOM page margin to use (in pixels):" | lns3.scpt |
set bottomMarginHeight to my promptForIntegerValue(bottomMarginPrompt, 0, documentHeight div 2, defaultBottomMarginHeight) | lns3.scpt |
set leftMarginPrompt to "Enter the size of the LEFT page margin to use (in pixels):" | lns3.scpt |
set leftMarginWidth to my promptForIntegerValue(leftMarginPrompt, 0, documentHeight div 2, defaultLeftMarginWidth) | lns3.scpt |
set rightMarginPrompt to "Enter the size of RIGHT page margin to use (in pixels):" | lns3.scpt |
set rightMarginWidth to my promptForIntegerValue(rightMarginPrompt, 0, documentHeight div 2, defaultRightMarginWidth) | lns3.scpt |
set columnGutterPrompt to "Enter the space between columns (in pixels):" | lns3.scpt |
set columnGutterWidth to my promptForIntegerValue(columnGutterPrompt, 0, 100, defaultColumnGutterWidth) | lns3.scpt |
set rowGutterPrompt to "Enter the space between rows (in pixels):" | lns3.scpt |
set rowGutterHeight to my promptForIntegerValue(rowGutterPrompt, 0, 100, defaultRowGutterHeight) | lns3.scpt |
set columnCountPrompt to "Enter the column count:" | lns3.scpt |
set columnCount to my promptForIntegerValue(columnCountPrompt, 2, 20, defaultColumnCount) | lns3.scpt |
if objectType is "Both" then | lns3.scpt |
set rowCountForBothPrompt to "Since you’ve chosen to create paired image and text rows, enter the total row count (including both image and text rows):" & return & return & "(This value must be an even number)" | lns3.scpt |
set rowCount to my promptForIntegerValue(rowCountForBothPrompt, 2, 20, defaultRowCount) | lns3.scpt |
if rowCount mod 2 is 0 then | lns3.scpt |
set rowCountPrompt to "Enter the row count:" | lns3.scpt |
set rowCount to my promptForIntegerValue(rowCountPrompt, 2, 20, defaultRowCount) | lns3.scpt |
set pageIdentiferPrompt to "Do you want add identifiers to the page items?" | lns3.scpt |
display dialog pageIdentiferPrompt buttons {"Cancel", "No", "Yes"} default button 3 | lns3.scpt |
if (the button returned of the result) is "Yes" then | lns3.scpt |
set shouldAddID to true | lns3.scpt |
set shouldAddID to false | lns3.scpt |
set columnGutterCount to columnCount - 1 | lns3.scpt |
set rowGutterCount to rowCount - 1 | lns3.scpt |
set editableAreaWidth to documentWidth - leftMarginWidth - rightMarginWidth | lns3.scpt |
set editableAreaHeight to documentHeight - topMarginHeight - bottomMarginHeight | lns3.scpt |
set editableColumnAreaWidth to editableAreaWidth - (columnGutterCount * columnGutterWidth) | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.