Abhishek bhadouria


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



Re: XPS to GDI conversion

CTA


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






Re: XPS to GDI conversion

Abhishek bhadouria

Hi ,
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
Regards
Abhishek





Re: XPS to GDI conversion

Jo0815

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;





Re: XPS to GDI conversion

CTA

I don't have any Jo.




Re: XPS to GDI conversion

Sasky02

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





Re: XPS to GDI conversion

Jo0815

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...





databaseforum