Skip to content

Commit

Permalink
Changed location for Utility, improved file naming and improved remov…
Browse files Browse the repository at this point in the history
…al tool.
  • Loading branch information
rodyager committed Jun 23, 2022
1 parent 43d9064 commit 4e804fb
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 26 deletions.
13 changes: 8 additions & 5 deletions PDFWriter Utility/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
}
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions build/RWTS PDFwriter.ppd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions build/buildscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -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&"
7 changes: 7 additions & 0 deletions build/preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -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


7 changes: 1 addition & 6 deletions build/uninstall.sh → build/uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions pdfwriter/pdfwriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4e804fb

Please sign in to comment.