Writing a simple app to convert files to pdf - cocoa

I want to create an application on a Mac to convert multiple files (txt, pdf, doc, html, etc) to a single pdf file that can be printed. The real point is that if you have 50 texts you don't have to open every single file and click command-p.
I'm not quite sure whether the best way to do this is by creating a full-fledged app or an automator plugin (or something else). If I remember correctly there's a filter in mac os's terminal that can convert files to pdf (but I forgot what it's called).
So would an automator plugin do this well, or shall I make an app for this? Can you provide me advantages for each answer?
I've done cocoa touch programming before so I can write objective-c quite well.

Use appscript, either as an action in an automator script or standalone. The advantage is that it is very simple and will take you a fraction of the time to write an app.
Here is something very close to what you want. It sets up a drop-folder and each file dragged onto it is printed (you can use multiple-select to get what you want). It uses Apple Works 6 which doesn't support the file-types that you want.
To modify it to use the Preview application instead you need to change the tell command in the script and then google the dictionary for Preview to check which verb to use for printing.

Related

Alternative to Windows Alternate Data Streams

I have the following need to implement on Windows: file with files.
Originally I was thinking to use directory with extension. Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened. Unfortunately, I was unable to find a way to do that. Then I tried to use Alternate Data Streams. This works just fine, but several problems with it:
It works only in NTFS, so no way to send it via email or FTP as is;
Only WinRAR can properly archive it, and you still have to do extra clicks in the UI for that;
The real file size (with all streams in it) is not shown in Explorer and does not participate in showing free/used space, which can very quickly lead to big problems for the user.
No, I can't use zip or any other way to combine files into one - this is high-performance app that also requires write streaming (i.e. it changes data all the time).
Any idea how else to achieve my need on Windows? I know on MacOS you can use 'package', but there is nothing like that on Windows. Any idea?
Something like "folderA.myappext", so when user clicks on it in Explorer, my app is launched instead of folder being opened.
You can't do it based on the extension because folders don't have extensions but you can do it with desktop.ini. Windows 7 and later supports custom verbs on folders.
A working example can be found here.

Using applescript / automator to run illustrator batch process

