]]>2018-05-10T08:35:43-08:002018-05-10T08:35:43-08:00https://nisus.com/forum/viewtopic.php?t=7003&p=30777#p30777Statistics: Posted by aersloat — 2018-05-10 08:35:43
]]>2018-05-09T10:01:33-08:002018-05-09T10:01:33-08:00https://nisus.com/forum/viewtopic.php?t=7003&p=30772#p30772So I'd build a Nisus macro that saves the document as a PDF.

The "Do Menu Macro With Macro" Command is the one you want. So, your service would be something like this (thanks to Kino):

CODE:

set myMacro to "$doc = Document.active$docPath = $doc.filePath# The next three line is unnecessary if you are 100% sure you run this macro# on saved documents only.if $docPath == @undefinedexit 'The document has never been saved, exiting...'end# As this macro will change the content of the surrounding folder,# you may get an error if you don't “require” the access to it. # Remove the next two lines if you are running an earlier version of# Nisus Writer Pro not understanding “File.requireAccessAtPath” command$folderPath = $docPath.filePathByRemovingLastComponent # Get the folder pathFile.requireAccessAtPath $folderPath # For Sandbox access# Get the path of the pdf file this macro will generate.# For example, '/Users/you/Documents/sample.pdf'# for '/Users/you/Documents/sample.rtf'.$pdfPath = $docPath.filePathByChangingExtension('pdf')Save As PDF $pdfPath"on run {input, parameters}set theFiles to inputtell application "Nisus Writer Pro"repeat with aFile in theFilesopen aFileDo Menu Macro with macro myMacroclose front documentend repeatend tellend run

Now, I had to build in Sandboxing code. This code works best with a folder of documents; the first time you run it with a set of files never done before, it'll ask you to grant access to the file or the folder. Give it access to the folder and you'll never have to worry about it again.

on run {input, parameters}set theFiles to inputtell application "Pages"repeat with aFile in theFilesopen aFileset docPath to path of front documentsave front document as "SLDocumentTypePDF" in docPathclose front documentend repeatend tellend run

A very simple script which worked really well for us. From what I gather there is no straight analogy with NW with PDFs specifically. I gather the best way is to create a macro and then call the macro from the Service. If we can do it from the Finder with a service it is preferable in terms of keeping the process smooth.

]]>2018-04-16T03:39:59-08:002018-04-16T03:39:59-08:00https://nisus.com/forum/viewtopic.php?t=6988&p=30745#p30745It is unfortunate that there are these 'holes' in the macro language as they prevent creating a macro to automate some formatting changes.

]]>2018-04-15T21:37:34-08:002018-04-15T21:37:34-08:00https://nisus.com/forum/viewtopic.php?t=6988&p=30742#p30742A couple of other possible solutions occur to me.

One is to make the header and footer text the same color as the background.

Another is to overlay the header and the footer with opaque rectangular shapes of the same color as the background and then toggle the “Draw behind text” option in the Shape Wrap Palette. While I can find no obvious object-related command in the Macro Language to do this toggling, one could just access the desired command via the hierarchical menu:–

]]>2018-04-15T10:44:25-08:002018-04-15T10:44:25-08:00https://nisus.com/forum/viewtopic.php?t=6987&p=30740#p30740Statistics: Posted by Þorvarður — 2018-04-15 10:44:25
]]>2018-04-13T18:28:24-08:002018-04-13T18:28:24-08:00https://nisus.com/forum/viewtopic.php?t=6987&p=30738#p30738I agree with you that the task at hand could easily be achieved with a Nisus macro as well. Let me just make a few suggestions.

First to process several documents in this fashion, a better interface than trying to read filenames/paths out of a document would be to let the user choose them in the finder. Nisus macro language has the commands Choose File, Choose Files and Choose Folder, which very conveniently return file paths. It will also allow you to easily add a loop to your code to process a whole group of files.

CODE:

$filePaths = Choose Filesforeach $filePath in $filePaths…end

Second if you want to manipulate filepaths and filenames I would generally recommend using the macro language commands. They will avoid you having to mess around with adding "/" and "." etc. For example:

CODE:

$newFilePath = $oldFilePath.filePathByChangingExtension 'rtf'

Third if you want to do something like removed " (Converted)" from a file path, then a much more straightforward approach would be to use ".findAndReplace". This will also make your code much more maintainable, since you won't have to look at this later and think "What was I trying to do here."