gpt4 book ai didi

c# - 如何在c# monotuch中打印多个页面的UITableview内容数据

转载 作者:行者123 更新时间:2023-11-29 02:45:20 25 4
gpt4 key购买 nike

我在 UITableview 中打印所有数据,它工作正常,但如果内容太长,所有内容都显示在单页中,所以我想根据 tableview 内容在多页中打印数据。

这是我的代码

            float x = tableView.Frame.X;
float y = tableView.Frame.Y;
float w = tableView.Frame.Width;
float h = tableView.ContentSize.Height;

tableView.Frame = new RectangleF (x, y, w, h);

UIGraphics.BeginImageContext(tableView.Bounds.Size);

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

UIImage newImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
NSData imgData = newImage.AsPNG();

var printInfo = UIPrintInfo.PrintInfo;

printInfo.JobName = "Test: PDF Print";

var printer = UIPrintInteractionController.SharedPrintController;

printer.PrintingItems = imgData;
printer.ShowsPageRange = true;
//printer.PrintFormatter = textFormatter;
printer.Present (true, (handler, completed, err) => {
if (!completed && err != null){
Console.WriteLine ("error");
}
} );

最佳答案

您最好的选择是提供一个 UIPrintPageRenderer 并使用它来教它如何打印您的数据。

此示例展示了如何操作:

https://github.com/xamarin/monotouch-samples/blob/master/RecipesAndPrinting/RecipePrintPageRenderer.cs

关于c# - 如何在c# monotuch中打印多个页面的UITableview内容数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25216958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com