Is there a way to get Automator or Applescript to run 'batch' processes in Adobe Illustrator?
I have a workflow that handles a number of steps - but the key one is to use Illustrator variable data sets to replace two embedded eps files (one of a symbol and one of some text) and a bit of text with a product code.
I'm basically running through this:
http://hypertransitory.com/blog/2014/05/27/use-adobe-illustrator-variable-data-xml/
Except I have some php spitting out the xml that illustrator requires to use for data.
So I have my xml, and if I run a batch process from within illustrator that works fine - trouble is I want to do this multiple times - and each time I want the files to save in the same location. I can get automator to run an action in illustrator, but I can't create an action to load in and run through the data sets from the xml, saving each one. The only way illustrator seems to let you use the variable data sets is via 'batch' - which means you have to provide it with the 'Destination' to export the files to every time (and you can't use it as a step in Automator).
I'm using Illustrator CC (so I believe that's referred to as illustrator 17 in applescript) and OSX 10.10 (if that's relevant)
I'm new to applescript and am busy learning the syntax - but I can't find anything that seems to indicate this is going to be possible!
You can use Illustrator-friendly scripting languages to "manually" change out the datasets within the Illustrator document and output the files into your manually-coded location. If you can find the Applescript commands to do this, you can use it, otherwise you can make a .jsx extendscript and trigger it with your Applescript.
There are also a couple of sets of Illustrator Automator actions, which may be of use to you. Ai Actions and AI Automator Action Pack, both of which are available on the Mac app store. Not as versatile as coding your own bespoke solution using AppleScript (which is how I'd probably approach the problem), but much easier to implement. For the sake of transparency, I'm the developer of the former.

Redirect default program to another program when a file opens in Windows OS

This is only under windows env.
As I know windows os identifies associated application of a particular file by file extension.
Like wise each file (binary) starting with corresponding symbols ("starting symbols"). For an example .JPG starts with ÿØÿà. Let say I open this .JPG file in a Hex editor or a Text editor and then I change that starting symbols into another file type. for an example I can change ÿØÿà to .Eߣ (.mkv). So when I double click on the .JPG the Windows Photo Viewer says there are some errors or similar message. So I need to get some information about the application that tries to open that kind of a file. If I can, I need to open that file using the application that associated with "starting symbols".
Briefly when I open .JPG I need to open a default video player .mkv files. But It may not work for this example. Because I changed only the "starting symbols" of my .JPG.
Please give me any idea to do this.
Thanks!
When you encrypt the file, give it a new extension. e.g. Picture.jpg becomes Picture.encrypted-jpg. You then register as the handler for encrypted-jpg, decrypt the file, then launch the normal jpg handler.
When the shell is asked to perform a verb on a file, the shell does not use the contents of the file to determine which app to pass it to. The file extension is what determines how the file will be treated.
You wish to use the contents of the file to influence which app processes a shell verb. In order to do so you would need to create a launcher app that reads the file header and then decides which app to pass the file on to. You would assign your launcher app as the handler app for all file extensions that you were interested in.
Although you could do this, it would be much easier just to set the file extension appropriately.
The proper way to do this sort of thing is to replace the files with reparse points.
The downside is that this involves writing a file system filter driver, i.e., an operating system extension, which is a whole level of trouble above and beyond ordinary application programming. (Since Windows already does file encryption, I doubt it would be worth the effort.)

OSX Application or Web App for converting text to plain text (unicode)

I am looking for ways to quickly converting blocks of text created in Word, etc. into plain text (i.e. turning right and left quotation marks into "plain text" quotation marks) for quickly transferring content to code with as few headaches as possible.
I came across this:
http://www.softpedia.com/get/Office-tools/Other-Office-Tools/Keith-Fenske-Plain-Text.shtml
...but it is Windows only and I prefer to dev on a Mac. Does anyone have a suggestion for an OSX tool or better yet a web app?
If you're using Snow Leopard, it's easy to create a Service to clean text. Run /Applications/Automator, choose the Service template, set it to receive text in any application, and enable replacing the selected text. Add a Run Shell Script action to the workflow, with Pass Input set to stdin. For the actual script, paste this in in place of the template (cat):
LC_CTYPE=en_US.UTF-8 tr '‘’‛❛❜“”‟❝❞‐–—­‒‑' "['*5]"'["*5][-*6]'
(note: hopefully all the various funny characters I included in the first string will pass through our various web interfaces intact... if not, edit the collections of quote marks to include whatever you need to squash in the first string, and matching numbers of their plain-text equivalents in the second string. And feel free to add other replacements as needed.)
Anyway, save this Service with some reasonable name, and then to invoke it just select some text (in any Cocoa app -- not, unfortunately, MS Word), and select your service from the application menu -> Services submenu. Also, you can use the Keyboard preference pane to assign it a keyboard shortcut if you like.
Text Wrangler from Bare Bones Software. This is BBEdit's free little brother (which will also do what you want).
The "Plain Text" Java application will run on Linux, Mac OS, and Windows.

Creating quick GUI front ends

I wanted to have a GUI front-end for a script that accepts numerous command-line options, most of them are UNIX paths. So I thought rather than typing them in (even with auto-completion) every time, I'd create a GUI front end which contains text boxes with buttons beside them, which when clicked will invoke the file browser dialogue. Later, I thought I'd extend this to other scripts which would sure require a different set of GUI elements. This made me think if there's any existing app that would let me create a GUI dialog, after parsing some kind of description of the items that I want that window should contain.
I know of programs like Zenity, but I think it's doesn't give me what I want. For example, if I were to use it for the first script, it'll end up flashing sequence of windows in succession rather than getting everything done from a single window.
So, basically I'm looking at some corss-platform program that lets me create a window from a text description, probably XML or the like. Please suggest.
Thanks
Jeenu
Mozilla's XUL is a cross platform application framework - . You could write an app as a Firefox plugin or a standalone XUL application.
mono and monodevelop could work for this. Or even something super simple like shoes.

Resources