Draw onto an XPS file
Here's another example of the capabilities of our new NiXPS SDK v2.6.
The NiXPS SDK v2.6 has the ability to do processing on existing XPS files. This means that you can modify, or in this case decorate, XPS files that are coming f.i. from a different source. In this example I demonstrate how easy it is to get access to the content stream of an XPS page, and as an example draw a red square on the page. This code could be a nice starting point for an application that would like to add a barcode, draw a watermark, etc...
So, to start off, we are going to process a given XPS file, and write the result out to another location (in C#):
public static void test_open_drawrectangle_save() { string pIn="../../examples/testfiles/Office2007_Powerpoint_Drawing_Fills_Texture.xps"; string pOut="../../examples/output/open_drawrectangle_save.xps";
Next, read the XPS file, and get a handler to the page, and page content.
NOPackage lPackage = NOPackage.readPackageFromFile(pIn); // get first page NOPage lPage = lPackage.getDocument(0).getPage(0);
// get content stream NOXFixedPage lContent = lPage.getFixedPage();
Now, let's do some drawing. We add a path, with a square geometry and in a transparant red
// append a rectangle // a rectangle is a path, we will add this in a seperate canvas (group) // and we will put this canvas at the end of the stack, so it will be displayed on top NOXPath lPath=lContent.createCanvas(lContent.getNumCanvas()).createPath(0); lPath.intialize();
// geometry: (100,100)-(200,200) lPath.setData("M 100,100 L 200,100 L 200,200 L 100,200 Z");
// color: ARGB - so full red, transparant overlay lPath.setFill("#99FF0000");
That's about it. Now save and close:
// write the XPS file out lPackage.writePackageToFile(pOut);
NOPackage.destroyPackage(ref lPackage); }
The result is the input file, with a red, transparent square that lies over on the first page. As the NiXPS SDK uses XPS natively, the only change you'll find in the file is that square, all the rest is exactly the smae as the input document.
¶ 15:280 Comments
Thursday, November 20, 2008
HP Laserjet XPS driver
A lot of printers were released this year that support XPS printing, but most of them were big, 'copier' like, office machines.
This month HP released an XPS driver for their entry level Laserjet P2030 range. At around 175€, a good laser printer for mere mortals.
This shows again that, albeit slowly, XPS is spreading. Developers will be able to leverage the fantastic new graphic capabilities that XPS brings to the Windows platform, and users will soon be able to take full advantage of the fact that both end-user and printer use the same file format. Resulting in less costly and error-prone document conversions, and true 'what you see is what you get' document printing on Windows.
¶ 15:424 Comments
Thursday, November 13, 2008
XPS Export to SVG
The following short demo video shows how you can write an app in C# in a few minutes that converts XPS file to SVG, using our new NiXPS SDK v2.6.
NiXPS SDK v2.6 Released! Today we are releasing a new version of our NiXPS software development kit: NiXPS SDK v2.6 (read the PR here).
As more and more customers are using .NET, we worked really hard in providing a much better C# interface. We already have a very elegant C++ object model, which allows you to do all kinds of high-level and low-level modifications to an XPS file, but in C# you were left with the base C api. The same power was there, but not very convenient to use. All of this changes now in the v2.6, as we have invested time and effort in offering the exact same object model for C# users, than the one that is (and keeps being) available for C++ users of the library.
However, there are also goodies for C/C++ developers.
We include a new conversion output: Scalable Vector Graphics (SVG), and made various improvements on the core technology based on feedback we have received from customers.
As we are big proponents of learning by example, we also increased the amount of examples we are supplying in our SDK. We plan on bringing these on-line too. The examples are available for both C/C++ developers and C# developers.
A lot of these examples are a result of feedback we get from prospects and customers. The information shared between our technical support and customers could benefit everyone working with, or thinking about working with, NiXPS software. That's why we are setting up a forum with the intentions to share information, experiences, questions, etc... about NiXPS software. I would like to invite you to join the NiXPS Google group. There is not much content there yet, but I'm sure this will change if more people join over time.
Finally some more info about NiXPS SDK v2.6: A full overview of this new release, including a feature matrix, can be found here. You can request a trial version by filling-in this form. Purchasing information can be found here.
Try it out, and let us know what you think!
PS. This v2.6 release is free for everyone under maintenance.
¶ 15:240 Comments
XPS in Windows 7 Last week Microsoft held its Professional Developer Conference (PDC) in Los Angeles. One of the highlights of the show was Windows 7, Microsoft's Vista sucessor. Here a NiXPS we're of course interested in Microsoft's roadmap for XPS, and we were able to find some info on this.
Windows 7 will evolve on the foundations that are being layed out by Vista, as such the printing path in 7 will be XPS based, as it is now in Vista.
The XPS Viewer in Windows 7 will get a makeover, Wictor Wilen describes this more in detail in his blog.
Adrian Ford has given an extensive presentation on the PDC about XPS in Windows 7, and how it allows you to bridge the gap between documents an printing. You can watch it here.