[iOS] need guidance:: ! skia sharp in pcl or custom renderer for printing drawings in canvas !!

ChdoulaChdoula JPMember ✭✭

Hello guys :) , I have a XF project (pcl, ios, and android), also I'm using Skiasharp graphic library for rendering geometric shapes on the screen and its working fine using xaml and code behind, The issue is I want to print the drawing i need custom renderer and i dont know if i can use skia sharp again for drawing the pdf because skia objects are not compatible with ios! should I draw everything in native way (custom renderer) and give up on skia? or there is a way to do it?
Thanks!!

// class

class Printer : IPrintCreator
{
public bool Create(NoteType type, string filePath)
{
try
{
var printInfo = UIPrintInfo.PrintInfo;
printInfo.OutputType = UIPrintInfoOutputType.General;
printInfo.JobName = "Print PDF Sample";

            //var height = 1754;
            //var width = 1240;
            //CGSize pageSize = new CGSize(width, height);

            NSMutableData pdfData = new NSMutableData();

            try
            {
                UIGraphics.BeginPDFContext(pdfData, view____here??????????????????????????????????????????????????, null);
                UIGraphics.BeginPDFPage();
                var pdfContext = UIGraphics.GetCurrentContext();

                PrintContentPageRenderer.pview.Layer.RenderInContext(pdfContext);

                UIGraphics.EndPDFContent();



                var printer = UIPrintInteractionController.SharedPrintController;
                printInfo.OutputType = UIPrintInfoOutputType.General;
                printer.PrintingItem = view____here??????????????????????????????????????????????????;
                printer.PrintInfo = printInfo;
                printer.ShowsPageRange = true;

                printer.Present(true, (handler, completed, err) => {
                    if (!completed && err != null)
                    {
                        Console.WriteLine("error");
                    }
                });
            }
            catch (Exception ex)
            {
                //     The error domain that the printing system uses to report errors.
                var error = UIPrint.ErrorDomain;
            }

            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

Best Answer

  • ChdoulaChdoula JP ✭✭
    Accepted Answer

    I found the solution, after rendering with skiasharp, the results were extremely slow and the performance on ioS is not good at all, so I switched to native rendering Using CGContext and it works perfectly.

Answers

  • ChdoulaChdoula JPMember ✭✭
    Accepted Answer

    I found the solution, after rendering with skiasharp, the results were extremely slow and the performance on ioS is not good at all, so I switched to native rendering Using CGContext and it works perfectly.

Sign In or Register to comment.