diff --git a/PDFWriter Utility/ContentView.swift b/PDFWriter Utility/ContentView.swift index 56f2193..8cc9be2 100644 --- a/PDFWriter Utility/ContentView.swift +++ b/PDFWriter Utility/ContentView.swift @@ -24,11 +24,14 @@ struct ContentView: View { let theData = try! theOrigURL.bookmarkData(options: [URL.BookmarkCreationOptions.suitableForBookmarkFile], includingResourceValuesForKeys: nil, relativeTo: nil) try! URL.writeBookmarkData(theData, to:panel.url!) } - }.padding() - Button("Quit"){ - NSApp.terminate(self) - }.padding() - }.frame(width:250, height:270 ) + } + Button("Reveal Uninstall script"){ + let task = Process() + task.launchPath = "/usr/bin/open" + task.arguments = ["/Library/Printers/RWTS/PDFwriter/"] + task.launch() + }.padding() + }.frame(width:250, height:230 ) .onAppear{ NSApp.activate(ignoringOtherApps: true)} } diff --git a/README.md b/README.md index 7ea69a3..ef1644c 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,15 @@ An OSX print to pdf-file printer driver -### [![](https://raw.githubusercontent.com/rodyager/RWTS-PDFwriter/master/build/PDFwriter.iconset/icon_256x256.png "Click to download installer pkg") Click to download the installer pkg](https://github.com/rodyager/RWTS-PDFwriter/releases/download/v2/RWTS-PDFwriter.pkg) +### [![](https://raw.githubusercontent.com/rodyager/RWTS-PDFwriter/master/build/PDFwriter.iconset/icon_256x256.png "Click to download installer pkg") Click to download the installer pkg](https://github.com/rodyager/RWTS-PDFwriter/releases/download/v2.0/RWTS-PDFwriter.pkg) ## About RWTS PDFwriter **RWTS PDFwriter** in an OSX 11.0 compatible print driver that enables you to “print” your documents directly to a pdf file. It has similar functionality to [CutePDF](http://www.cutepdf.com) on Windows. ## Installation and Usage Instructions -Download the installer package by clicking on the printer icon above and install as usual. The installer will open the **PDFWriter Utility** app which lets you create a destination folder for the PDFs you print. Other users can create their own print destination by using the **PDFWriter Utility** app found in - ` /Applications/Utilities/ ` +Download the installer package by clicking on the printer icon above and install as usual. The installer will open the **PDFWriter Utility** app which lets you create a destination folder for the PDFs you print. + +Other users can access this utility to create their own print destination from the ` Options & Supplies ` button for the printer in ` System Preferences > Printers & Scanners ` After installation, your new printer will be ready for use. @@ -22,11 +23,7 @@ The “printed” PDF files produced will be stored in the directory you created ## Removal instructions -If you want to uninstall **PDFwriter**, open Terminal.app, type - -` /Library/Printers/RWTS/PDFwriter/uninstall.sh ` - -and press Return. You will be asked for your admin password. After hitting Return, **PDFwriter** will be entirely removed from your system. +If you want to uninstall **PDFwriter**, open the **PDFWriter Utility** (see above)and click the button to reveal the ` uninstall ` script. When you open this script, you will be asked for your administrative password, after which **RWTS PDFwriter** will be completely removed from your system. ## Compiling from sources In the event that you want to compile your own copy, you can clone this repository. diff --git a/build/RWTS PDFwriter.ppd b/build/RWTS PDFwriter.ppd index 71fb216..3513f82 100644 --- a/build/RWTS PDFwriter.ppd +++ b/build/RWTS PDFwriter.ppd @@ -35,6 +35,7 @@ *APPrinterIconPath: "/Library/Printers/RWTS/PDFwriter/PDFwriter.icns" *1284DeviceID: "MFG:RWTS;MDL:PDFwriter;DES:RWTS PDFwriter - Prints documents as PDF files;CLS:PRINTER;CMD:POSTSCRIPT;" *cupsFilter: "application/vnd.cups-pdf 0 -" +*APPrinterUtilityPath: "/Library/Printers/RWTS/Utilities/PDFWriter Utility.app" *PSVersion: "(3016.102) 1" *LanguageLevel: "3" *ColorDevice: True diff --git a/build/buildscript.sh b/build/buildscript.sh index 30cd1b3..b823e1f 100755 --- a/build/buildscript.sh +++ b/build/buildscript.sh @@ -10,7 +10,7 @@ if [ -z "$SDKROOT" ]; then export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" fi PDFWRITERDIR="pkgroot/Library/Printers/RWTS/PDFwriter" -UTILITIESDIR="pkgroot/Applications/Utilities" +UTILITIESDIR="pkgroot/Library/Printers/RWTS/Utilities" PPDDIR="pkgroot/Library/Printers/PPDs/Contents/Resources" UTILITYAPP="PDFWriter Utility.app" PPDFILE="RWTS PDFwriter" @@ -35,17 +35,17 @@ echo "#### making directory structure" mkdir pkgroot resources scripts mkdir -m 775 pkgroot/Library pkgroot/Library/Printers pkgroot/Library/Printers/RWTS mkdir -m 755 $PDFWRITERDIR pkgroot/Library/Printers/PPDs pkgroot/Library/Printers/PPDs/Contents $PPDDIR -mkdir -m 775 pkgroot/Applications $UTILITIESDIR +mkdir -m 775 $UTILITIESDIR echo "#### populating directory structure" iconutil -c icns -o $PDFWRITERDIR/PDFwriter.icns PDFwriter.iconset cp pdfwriter $PDFWRITERDIR/ cp -r "$UTILITYAPP" $UTILITIESDIR/ -cp uninstall.sh PDFfolder.png $PDFWRITERDIR/ +cp uninstall PDFfolder.png $PDFWRITERDIR/ gzip -c "$PPDFILE".ppd > $PPDDIR/"$PPDFILE".gz chmod 700 $PDFWRITERDIR/pdfwriter -chmod 755 $PDFWRITERDIR/uninstall.sh # will be root:admin 750 after postinstall, but this will be ok if permissions are "repaired" +chmod 755 $PDFWRITERDIR/uninstall # will be root:admin 750 after postinstall, but this will be ok if permissions are "repaired" chmod 644 $PPDDIR/"$PPDFILE".gz cp PDFWriter.iconset/icon_256x256.png resources/background.png diff --git a/build/postinstall b/build/postinstall index e6dc0ef..f8c7db2 100755 --- a/build/postinstall +++ b/build/postinstall @@ -21,4 +21,4 @@ launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist # install printer lpadmin -p PDFwriter -E -v pdfwriter:/ -P /Library/Printers/PPDs/Contents/Resources/RWTS\ PDFwriter.gz -o printer-is-shared=false -su "$USER" -c "/Applications/Utilities/PDFWriter\ Utility.app/Contents/MacOS/PDFWriter\ Utility&" +su "$USER" -c "/Library/Printers/RWTS/Utilities/PDFWriter\ Utility.app/Contents/MacOS/PDFWriter\ Utility&" diff --git a/build/preinstall b/build/preinstall index 91e024f..7875948 100755 --- a/build/preinstall +++ b/build/preinstall @@ -11,3 +11,10 @@ then /Library/Printers/Lisanet/PDFwriter/uninstall.sh fi +if [ -e Applications/Utilities/PDFWriter\ Utility.app ] +then + # remove initial Version 2 Utility if it is there + rm -rf /Applications/Utilities/PDFWriter\ Utility.app +fi + + diff --git a/build/uninstall.sh b/build/uninstall similarity index 67% rename from build/uninstall.sh rename to build/uninstall index 9523745..2dddb0b 100755 --- a/build/uninstall.sh +++ b/build/uninstall @@ -9,13 +9,8 @@ lpadmin -x pdfwriter -sudo rm /Library/Printers/RWTS/PDFwriter/* +sudo rm -rf /Library/Printers/RWTS sudo rm /usr/libexec/cups/backend/pdfwriter sudo rm /Library/Printers/PPDs/Contents/Resources/RWTS\ PDFwriter.gz -sudo rm -rf /Applications/Utilities/PDFWriter\ Utility.app - - -sudo rmdir /Library/Printers/RWTS/PDFwriter -sudo rmdir /Library/Printers/RWTS sudo pkgutil --forget au.rwts.pdfwriter diff --git a/pdfwriter/pdfwriter.m b/pdfwriter/pdfwriter.m index 38823c1..a1de927 100644 --- a/pdfwriter/pdfwriter.m +++ b/pdfwriter/pdfwriter.m @@ -448,8 +448,17 @@ int main(int argc, char *argv[]) { log_event(CPDEBUG, "no title found - using default value", title); } else { - /* motwithstanding good advice above, we don't use a prefix, which means duplicates overwrite */ - snprintf(title, BUFSIZE, "%s", cmdtitle); + /* create a unique title for the file*/ + NSString * proposedTitleWithoutExtension = [NSString stringWithCString: cmdtitle encoding: NSString.defaultCStringEncoding]; + NSString * proposedTitle = [proposedTitleWithoutExtension stringByAppendingPathExtension:@"pdf"]; + NSString * outDirectory = [NSString stringWithCString: conf.outdir encoding: NSString.defaultCStringEncoding]; + outDirectory = [outDirectory stringByAppendingPathComponent: [NSString stringWithCString: userdirname encoding: NSString.defaultCStringEncoding] ]; + int fileIndex = 1; + while ([NSFileManager.defaultManager fileExistsAtPath: [outDirectory stringByAppendingPathComponent:proposedTitle]]){ + proposedTitle = [NSString stringWithFormat: @"%@-%d.pdf",proposedTitleWithoutExtension, fileIndex]; + fileIndex++; + } + snprintf(title, BUFSIZE, "%s", [proposedTitle.stringByDeletingPathExtension cStringUsingEncoding:NSString.defaultCStringEncoding]); log_event(CPDEBUG, "title successfully retrieved", title); }