private void AddImage(AsposePageDocumentInfo doc, string imageFile) { XpsDocument document = doc.Document as XpsDocument; string signatureImageName = imageFile; XpsPath path = document.AddPath(document.CreatePathGeometry("M 413.65,0 L 611.95,0 L 611.95,99.15 L 413.65,99.15 Z")); path.Clip = document.CreatePathGeometry("M 0.000008454,0 L 612,0 L 612,792 L 0.000008454,792 Z "); var imageBrush = document.CreateImageBrush(signatureImageName, new RectangleF(0, 0, 350.05f, 150.02f), new RectangleF(0, 0, 1f, 1f)); imageBrush.Transform = document.CreateMatrix(198.3f, 0, 0, 99.15f, 413.65f, 0); imageBrush.TileMode = XpsTileMode.None; path.Fill = imageBrush; }
private void AddDrawing(AsposePageDocumentInfo doc, string signatureImageStr, string outPath) { byte[] imageBytes = Convert.FromBase64String(signatureImageStr); var signatureImageFileName = outPath.Replace("xps", "png"); System.IO.File.WriteAllBytes(signatureImageFileName, imageBytes); XpsDocument document = doc.Document as XpsDocument; XpsPath path = document.AddPath(document.CreatePathGeometry("M 413.65,0 L 611.95,0 L 611.95,99.15 L 413.65,99.15 Z")); path.Clip = document.CreatePathGeometry("M 0.000008454,0 L 612,0 L 612,792 L 0.000008454,792 Z "); var imageBrush = document.CreateImageBrush(signatureImageFileName, new RectangleF(0, 0, 350.05f, 150.02f), new RectangleF(0, 0, 1f, 1f)); imageBrush.Transform = document.CreateMatrix(198.3f, 0, 0, 99.15f, 413.65f, 0); imageBrush.TileMode = XpsTileMode.None; path.Fill = imageBrush; }
private void AddText(AsposePageDocumentInfo doc, string signatureText, string signatureTextColor) { XpsDocument document = doc.Document as XpsDocument; XpsSolidColorBrush textFill = document.CreateSolidColorBrush(Color.Black); if (signatureTextColor != "") { if (!signatureTextColor.StartsWith("#")) { signatureTextColor = "#" + signatureTextColor; } textFill = document.CreateSolidColorBrush(System.Drawing.ColorTranslator.FromHtml(signatureTextColor)); } //Add glyph to the document XpsGlyphs glyphs = document.AddGlyphs("Arial", 24, FontStyle.Regular, 450f, 50f, signatureText); glyphs.Fill = textFill; }