XPS to GDI conversion
-
Wednesday, December 20, 2006 7:27 AM
Hi
i want to use XPS to GDI conversion path for GDI based printer.
From MSDN i came to know that
The XPSDrv model also provides a converter for XPS to GDI format so that Win32 applications can print XPS Documents.
Can anybody help me how can i get a postscript as an output from a XPS printer Driver.
Regards
Abhishek
All Replies
-
Wednesday, December 20, 2006 10:40 PM
Hi,
This conversion is avaiable when WPF app is printing to GDI driver, in that case it converts automatically XPS to GDI. If your driver is PScript driver then automatically you get the PS effect even from WPF app writing XPS content.
How about having last filter as PDL filter that generates PS output.
Thanks
- Proposed As Answer by Snekethan Wednesday, October 27, 2010 6:12 AM
-
Thursday, December 21, 2006 7:01 AMHi ,Yeh you are right we can have last filter as PDL filter which generates PS output.can you point me on some links where i can get some base code or info about how to convert XPS to postscript.Is WDK having any base code for this conversion???RegardsAbhishek
-
Thursday, December 21, 2006 8:19 AM
I don't think there's any code/samples for converting XPS to postscript in the WDK... and I think it's not that easy to do...
However you could have a look at the example in the WPFSamples/DocServices/DocumentSerialize folder...
this shows you how to serialize a document to an external file in one of several popular formats: flow document XAML, HTML, RTF, plain text, WordXML, or XPS... maybe it helps...another thing you should donwload is the "Microsoft Xml Paperspecification", where all of XPS is described and you could use for your conversion...
_______
@CTA: "How about having last filter as PDL filter that generates PS output."
do you have an example for how to add a PDL filter? or any link? would be interesting for me too.. (c;
-
Thursday, December 21, 2006 6:19 PMI don't have any Jo.
-
Friday, January 05, 2007 3:51 PM
This is not a direct answer to your question, but maybe this can help:
A possibility is to use the the Harlequin XPS reference RIP Microsoft bought some time ago (http://www.microsoft.com/whdc/device/print/RRIP.mspx).
This includes an XPS filter. As far as I know, it cannot generate PostScript, but can generate a TIFF from the the XPS pages. From there, in another filter placed after the Harlequin filter, you could convert the TIFF image to a PostScript image that could be printed by a PostScript printer. The conversion would be an easy matter in that case, either doing that programmatically yourself, or using one of the many converters on the market.
Not sure that covers your need, only my 2 cents! ;-)
/Sas
-
Wednesday, January 10, 2007 11:36 AM
Converting XPS to BMP, JPG, TIFF... is quite easy to do with the RenderTarget-Class...
public void SaveXpsPageToBitmap(string xpsFileName)
{
XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);
FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();
int pageCount = docSeq.References[0].GetDocument(false).Pages.Count;
// You can get the total page count from docSeq.PageCount
for(int pageNum = 0; pageNum < pageCount; pageNum ++)
{
DocumentPage docPage = docSeq.DocumentPaginator.GetPage(pageNum);
BitmapImage bitmap = new BitmapImage();
RenderTargetBitmap renderTarget =
new RenderTargetBitmap((int)docPage.Size.Width,
(int)docPage.Size.Height,
96, // WPF (Avalon) units are 96dpi based
96,
System.Windows.Media.PixelFormats.Pbgra32);
renderTarget.Render(docPage.Visual);
BitmapEncoder encoder = new BmpBitmapEncoder(); // Choose type here ie: JpegBitmapEncoder, TiffBitmapEncoder etc.
encoder.Frames.Add(BitmapFrame.Create(renderTarget));
FileStream pageOutStream = new FileStream(xpsFileName + ".Page" + pageNum + ".bmp", FileMode.Create, FileAccess.Write);
encoder.Save(pageOutStream);
pageOutStream.Close();
}
}
however if you need to manipulate the document afterwards again (inserting additional PS/PCL-commands for OMR-Codes for example), you have no chance because of using images instead of a postscript/pcl-code... -
Friday, August 01, 2008 7:35 AMcan I create a 8 Bpp from XPS document using RenderTargerBitmap?
When ever i use
RenderTargetBitmap renderTarget =
new RenderTargetBitmap((int)docPage.Size.Width,
(int)docPage.Size.Height,
96, // WPF (Avalon) units are 96dpi based
96,
System.Windows.Media.PixelFormats.Indexed8);
The method fails with an exception,
Can anyone Let me know how to create a 8 Bpp from xps document? -
Monday, August 10, 2009 10:01 AM
Hi Jo0815I want to conver XPS Document in Tiff.Your code seems to be a Pinnacle for me.Can you please explain where this code need to be inserted. In XPSDrv sample I am unable to find Render target class.Is any similar sample available in WDk?Thank you very much.Samual- Proposed As Answer by vipulmalhotra Tuesday, March 16, 2010 11:29 AM
-
Thursday, August 13, 2009 2:49 PM
Hi Samual,
RenderTargetBitmap is part of .Net (in System.Windows.Media.Imaging). You won't find it in the XPSdrv sample because managed code (.Net) is not supported for print driver development. For an alternative see the XPS Rasterization Services and sample in the Windows 7 WDK.
/aiddy
http://blogs.msdn.com/adrianford -
Tuesday, March 02, 2010 7:56 AMtry yahoo.com for omr and you will find lot of useful resources like
http://www.omrchina.comhttp://www.omrhome.comhttp://www.omrsolutions.com -
Tuesday, March 16, 2010 11:30 AMSearch yahoo.com and you will find useful sites likeforum.mess.behttp://www.gingerwebs.comwww.ozzu.com/bing-forum
-
Tuesday, September 07, 2010 6:23 AM
Hi,
This conversion is avaiable when WPF app is printing to GDI driver, in that case it converts automatically XPS to GDI. If your driver is PScript driver then automatically you get the PS effect even from WPF app writing XPS content.
How about having last filter as PDL filter that generates PS output.
Thanks
Thanks for your effort! It's helpful to me, It's quite useful. -
Wednesday, October 27, 2010 6:14 AMUse XpsRasterizer to generate raster data( tiff,png, jpeg) then embedded this raster data into your PostScript file.
C--s

