Вопрос

I'm trying to render a LocalReport to a XPS file, so I can print them from a Windows Service using the XPS Print API, as it is shown in this article.

The problem I find is that I cannot render a local report directly to XPS. Maybe I can render it to an image stream, and then embed that image into a manually created XPS, but I don't like that solution too much.

I would really appreciate any advise about rendering a LocalReport to XPS.

Это было полезно?

Решение

Unfortunately, it won't be easy. Except that it is.

First off, everything has to happen within an STA thread. So you start out with threading issues.

Next, XPS documents are deeply intertwined with WPF. XPS documents expose their content as FixedDocumentSequences, which are DependencyObjects. That's all WPF. Your LocalReport is not WPF, its a Forms-based component.

Your only option is to render the report to some kind of format that can be converted to a WPF representation by some kind of parsing and rendering process you code. This might be as simple as creating images from the report, or as hard as writing an XSLX converter.

But why even bother with this in the first place? The documentation for LocalReport shows how you can print the report without dealing with XPS print paths.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top