public void ToDictionary() { // Bug #8879 var info = GetInfo(); UIGraphics.BeginPDFContext("file", RectangleF.Empty, info); }
public void ToDictionary() { if (TestRuntime.CheckXcodeVersion(9, 3)) { Assert.Ignore("Crash (at least on devices) with iOS 11.3 beta 1"); } // Bug #8879 var info = GetInfo(); UIGraphics.BeginPDFContext("file", CGRect.Empty, info); }
public static NSData ToPdf(this UIView view, RectangleF rect) { var data = new NSMutableData(); UIGraphics.BeginPDFContext(data, rect, null); UIGraphics.BeginPDFPage(); view.Draw(rect); UIGraphics.EndPDFContent(); return(data); }
public NSMutableData PrintToPdf() { var pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, PaperRect, null); PrepareForDrawingPages(new NSRange(0, NumberOfPages)); var rect = UIGraphics.PDFContextBounds; for (int i = 0; i < NumberOfPages; i++) { UIGraphics.BeginPDFPage(); DrawPage(i, rect); } UIGraphics.EndPDFContent(); return(pdfData); }
NSData CreatePDF(string text, float w, float h) { NSMutableData data = new NSMutableData(); UIGraphics.BeginPDFContext(data, new RectangleF(0, 0, w, h), null); UIGraphics.BeginPDFPage(); CGContext gctx = UIGraphics.GetCurrentContext(); gctx.ScaleCTM(1, -1); gctx.TranslateCTM(0, -25f); gctx.SelectFont("Helvetica", 25f, CGTextEncoding.MacRoman); gctx.ShowText(text); UIGraphics.EndPDFContent(); return(data); }
public static NSData PrintToPDF(this UIPrintPageRenderer renderer, CGRect paperRect) { var pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, paperRect, null); var range = new NSRange(0, renderer.NumberOfPages); renderer.PrepareForDrawingPages(range); var bounds = UIGraphics.PDFContextBounds; for (int x = 0; x < renderer.NumberOfPages; x++) { UIGraphics.BeginPDFPage(); renderer.DrawPage(x, bounds); } UIGraphics.EndPDFContent(); return(pdfData); }
void DrawPDFInMemory() { //data buffer to hold the PDF NSMutableData data = new NSMutableData(); //create a PDF with empty rectangle, which will configure it for 8.5x11 inches UIGraphics.BeginPDFContext(data, CGRect.Empty, null); //start a PDF page UIGraphics.BeginPDFPage(); using (CGContext g = UIGraphics.GetCurrentContext()) { g.ScaleCTM(1, -1); g.TranslateCTM(0, -25); g.SelectFont("Helvetica", 25, CGTextEncoding.MacRoman); g.ShowText("Hello Evolve"); } //complete a PDF page UIGraphics.EndPDFContent(); }
private NSData PrintToPDFWithRenderer(UIPrintPageRenderer renderer, CGRect paperRect) { NSMutableData pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, paperRect, null); renderer.PrepareForDrawingPages(new NSRange(0, renderer.NumberOfPages)); _ = UIGraphics.PDFContextBounds; for (int i = 0; i < renderer.NumberOfPages; i++) { UIGraphics.BeginPDFPage(); renderer.DrawPage(i, paperRect); } UIGraphics.EndPDFContent(); return(pdfData); }
private string GeneratePdf() { NSMutableData printData = new NSMutableData(); //create a PDF with empty rectangle, which will configure it for 8.5x11 inches var frame = new CGRect(0, 0, 0, 0); if (Orientation == PrintHelper.ORIENTATION.LANDSCAPE) { frame.Width = 792f; frame.Height = 612f; } else { frame.Width = 612f; frame.Height = 792f; } UIGraphics.BeginPDFContext(printData, frame, null); if (renderer != null) { for (int i = 0; i < renderer.NumberOfPages; i++) { UIGraphics.BeginPDFPage(); renderer.DrawHeaderForPage(i, new CGRect()); renderer.DrawFooterForPage(i, new CGRect()); renderer.DrawContentForPage(i, new CGRect()); renderer.DrawPage(i, new CGRect()); } } // complete a PDF page UIGraphics.EndPDFContent(); var path = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0].Path; var pdfFile = System.IO.Path.Combine(path, "test.pdf"); printData.Save(pdfFile, true); return(pdfFile); }
public void RedrawDailyStockPDF(bool DocumentSigned) { // render created preview in PDF context NSMutableData pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, GeneratedPDFView.Bounds, null); UIGraphics.BeginPDFPage(); GeneratedPDFView.Layer.RenderInContext(UIGraphics.GetCurrentContext()); UIGraphics.EndPDFContent(); // save the rendered context to disk NSError err; string pdfID = String.Format("{0}_{1}_{2}_UsedStock", MyConstants.EmployeeID, MyConstants.EmployeeName, DateTime.Now.Date.ToString("yyyy-MM-dd")); string pdfFileName; if (DocumentSigned) { pdfFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pdfID + "_Signed.pdf"); } else { pdfFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pdfID + "_Not_Signed.pdf"); } pdfData.Save(pdfFileName, true, out err); if (err != null) { err.Dispose(); err = null; } if (pdfData != null) { pdfData.Dispose(); pdfData = null; } // set up UIWebView in signature view controller this.PDFView.MultipleTouchEnabled = true; this.PDFView.ScalesPageToFit = true; this.PdfFileName = pdfFileName; if (DocumentSigned) { PDFView.LoadRequest(new NSUrlRequest(NSUrl.FromFilename(PdfFileName))); } }
public void PrintToPDF() { IDirectory dirInstance = IoCContainer.Instance.ResolveInterface <IDirectory> (); string fileName = dirInstance.GetAppRootPath() + ViewConstant.SHARE_TMP_PDF_NAME; UIGraphics.BeginPDFContext(fileName, PaperRect, new CGPDFInfo { Author = "LexisNexis Red", Title = "LexisNexis Red" }); PrepareForDrawingPages(new NSRange(0, NumberOfPages)); CGRect bounds = UIGraphics.PDFContextBounds; for (int i = 0; i < NumberOfPages; i++) { UIGraphics.BeginPDFPage(); DrawPage(i, bounds); } UIGraphics.EndPDFContent(); }
public NSMutableData PrintToPdf() { var pdfData = new NSMutableData(); // Second parameter (CGRect bounds) of BeginPDFContext controls the size of the page onto which the content is rendered ... but not the content size. // So the content (if bigger) will be clipped (both vertically and horizontally). // Also, pagenation is determinted by the content - independent of the below CGRect bounds. UIGraphics.BeginPDFContext(pdfData, PaperRect, null); //UIGraphics.BeginPDFContext(pdfData, new CGRect(0, 0, 200, 300), null); PrepareForDrawingPages(new NSRange(0, NumberOfPages)); var rect = UIGraphics.PDFContextBounds; for (int i = 0; i < NumberOfPages; i++) { UIGraphics.BeginPDFPage(); DrawPage(i, rect); } UIGraphics.EndPDFContent(); return(pdfData); }
public void RedrawPrePlumbingPDF(bool ThereAndBack, bool DocumentSigned) { if (ThereAndBack) { _navWorkflow.PopToRootViewController(false); } // render created preview in PDF context NSMutableData pdfData = new NSMutableData(); UIGraphics.BeginPDFContext(pdfData, _generatedPdfView.Bounds, null); UIGraphics.BeginPDFPage(); _generatedPdfView.Layer.RenderInContext(UIGraphics.GetCurrentContext()); UIGraphics.EndPDFContent(); // save the rendered context to disk NSError err; string pdfFileName; string pdfID = _navWorkflow._tabs._jobRunTable.CurrentCustomer.CustomerNumber.ToString() + "_PrePlumbingPDF"; if (DocumentSigned) { pdfFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pdfID + "_Signed.pdf"); } else { pdfFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), pdfID + "_Not_Signed.pdf"); } pdfData.Save(pdfFileName, true, out err); err = null; pdfData = null; // load the content into Signing view controller _navWorkflow._tabs.SignPre.PDFView.MultipleTouchEnabled = true; _navWorkflow._tabs.SignPre.PDFView.ScalesPageToFit = true; _navWorkflow._tabs.SignPre.PDFView.LoadRequest(new NSUrlRequest(NSUrl.FromFilename(pdfFileName))); pdfPrePlumbingFileName = pdfFileName; // if (ThereAndBack) _navWorkflow.PushViewController (_navWorkflow._tabs._signView, true); }
/// <summary> /// Generates the pdf contents. /// </summary> /// <returns>The pdf in NSMutable data format.</returns> public NSMutableData GeneratePDF() { // data buffer to hold the PDF var data = new NSMutableData(); // create a PDF with empty rectangle, which will configure it for 8.5x11 inches UIGraphics.BeginPDFContext(data, CGRect.Empty, null); // configure the image size according to page size of PDF file DrawImageWithBoundingBox(_resultImage.ToCGImage()); // draw table table grids for categories in observation DrawCategorySummary(); // draw table table grids for all observations DrawObservationTable(); // complete a PDF page UIGraphics.EndPDFContent(); return(data); }
private NSData PrintToPDFWithRenderer(UIPrintPageRenderer renderer, CGRect paperRect) { NSMutableData pdfData = new NSMutableData(); try { UIGraphics.BeginPDFContext(pdfData, paperRect, null); renderer.PrepareForDrawingPages(new NSRange(0, renderer.NumberOfPages)); for (int i = 0; i < renderer.NumberOfPages; i++) { UIGraphics.BeginPDFPage(); renderer.DrawPage(i, paperRect); } UIGraphics.EndPDFContent(); } catch { PDFToHtml.Status = PDFEnum.Failed; } return(pdfData); }
protected override void AddPageImpl(float width, float height) { if (_closed) { throw new Exception("Unable to add a page because the PDFContext is already closed."); } if (_tempFilePath == null) { _tempFilePath = Path.GetTempFileName(); UIGraphics.BeginPDFContext(_tempFilePath, CGRect.Empty, _documentInfo); } var pageInfo = new NSMutableDictionary(); UIGraphics.BeginPDFPage(new CGRect(0, 0, width, height), pageInfo); var context = UIGraphics.GetCurrentContext(); context.SetFillColorSpace(CGColorSpace.CreateDeviceRGB()); context.SetStrokeColorSpace(CGColorSpace.CreateDeviceRGB()); _canvas.Context = context; }