从 uiwebview (iOs) 打印本地 html 文件

Posted

技术标签:

【中文标题】从 uiwebview (iOs) 打印本地 html 文件【英文标题】:Print local html file from uiwebview (iOs) 【发布时间】:2011-05-24 10:13:17 【问题描述】:

我需要在我的应用程序中引入打印功能,这是使用 phonegap 框架制作的。有从javascript实现airprint或使用本机方法的解决方案吗?谢谢。

【问题讨论】:

【参考方案1】:

使用此处建议的代码为 phonegap 创建一个插件...

https://groups.google.com/forum/#!topic/phonegap/nAt0TqsStgc

它将指向您

http://marceloprogramming.blogspot.com/2010/12/resolving-runtime-issues-with-airprint.html

【讨论】:

【参考方案2】:

在 Monotouch 中,您可以只截屏:

    public class ScreenShot

    public static UIImage TakeScreenShot (UIView view)
    
        RectangleF canvasRect = view.Bounds;
        UIGraphics.BeginImageContext (canvasRect.Size);

        CGContext ctx = UIGraphics.GetCurrentContext ();
        ctx.FillRect (canvasRect);
        view.Layer.RenderInContext (ctx);

        UIImage newImage = UIGraphics.GetImageFromCurrentImageContext ();

        UIGraphics.EndImageContext ();

        return newImage;
    

【讨论】:

以上是关于从 uiwebview (iOs) 打印本地 html 文件的主要内容,如果未能解决你的问题,请参考以下文章