[UWP]如何打印PDF?

人气:298 发布:2022-09-22 标签: wpdevelop

问题描述

这已经差不多3年了。任何人都有一个在UWP中打印PDF的解决方案吗?

This has almost been 3 years. Anyone has a solution for printing PDF in UWP yet?

推荐答案

嗨Gabriel,

Hi Gabriel,

我把它分开了目前还不清楚你在寻找什么。您遇到了几个非常旧的线程,其中包含与打印和PDF相关的不同问题。一般来说,提出一个新问题要比碰到一个旧问题要好得多,而且明确你要找的具体内容至关重要。

I split this out since it's not clear what you're looking for here. You bumped several very old threads with different questions related to printing and PDFs. In general it's much better to ask a new question than to bump an old one, and it's vital to be clear on what specifically you are looking for.

Windows提供PDF Windows.Data.Pdf 命名空间中的阅读和光栅API 。您可以使用它来读取PDF文件并将其页面呈现为图像,然后可以使用打印API进行打印。请参阅 从您的应用中打印。在https://github.com/Microsoft/Windows-universal-samples的示例存储库中有两个示例,但您必须将这两个部分放在一起(渲染到位图然后打印位图) )。

Windows provides a PDF reading and rastering API in the Windows.Data.Pdf namespace. You can use this to read a PDF file and render its pages to images, which you can then print with the printing API. See Print from your app. There are samples for both of these in the sample repository athttps://github.com/Microsoft/Windows-universal-samples , but you'll have to put the two pieces together (render to a bitmap and then print the bitmap).

Windows不提供PDF编写API,但在UWP中有几个第三方API。您必须查看各个第三方SDK,以了解哪种最符合您的需求。对于非常简单的PDF,您也可以自己生成格式。

Windows doesn't provide a PDF writing API, but there are several 3rd party API to do so in UWP. You'll have to look at the individual 3rd party SDKs to see which best meets your needs. For very simple PDFs you may be able to generate the formatting yourself as well.

- Rob

938