How to draw PDF on canvas using skia sharp?

妖精的绣舞 提交于 2020-01-25 04:17:10

问题


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();

As per the above code I'm getting canvas, but how can I draw that on my canvas view?

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

Also do I need to use scroll view to display those multiple pages on canvas?

Any help on this appreciated. Thanks.


回答1:


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

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#



来源:https://stackoverflow.com/questions/59171851/how-to-draw-pdf-on-canvas-using-skia-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!