MSDN > 論壇首頁 > XML Paper Specification (XPS) > How do I set the resolution of 3D content and BitmapEffects in an XPS?
發問發問
 

問題How do I set the resolution of 3D content and BitmapEffects in an XPS?

  • 2006年11月2日 上午 11:39IanGMVP使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    If I use WPF's XpsDocumentWriter class either to generate an XPS file or to print, it lets me pass any Visual to the document writer's Write method. Of course, not all WPF visuals have a good representation in XPS.

    For example, XPS has no support for 3D content or elements to which a BitmapEffect has been applied. (I'm not sure if that's the complete set of content type with this problem. Obviously animated content is also a problem, but for different reasons.)

    The Write method takes care of this. If you pass it such content, either directly to the overload that takes a Visual, or indirectly by wrapping the content inside a FixedPage, it converts it to a bitmap.

    It's nice that it does this, because it means the XPS file looks about right. (Although when I print to my HP LaserJet 2200DN, bitmap effects don't get the transparency right - they bleach everything behind them a little bit even in places where they should be completely transparent.)

    The problem is that it always seems to generate the bitmaps at a fairly low resolution. I've tried various things with a PrintTicket:

    PrintTicket pt = new PrintTicket();

    pt.OutputQuality = OutputQuality.High;

    pt.PageResolution = new PageResolution(600, 600, PageQualitativeResolution.High);

    pt.PhotoPrintingIntent = PhotoPrintingIntent.PhotoBest;

     

    xpdw.Write(content, pt);

    But none of those seem to make any difference, either used one at a time, or used collectively as this example shows. The print ticket makes it into the XPS file - it I use this code and print to the XPS Document Writer in Vista, the generated XPS file contains a Page1_PT.xml print ticket that honours all my requests. Unfortunately, the bitmaps embedded into the XPS representing the 3D content and the elements with a BitmapEffect set all remain at the same low resolution.

    Printing to a real printer suffers from the same problem - the generated bitmaps look to be at the screen resolution, and not the printer resolution. This looks really bad - the output suffers from horrible 'jaggies' on 3D output. It's not quite as bad with the bitmap effects, because those at least are anti-aliased, but it still looks pretty poor, because it's nothing like as crisp as it should be.

    I've tried setting the PrintTicket at both the job level (document sequence) and the page level, but that seems to make no difference. As far as I can tell the PrintTicket info just gets dumped into the XPS file, and has no impact on how the embedded bitmaps get rendered, so I suspect the PrintTicket is the wrong place. But it was the only place I could find that let me specify resolution and print quality.

    Is there a way to cause bitmaps generated for an XPS file for 3D and BitmapEffects to come out at a higher resolution? (Either when printing - using an XpsDocumentWriter obtained from the PrintQueue.CreateXpsDocumentWriter - or when writing directly to an XpsDocument, i.e. using the XpsDocument.CreateXpsDocumentWriter method.)

所有回覆

  • 2007年2月27日 下午 06:58XPSUser 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Did you have any luck with this ?
  • 2008年8月21日 上午 03:25boomhauer 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Im facing some serious problems with xps... i think it outputs 96 dpi no matter what you do. which looks terrible on a laser printer.

     

    Another huge problem im having, is that even when printing to a PDF, all my output is rasterized- text, lines, everything represented by line vectors appear to be converted into bitmaps, and look jaggie. Printing to the XPS printer and viewing in the xps viewer looks fine - all the output is created as as vector graphics, and you can zoom in to infinity and they still look great.

     

    This behaves the same way with printing to a laser printer - even text is rasterized and looks terrible.

     

    Please someone tell me Im doing this all wrong. If things really are this bad, I simply cant use wpf's printing at all.

  • 2008年11月17日 上午 06:47Vineeth Paliath 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     


    Hi,

    iam also facing big problem with bitmapeffectgroup and xps, that is iam developing an designer application using wpf c# , so i want to apply effects to shapes when i apply emboss effect to shape using bitmapeffectgroup and generate the xps document from xaml file always i got error message when i open the xps document i generated.

    System.Windows.Markup.XamlParseException: The 'RenderTransform' attribute is invalid - The value 'NaN,0,0,NaN,-Infinity,-Infinity' is invalid according

    this is the error message i got when i open the xps file

    if i use other bimapeffects (outer glow, drop shadow, bevel, blur) it work perfectly , but when i apply the bitmapeffect group it always  gives error message

    is it the problem of bitmapeffectgroup??
    so please give a reply




  • 2009年6月3日 上午 07:18naftali5 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    I know this is a rather old post, but I encountered the same issue, and was wondering if anyone found the resolution. I searched extensively, and found a couple of places the problem was mentioned, but no resolution.

    To summarize:

    When saving a FixedPage XAML object to an XPS document, the XPS document assumes 96dpi.
    If the FixedPage is set to a width of inches * 96, the document prints correctly, but only at 96dpi.
    If the FixedPage is set to a width of inches * 300, the document assumes it is a much larger page size, again only at 96dpi. (This also makes designing the page harder, as text point size is based on 96dpi.)

    Any vector based objects work fine even at 96dpi because they are resolution independent, but 3D objects and images with BitmapEffect applied can not remain vector as xps does not support them and are rendered at 96dpi.

    Even high resolution images retain their resolution as the original image is retained, and the original size and resolution are kept.