XPS Imposition
I've written a small example script for NiXPS View v3.0 that implements XPS imposition.
Given a multipage file, it imposes 2 pages on 1 landscape A4 - so a 16 page document will yield an 8 page document, where each page has 2 pages on it.
The script is fairly simple, about 50 lines of code:
First, define our A4 paper size:
// paper size, use A4 lMaxWidth=1056; lMaxHeight=816;
Then create a new XPS file:
// create a new XPS file, with a single document lNewXPS=new NOPackage(); lNewXPS=lNewXPS.create(true,"spreads.xps"); lNewDoc=lNewXPS.getDocument(0);
Next, we walk over all the pages is the currently active document, and put 2 pages on each page. We do some RenderTransform magic to position the pages correctly:
// get the doc lDocument=App.getDocument(); lNumberOfPages=lDocument.getNumberOfPages();
for (i=0; i<lNumberOfPages; i++) { if (i % 2==0) { // create a new page lNewPage=lNewDoc.createPage(); lNewFixedPage=lNewPage.getFixedPage(); lNewFixedPage.setWidth(lMaxWidth); lNewFixedPage.setHeight(lMaxHeight); lOffsetX=0; lNum=0; } else { lOffsetX=lMaxWidth/2; lNum=1; } // access the page lPage=lDocument.getPage(i); lFixedPage=lPage.getFixedPage(); lPageWidth=lFixedPage.getWidth(); lPageHeight=lFixedPage.getHeight();
// calculate the factor lFactorWidth=(lMaxWidth/2)/lPageWidth; lFactorHeight=lMaxHeight/lPageHeight; lFactor=lFactorWidth; if (lFactorHeight<lFactor) lFactor=lFactorHeight;
// copy page on top lNewPage.copyPageOnTop(lPage); lCanvas=lNewFixedPage.getCanvas(lNum); lCanvas.setRenderTransform(lFactor+",0,0,"+lFactor+","+lOffsetX+",0"); }
And that's it. Only thing left to do now at this point is give the newly created XPS file to the application, so the user can work with it further.
App.addPackage(lNewXPS);
As you can see you can fairly easy leverage the NiXPS SDK in Javascript this way. It's great for tools and customizations, and also for experimenting, as it is also fairly easy to convert this script to a C-Sharp or C++ source, and use it in conjunction with our SDK.
NiXPS View 3.0 features: Scripting An exciting new addition to NiXPS View v3.0 is its ability to run scripts.
Granted, this is a fairly technical feature, but it can be very useful to extend the NiXPS View applications with more 'vertical' features.
Scripting is essentially programming, so to a certain degree you need to be a 'computer geek' to be able to grok how to do this. But scripting has a fairly low barrier of entry. Especially if the scripting is based on something relatively ubiquitous Javascript.
Javascript powers virtually all websites around the internet, and chances are that if you ever had a go at building your own website, that you have encountered, and even tried writing, a Javascript.
Fact is: Javascript is fairly easy to learn and use, and if technology is not really your thing, which is very possible, than it isn't hard to find someone with the technical ability required to hack together a decent script.
We leverage our NiXPS SDK in the scripting environment, and together with some hooks for the application, one can build fairly powerful scripts which very little coding.
To aid the development of scripts, we have started a wiki where we give a small introduction to how to get around making scripts for NiXPS View v3.0. You can find this at http://nixps.com/scripting.
We are big proponents of 'learning by example', and for this we are posting example scripts on the wiki. This is a great way to experiment, and get the hang of writing small scripts. And for technical help you could also post your question on the NiXPS mailing list
One of the first scripts that we are posting in the example section is a script that performs XPS imposition. I'm going to write a bit more about this in a next blog post.
¶ 14:010 Comments
Thursday, September 24, 2009
NiXPS View 3.0 features: UI
This is the first of a series of posts that takes an in-depth look at our latest NiXPS View release.
The subject of this post is UI, one of the most , if the most, important aspects of a desktop application. I've written before about how important, and how much work it is to get a UI right. We've invested a lot of time and effort to make the UI of NiXPS View v3.0 more efficient, and aesthetically pleasing.
Toolbar One of the things that you'll first notice when starting up the application, is the new toolbar:
We have chosen not to fill this up with 'everything but the kitchen sink', like a lot of applications tend to do, but in stead we have opted to only offer the most used features, and put all others on the menu. This makes the application look a lot less complex, which is good, as complexity alienates users. Advanced functionality can be discovered in the menus.
So the toolbar contains:
page down and page up
zoom in and out
the tools: pan, zoom, text select & edit and the note tool
a button to toggle the sidebar
the quick search
These are the most important functions one need when interacting with an electronic document. We have decided against putting the 'print' in the toolbar, as it would add to the visual clutter, and everyone is accustomed to finding the print feature in the file menu.
Sidebar The sidebar contains all kinds of 'lists': an optional document outline (aka table of contents), page thumbnails, document thumbnails and the search results. These are very useful lists, but showing them by default make the UI too busy. We chose an approach to only show the sidebar when there is a reason for it (if the document has an outline, it will show by default; if the user searches, the results will be shown), otherwise it is hidden, but can be discovered by the user via the sidebar button.
Quick search Searching through a document is a very important function; we spend a lot of time speeding it up, and made sure it works well with large documents. The moment you start typing in the quick search control, the app will start searching, without blocking the UI. This is a very natural, and pleasing way to do a search. We also provide extensive feedback during the search, so the user knows what is going on when the search takes a long while, which can be the case for very large documents.
OS specifics We carefully crafted the application to really 'fit in' the native OS it runs on. On Windows this means that we start-up with an empty windows, which is a drag target for opening files. Dropping a file on the icon will also open the file. The application will open documents in separate windows, as this gives a clear 1 file = 1 window metaphor, which we fee is more natural than an MDI interface, which quickly gives a 'cramped' and 'busy' feel.
On OSX we make sure we do not show an empty window on start-up. We also implemented the proxy icon, which is a great way to map a document to it's place in the finder. Being a document centric app, we also made sure that starting in v3, XPS files can be viewed via QuickLook - all you need is the NiXPS View v3.0 installed on your Mac.
Here's a small demo of our NiXPS View v3.0 running on Windows 7:
PR online: NiXPS View v3.0 brings annotations, scripting and PDF/A conversion to XPSHere's the link to the PR. Download it in xps format here.
¶ 15:000 Comments
Friday, September 18, 2009
NiXPS View v3.0 released! Today we are releasing NiXPS View v3.0! We have worked hard to make this version the best version ever, and we are introducing a truckload of new and unique features:
Notes can be added on XPS documents
Scripts allow you to automate and extend
We've added a text correction tool
PDF conversion was enhanced, and we now also support PDF/A export
The UI has been reworked and polished, with a much improved Quicksearch and improved document interactivity with the support for links and a more natural pan tool
And much more!
For a short period of time we are offering this fantastic new version at a special launch price of USD 49 (EU 35)! (Existing v2.6 customers get this version for free.)
Give it a try and let us know what you think!
You can read more about this release here. You can download a 30-day trial here. You can buy a license here.
¶ 17:363 Comments
Thursday, September 10, 2009
Quick, look! We introduced the world's first XPS Macintosh viewer exactly 2 years ago (more here, or here, or here). We are very committed to the Mac, and to honour this we are introducing QuickLook support in our upcoming NiXPS View 3.0. Because, we really think you can do more with XPS!
¶ 17:050 Comments
Monday, September 07, 2009
NiXPS SDK powers future products of Dane Prairie Systems LLC
NiXPS is proud to announce that Dane Prairie Systems LLC has chosen its NiXPS SDK v2.6.3 for inclusion in the next generation of their software products. Read more here.
¶ 16:420 Comments
Thursday, September 03, 2009
Javascript and XPS, a match made in heaven.
Javascript is pretty ubiquitous these days. Great for quick, usefull scripts. Like drawing a barcode on top of an XPS, for instance.