如何使用Skia Sharp在画布上绘制PDF? [英] How to draw PDF on canvas using skia sharp?

查看:555
本文介绍了如何使用Skia Sharp在画布上绘制PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经参考了skia的正式文档: https://docs.microsoft.com/en-us/dotnet/api/skiasharp.skcanvas?view=skiasharp-1.68.1#constructing-a-pdf-document

I have referred official document of skia: https://docs.microsoft.com/en-us/dotnet/api/skiasharp.skcanvas?view=skiasharp-1.68.1#constructing-a-pdf-document

// create the document
var stream = SKFileWStream.OpenStream("document.pdf");
var document = SKDocument.CreatePdf(stream);

// get the canvas from the page
var canvas = document.BeginPage(256, 256);

// draw on the canvas ...

// end the page and document
document.EndPage();
document.Close();

根据上述代码,我正在获取画布,但是如何在画布视图上绘制画布呢?

 <skia:SKCanvasView x:Name="canvasViews"/>

我还需要使用滚动视图在画布上显示这些多个页面吗?

对此有任何帮助,我们深表感谢.谢谢.

Any help on this appreciated. Thanks.

推荐答案

我认为您对SkiaSharp支持的内容有相反的看法. SkiaSharp创建PDF文件,而不呈现它们.

I think you got the reverse issue as to what SkiaSharp supports. SkiaSharp CREATES PDF files, not renders them.

我不知道可以推荐的任何PDF渲染器,但我将从搜索SO或进行一些谷歌搜索开始.我看到了这篇文章:如何使用C#渲染pdf

I do not know of any PDF renderers offhand that I can recommend, but I would start by searching SO or doing a bit of Googling. I see this post: How to render pdfs using C#

这篇关于如何使用Skia Sharp在画布上绘制PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