public static void CreatePdfSample(SKCanvas canvas, int width, int height) { canvas.Clear(SKColors.White); using (var paint = new SKPaint()) { paint.TextSize = 24.0f; paint.IsAntialias = true; paint.Color = new SKColor(0x9C, 0xAF, 0xB7); paint.StrokeWidth = 3; paint.TextAlign = SKTextAlign.Center; canvas.DrawText("tap to open", width / 2f, 100f, paint); } using (var stream = new SKFileWStream(Path.Combine(WorkingDirectory, "document.pdf"))) using (var document = SKDocument.CreatePdf(stream)) using (var pdfCanvas = document.BeginPage(width, height)) using (var paint = new SKPaint()) { paint.TextSize = 64.0f; paint.IsAntialias = true; paint.Color = new SKColor(0x9C, 0xAF, 0xB7); paint.IsStroke = true; paint.StrokeWidth = 3; paint.TextAlign = SKTextAlign.Center; pdfCanvas.DrawText("...PDF...", width / 2f, 100f, paint); document.EndPage(); document.Close(); } }
private void Add(SKDocument pdf, XContainer container) { using (var canvas = pdf.BeginPage((float)container.Template.Width, (float)container.Template.Height)) { _presenter.Render(canvas, _renderer, container, 0, 0); } }
private static SKDocument Referenced(SKDocument doc, SKWStream stream) { if (stream != null && doc != null) { doc.underlyingStream = stream; } return(doc); }
private static SKDocument Owned(SKDocument doc, SKWStream stream) { if (stream != null) { if (doc != null) { doc.SetDisposeChild(stream); } else { stream.Dispose(); } } return(doc); }