public static byte[] ToByteArray(System.Drawing.Image p_ImageIn) { System.Drawing.ImageConverter imgConverter = new System.Drawing.ImageConverter(); Byte[] result = (Byte[])imgConverter.ConvertTo(p_ImageIn, typeof(Byte[])); return result; }
private void loadAssets() { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); arrowHeadV.Add(0, (byte[])converter.ConvertTo(System.Drawing.Image.FromStream(URIImage2Stream(new Uri(@"pack://*****:*****@"pack://application:,,,/Resources/bheartheadh.png"))), typeof(byte[]))); arrowTailV.Add(0, (byte[])converter.ConvertTo(System.Drawing.Image.FromStream(URIImage2Stream(new Uri(@"pack://*****:*****@"pack://application:,,,/Resources/bhearttailh.png"))), typeof(byte[]))); }
public async Async.Task OneNoteAddPageWithMultipart() { try { string title = "OneNoteAddPageMultipart test created this"; string htmlBody = $@"<!DOCTYPE html><html><head><title>{title}</title></head> <body>Generated from the test <p> <img src=""name:imageBlock1"" alt=""an image on the page"" width=""300"" /> </p> </body></html> "; string boundary = "MultiPartBoundary32541"; string contentType = "multipart/form-data; boundary=" + boundary; // Create the presentation part. StringContent presentation = new StringContent(htmlBody); presentation.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); presentation.Headers.ContentDisposition.Name = "Presentation"; presentation.Headers.ContentType = new MediaTypeHeaderValue("text/html"); StreamContent image; // Get an image stream. System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); var buff = (byte[])converter.ConvertTo(Microsoft.Graph.Test.Properties.Resources.hamilton, typeof(byte[])); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(buff)) { // Create the image part. image = new StreamContent(ms); image.Headers.ContentDisposition = new ContentDispositionHeaderValue(@"form-data"); image.Headers.ContentDisposition.Name = "imageBlock1"; image.Headers.ContentType = new MediaTypeHeaderValue("image/png"); // Put the multiparts together MultipartContent multiPartContent = new MultipartContent("form-data", boundary); multiPartContent.Add(presentation); multiPartContent.Add(image); // Get the multiPart stream and then send the request to add a page using the stream. testPage = await graphClient.Me.Onenote.Sections[firstSectionID].Pages.Request().AddAsync(multiPartContent); } Assert.IsNotNull(testPage, "We didn't deserialize the OnenotePage object."); Assert.IsTrue(testPage.GetType() == typeof(OnenotePage), $"Expected a OnenotePage object. Actual type is {testPage.GetType().ToString()} "); StringAssert.Contains(htmlBody, testPage.Title, "Expected: title returned in the OneNotePage object is found in the source HTML. Actual: not found."); TestPageCleanUp(); } catch (Microsoft.Graph.ServiceException e) { Assert.Fail("Error code: {0}", e.Error.Code); } catch (Exception e) { Assert.Fail("Error code: {0}", e.Message); } }
public Message(Type _type, Question _x, String _message, String _IP, String _name, bool _recount) { switch (_type) { case Type.Quest: x = _x; type = _type; IP = _IP; name = _name; if (null != _x.questionImage && _x.questionImage.CompareTo("") != 0) { type = Type.Quest; System.Drawing.Bitmap Image = new System.Drawing.Bitmap(System.IO.Directory.GetCurrentDirectory() + @"\Image\" + _x.questionImage); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); image = (byte[])converter.ConvertTo(Image, typeof(byte[])); imagename = _x.questionImage; } else { Console.WriteLine("null"); image = null; imagename = null; } break; default: x = null; message = _message; type = _type; IP = _IP; name = _name; break; } recount = _recount; }
public static Byte[] ImageToByte(System.Drawing.Image Img) { System.Drawing.ImageConverter d = new System.Drawing.ImageConverter(); Byte[] bta; bta = (Byte[])(d.ConvertTo(Img, typeof(Byte[]))); return(bta); }
public async Task OneDriveUploadLargeFile() { try { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); var buff = (byte[])converter.ConvertTo(Microsoft.Graph.Test.Properties.Resources.hamilton, typeof(byte[])); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(buff)) { // Describe the file to upload. Pass into CreateUploadSession, when the service works as expected. var props = new DriveItemUploadableProperties(); //props.Name = "_hamilton.png"; //props.Description = "This is a pictureof Mr. Hamilton."; //props.FileSystemInfo = new FileSystemInfo(); //props.FileSystemInfo.CreatedDateTime = System.DateTimeOffset.Now; //props.FileSystemInfo.LastModifiedDateTime = System.DateTimeOffset.Now; props.AdditionalData = new Dictionary <string, object>(); props.AdditionalData.Add("@microsoft.graph.conflictBehavior", "rename"); // Get the provider. // POST /v1.0/drive/items/01KGPRHTV6Y2GOVW7725BZO354PWSELRRZ:/_hamiltion.png:/microsoft.graph.createUploadSession // The CreateUploadSesssion action doesn't seem to support the options stated in the metadata. This issue has been filed. var uploadSession = await graphClient.Drive.Items["01KGPRHTV6Y2GOVW7725BZO354PWSELRRZ"].ItemWithPath("_hamilton.png").CreateUploadSession().Request().PostAsync(); var maxChunkSize = 320 * 1024; // 320 KB - Change this to your chunk size. 5MB is the default. var provider = new ChunkedUploadProvider(uploadSession, graphClient, ms, maxChunkSize); // Setup the chunk request necessities var chunkRequests = provider.GetUploadChunkRequests(); var readBuffer = new byte[maxChunkSize]; var trackedExceptions = new List <Exception>(); DriveItem itemResult = null; //upload the chunks foreach (var request in chunkRequests) { // Do your updates here: update progress bar, etc. // ... // Send chunk request var result = await provider.GetChunkRequestResponseAsync(request, readBuffer, trackedExceptions); if (result.UploadSucceeded) { itemResult = result.ItemResponse; } } // Check that upload succeeded if (itemResult == null) { // Retry the upload // ... } } } catch (Microsoft.Graph.ServiceException e) { Assert.Fail("Something happened, check out a trace. Error code: {0}", e.Error.Code); } }
/// <summary> /// Cloud Vision用のImageの型に変換する /// </summary> private Image ConvertImageFormatForV1(System.Drawing.Image img) { System.Drawing.ImageConverter imgConv = new System.Drawing.ImageConverter(); byte[] b = (byte[])imgConv.ConvertTo(img, typeof(byte[])); Image ret = Image.FromBytes(b); return(ret); }
public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2) { CompareResult cr = CompareResult.ciCompareOk; //Test to see if we have the same size of image if (bmp1.Size.Height / bmp1.Size.Width == bmp2.Size.Height / bmp2.Size.Width) { if (bmp1.Size != bmp2.Size) { if (bmp1.Size.Height > bmp2.Size.Height) { bmp1 = (new Bitmap(bmp1, bmp2.Size)); } else if (bmp1.Size.Height < bmp2.Size.Height) { bmp2 = (new Bitmap(bmp2, bmp1.Size)); } } //Convert each image to a byte array System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter(); byte[] btImage1 = new byte[1]; btImage1 = (byte[])ic.ConvertTo(bmp1, btImage1.GetType()); byte[] btImage2 = new byte[1]; btImage2 = (byte[])ic.ConvertTo(bmp2, btImage2.GetType()); //Compute a hash for each image SHA256Managed shaM = new SHA256Managed(); byte[] hash1 = shaM.ComputeHash(btImage1); byte[] hash2 = shaM.ComputeHash(btImage2); //Compare the hash values for (int i = 0; i < hash1.Length && i < hash2.Length && cr == CompareResult.ciCompareOk; i++) { if (hash1[i] != hash2[i]) { cr = CompareResult.ciPixelMismatch; } } } else { cr = CompareResult.ciAspectMismatch; } return(cr); }
public static byte[] CreateThumbnail(byte[] bytes) { using (var ms = new MemoryStream(bytes)) { var bmp = new System.Drawing.Bitmap(ms); var resized = new System.Drawing.Bitmap(bmp, new System.Drawing.Size(bmp.Width / 4, bmp.Height / 4)); var converter = new System.Drawing.ImageConverter(); var outbytes = (byte[])converter.ConvertTo(resized, typeof(byte[])); return(outbytes); } }
internal static byte[] GetContent(this HttpRequestMessage request) { System.Drawing.Image image = System.Drawing.Image.FromFile("..\\..\\Images\\UploadFileTest.jpg"); var converter = new System.Drawing.ImageConverter(); byte[] byteContent = (byte[])converter.ConvertTo(image, typeof(byte[])); var content = new ByteArrayContent(byteContent); content.Headers.Add("Content-Disposition", "form-data"); return(content); }
private byte[] ConvertImageSourceToByte(Image value) { BitmapSource bmpSource = value.Source as BitmapSource; MemoryStream ms = new MemoryStream(); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmpSource)); encoder.Save(ms); ms.Seek(0, SeekOrigin.Begin); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(ms); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); return((byte[])converter.ConvertTo(bitmap, typeof(byte[]))); }
public static byte[] AsByteArray(System.Drawing.Image image) { try { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); return((byte[])converter.ConvertTo(image, typeof(byte[]))); } catch (Exception) { return(null); } }
//get btm image , rotate it and return byte[] public static byte[] RotateImage(System.Drawing.Bitmap btm) { byte[] a = null; System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); //return (byte[])converter.ConvertTo(img, typeof(byte[])); if (btm != null) { btm.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipY); btm.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX); //convert btm to image-Google.Cloud.Vision.V1 a = (byte[])converter.ConvertTo(btm, typeof(byte[])); } return(a); }
public void InsertImageFromByteArrayRelativePositionEx() { //ExStart //ExFor:DocumentBuilder.InsertImage(Byte[], RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType) //ExSummary:Shows how to import an image from a byte array into a document using relative positions. Aspose.Words.Document doc = new Aspose.Words.Document(); DocumentBuilder builder = new DocumentBuilder(); // Prepare a byte array of an image. System.Drawing.Image image = System.Drawing.Image.FromFile(ExDir + "Aspose.Words.gif"); System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter(); byte[] imageBytes = (byte[])imageConverter.ConvertTo(image, typeof(byte[])); builder.InsertImage(imageBytes, Aspose.Words.ConvertUtil.PixelToPoint(450), Aspose.Words.ConvertUtil.PixelToPoint(144)); builder.Document.Save(ExDir + "Image.CreateFromByteArrayRelativePosition Out.doc"); //ExEnd }
public void InsertImageFromByteArrayCustomSizeEx() { //ExStart //ExFor:DocumentBuilder.InsertImage(Byte[], Double, Double) //ExSummary:Shows how to import an image into a document from a byte array, with a custom size. Aspose.Words.Document doc = new Aspose.Words.Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Prepare a byte array of an image. System.Drawing.Image image = System.Drawing.Image.FromFile(MyDir + "Aspose.Words.gif"); System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter(); byte[] imageBytes = (byte[])imageConverter.ConvertTo(image, typeof(byte[])); builder.InsertImage(imageBytes, Aspose.Words.ConvertUtil.PixelToPoint(450), Aspose.Words.ConvertUtil.PixelToPoint(144)); builder.Document.Save(MyDir + "Image.CreateFromByteArrayCustomSize Out.doc"); //ExEnd }
public void InsertImageFromByteArrayEx() { //ExStart //ExFor:DocumentBuilder.InsertImage(Byte[]) //ExSummary:Shows how to import an image from a byte array into a document. Aspose.Words.Document doc = new Aspose.Words.Document(); DocumentBuilder builder = new DocumentBuilder(); // Prepare a byte array of an image. System.Drawing.Image image = System.Drawing.Image.FromFile(ExDir + "Aspose.Words.gif"); System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter(); byte[] imageBytes = (byte[])imageConverter.ConvertTo(image, typeof (byte[])); builder.InsertImage(imageBytes); builder.Document.Save(ExDir + "Image.CreateFromByteArray Out.doc"); //ExEnd }
public static byte[] GetBytes(System.Drawing.Image image) { try { if (image != null) { System.Drawing.ImageConverter convert = new System.Drawing.ImageConverter(); Byte[] buffer = (Byte[])(convert.ConvertTo(image, typeof(Byte[]))); return(buffer); } } catch (Exception ex) { throw ex; } return(null); }
private static ImageSource ConvertFromWinFormsImage( System.Drawing.Image image ) { ImageSource imageSource = null; try { System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter(); byte[] imageBytes = ( byte[] )imageConverter.ConvertTo( image, typeof( byte[] ) ); if( imageBytes != null ) imageSource = ImageConverter.ConvertFromByteArray( imageBytes ); } catch {} return imageSource; }
public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args) { if (args.ResourceType == ResourceType.Image) { // builder.InsertImage expects a uri so inputs like "Google Logo" would normally trigger a FileNotFoundException // We can still process those inputs and find an image any way we like, as long as an image byte array is passed to args.SetData() if (args.OriginalUri == "Google Logo") { using (WebClient webClient = new WebClient()) { byte[] imageBytes = webClient.DownloadData("http://www.google.com/images/logos/ps_logo2.png"); args.SetData(imageBytes); // We need this return statement any time a resource is loaded in a custom manner return(ResourceLoadingAction.UserProvided); } } if (args.OriginalUri == "Aspose Logo") { using (WebClient webClient = new WebClient()) { byte[] imageBytes = webClient.DownloadData("https://www.aspose.com/Images/aspose-logo.jpg"); args.SetData(imageBytes); return(ResourceLoadingAction.UserProvided); } } // We can find and add an image any way we like, as long as args.SetData() is called with some image byte array as a parameter if (args.OriginalUri == "My Watermark") { System.Drawing.Image watermark = System.Drawing.Image.FromFile(MyDir + @"\Images\Watermark.png"); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); byte[] imageBytes = (byte[])converter.ConvertTo(watermark, typeof(byte[])); args.SetData(imageBytes); return(ResourceLoadingAction.UserProvided); } } // All other resources such as documents, CSS stylesheets and images passed as uris are handled as they were normally return(ResourceLoadingAction.Default); }
public static void Create(List <Exam> exams, string path) { var writer = new PdfWriter(path); var pdf = new PdfDocument(writer); var document = new Document(pdf); document.SetMargins(20, 20, 20, 20); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); var bytes = (byte[])converter.ConvertTo(Properties.Resources.wordLogo, typeof(byte[])); Paragraph p = new Paragraph(); Image logo = new Image(ImageDataFactory.Create(bytes)); p.Add(logo); p.Add(new Tab()); p.AddTabStops(new TabStop(1000, TabAlignment.RIGHT)); p.Add(DateTime.Now.ToString("MM/dd/yyyy")); document.Add(p); var table = new Table(new float[] { 2, 2, 1, 2, 2, 1 }); table.SetWidth(UnitValue.CreatePercentValue(100)); table.AddHeaderCell(new Cell().Add(new Paragraph("Zdający"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Egzaminator"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Kategoria"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Data"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Czas Trwania"))); table.AddHeaderCell(new Cell().Add(new Paragraph("Wynik"))); foreach (var exam in exams) { table.AddCell(new Cell().Add(new Paragraph(exam.Examinee.FullName))); table.AddCell(new Cell().Add(new Paragraph(exam.Examiner.FullName))); table.AddCell(new Cell().Add(new Paragraph(exam.Category))); table.AddCell(new Cell().Add(new Paragraph(exam.Date.ToString("yyyy-MM-dd")))); table.AddCell(new Cell().Add(new Paragraph(exam.Duration.ToString("t")))); table.AddCell(new Cell().Add(new Paragraph((bool)exam.Result ? "Pozytywny" : "Negatywny"))); } document.Add(table); document.Close(); }
private static ImageSource ConvertFromWinFormsImage(System.Drawing.Image image) { ImageSource imageSource = null; try { System.Drawing.ImageConverter imageConverter = new System.Drawing.ImageConverter(); byte[] imageBytes = ( byte[] )imageConverter.ConvertTo(image, typeof(byte[])); if (imageBytes != null) { imageSource = ImageConverter.ConvertFromByteArray(imageBytes); } } catch {} return(imageSource); }
public static string GetTextFromPdfBytes(byte[] byteArray) { string pdfText = ParsePdfFromText(byteArray); if (string.IsNullOrEmpty(pdfText)) { // Can't get it normally, extract from images var images = ExtractImages(byteArray); if (images.Count > 0) { Trace.TraceInformation("File has images. Trying to do OCR..."); foreach (var name in images.Keys) { //if there is a filetype save the file if (name.LastIndexOf(".") + 1 != name.Length) { Trace.TraceInformation("Parsing " + name); // Try to get the text var converter = new System.Drawing.ImageConverter(); byte[] bytes = (byte[])converter.ConvertTo(images[name], typeof(byte[])); string text = OcrHelper.DoOcr(bytes); if (string.IsNullOrEmpty(text)) { Debug.WriteLine("No text found in file " + name); Trace.TraceWarning("No text found in file " + name); } pdfText += text; // trace first 100 characters var textSubString = (pdfText.Length < 100) ? pdfText : pdfText.Substring(0, 100); Trace.TraceInformation("Text found: " + textSubString); } else { Trace.TraceInformation("Unknown file for " + name); } } } } return(pdfText); }
public static Byte[] GetBytes(System.Drawing.Image image, int width, int height = 0, long minByteWeight = 0, long maxByteWeight = 0) { try { if (image != null) { System.Drawing.Image newImage = RedimImage(image, width, height, minByteWeight, maxByteWeight); System.Drawing.ImageConverter convert = new System.Drawing.ImageConverter(); Byte[] buffer = (Byte[])(convert.ConvertTo(image, typeof(Byte[]))); return(buffer); } } catch (Exception ex) { throw ex; } return(null); }
public async Task UserUpdatePhoto() { try { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); var buff = (byte[])converter.ConvertTo(Microsoft.Graph.Test.Properties.Resources.hamilton, typeof(byte[])); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(buff)) { // Sets the user's photo. // http://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/profilephoto_update // PUT https://graph.microsoft.com/v1.0/me/photo/$value await graphClient.Me.Photo.Content.Request().PutAsync(ms); } } catch (Microsoft.Graph.ServiceException e) { Assert.Fail("Something happened, check out a trace. Error code: {0}", e.Error.Code); } }
internal static byte[] convertToImage(string svg) // $TO-DO: chane to "internal" after unit-testing { byte[] result = Array.Empty <byte>(); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); try { xmlDoc.LoadXml(svg); Svg.SvgDocument svgDoc = Svg.SvgDocument.Open(xmlDoc); System.Drawing.Bitmap img = svgDoc.Draw(); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); result = (byte[])converter.ConvertTo(img, typeof(byte[])); } catch { return(result); } return(result); }
/// <summary> /// Upload drug image /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void uploadButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.DefaultExt = ".jpg"; dialog.Filter = "JPG Files|*.jpg|JPEG Files|*.jpeg | PNG Files|*.png|GIF Files|*.gif"; if (dialog.ShowDialog() == true) { uploadButton.IsEnabled = false; string filename = (dialog.FileName); if (new System.IO.FileInfo(filename).Length <= 184320) { try { img = new System.Drawing.Bitmap(filename); } catch (Exception) { MessageBox.Show("Failed to read file", "TeleMedicine", MessageBoxButton.OK, MessageBoxImage.Error); } if (img != null) { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); edit_img = (byte[])converter.ConvertTo(img, typeof(byte[])); image1.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(img.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); MessageBox.Show("Image upload completed", "TeleMedicine", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Image upload failed", "TeleMedicine", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Image upload failed. File size limit is 180kb", "TeleMedicine", MessageBoxButton.OK, MessageBoxImage.Error); } uploadButton.IsEnabled = true; } }
/// <summary> /// Обрабатывает запрос на тестовую картинку с заданными размерами (Width and Height) /// </summary> public System.Web.Mvc.ActionResult GetImage(System.String w, System.String h) { // parse args var width = System.Int32.Parse(w); if (width <= 0) { throw new System.ArgumentOutOfRangeException("width", width, "Argument out of range, must be greater than zero."); } var height = System.Int32.Parse(h); if (height <= 0) { throw new System.ArgumentOutOfRangeException("height", height, "Argument out of range, must be greater than zero."); } var text = ""; var random = new System.Random(); for (var i = 0; i < 6; i++) { text += random.Next(10); } // keep captcha key in session this.Session["CAPTCHA"] = text; // Create a CAPTCHA image and send it as response System.Drawing.Bitmap image = null; try { // Create a new 32-bit bitmap image. image = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create a graphics object for drawing. var g = System.Drawing.Graphics.FromImage(image); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; var rect = new System.Drawing.Rectangle(0, 0, width, height); // Fill in the background. var hatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.White); g.FillRectangle(hatchBrush, rect); // Set up the text font. System.Drawing.SizeF size; var fontSize = rect.Height + 1; System.Drawing.Font font; // Adjust the font size until the text fits within the image. do { fontSize--; font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif.Name, fontSize, System.Drawing.FontStyle.Bold); size = g.MeasureString(text, font); } while (size.Width > rect.Width); // Set up the text format. var format = new System.Drawing.StringFormat(); format.Alignment = System.Drawing.StringAlignment.Center; format.LineAlignment = System.Drawing.StringAlignment.Center; // Create a path using the text and warp it randomly. var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(text, font.FontFamily, (System.Int32)font.Style, font.Size, rect, format); var v = 4F; var points = new System.Drawing.PointF[] { new System.Drawing.PointF(random.Next(rect.Width) / v, random.Next(rect.Height) / v), new System.Drawing.PointF(rect.Width - random.Next(rect.Width) / v, random.Next(rect.Height) / v), new System.Drawing.PointF(random.Next(rect.Width) / v, rect.Height - random.Next(rect.Height) / v), new System.Drawing.PointF(rect.Width - random.Next(rect.Width) / v, rect.Height - random.Next(rect.Height) / v) }; var matrix = new System.Drawing.Drawing2D.Matrix(); matrix.Translate(0F, 0F); path.Warp(points, rect, matrix, System.Drawing.Drawing2D.WarpMode.Perspective, 0F); // Draw the text. hatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LargeConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.DarkGray); g.FillPath(hatchBrush, path); // Add some random noise. int m = System.Math.Max(rect.Width, rect.Height); for (var i = 0; i < (System.Int32)(rect.Width * rect.Height / 30F); i++) { g.FillEllipse(hatchBrush, random.Next(rect.Width), random.Next(rect.Height), random.Next(m / 50), random.Next(m / 50)); } // Clean up. font.Dispose(); hatchBrush.Dispose(); g.Dispose(); // send image response var converter = new System.Drawing.ImageConverter(); return(this.File((System.Byte[])converter.ConvertTo(image, typeof(System.Byte[])), "image/jpeg")); } finally { if (image != null) { image.Dispose(); } } }
public static void ExportPdf(DataTable table) { Document doc = new Document(PageSize.A4.Rotate(), 50, 50, 50, 50); string tm = DateTime.Today.ToString("yy/MM"); int id = 0; string query = string.Format("select top 1 d_seqid from TB_FA_RECORD where d_month = '{0}' order by d_id desc", tm); using (GlobalService.Reader = DataService.GetInstance().ExecuteReader(query)) { if (!GlobalService.Reader.HasRows) { id = 0; } else { while (GlobalService.Reader.Read()) { id = GlobalService.Reader.GetInt32(0); } } } string year = string.Format("{0:yy}", DateTime.Today); string month = string.Format("{0:MM}", DateTime.Today); id += 1; string strId = id.ToString("D3"); string filename = "FA" + year + month + "_" + strId + ".pdf"; string storedPath = @"\\kdthk-dm1\MOSS$\CM\FixedAssets\test\" + filename; string insertText = string.Format("insert into TB_FA_RECORD (d_filename, d_datetime, d_month, d_seqid)" + " values ('{0}', '{1}', '{2}', '{3}')", filename, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), tm, id); DataService.GetInstance().ExecuteNonQuery(insertText); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(storedPath, FileMode.Create)); doc.Open(); System.Drawing.Bitmap bmp = System.Drawing.Image.FromHbitmap(Properties.Resources.img_kyocera.GetHbitmap()); var converter = new System.Drawing.ImageConverter(); Image img = Image.GetInstance((byte[])converter.ConvertTo(bmp, typeof(byte[]))); img.SetAbsolutePosition(0, doc.PageSize.Height - img.Height); doc.Add(img); PdfPTable ptb = null; Font headerFont = FontFactory.GetFont("Calibri", 13); Font cellFont = FontFactory.GetFont("Calibri", 10); string title = filename.Substring(0, filename.LastIndexOf(".")); PdfPCell hTitle = new PdfPCell(new Phrase("Mgt No : " + title + "\nDownload Datetime : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), headerFont)); PdfPCell hChaseNo = new PdfPCell(new Phrase("Chase No.", headerFont)); PdfPCell hItemText = new PdfPCell(new Phrase("Item Text", headerFont)); PdfPCell hPartNo = new PdfPCell(new Phrase("Part No.", headerFont)); PdfPCell hRingi = new PdfPCell(new Phrase("Ringi", headerFont)); PdfPCell hVendor = new PdfPCell(new Phrase("Vendor", headerFont)); ptb = new PdfPTable(5); ptb.SpacingBefore = 0; float width = PageSize.A4.Rotate().Width / 5; float[] headerWidths = { width - 50, width + 50, width - 50, width - 50, width + 100 }; ptb.SetWidths(headerWidths); ptb.WidthPercentage = 100; hTitle.HorizontalAlignment = Element.ALIGN_LEFT; hTitle.Colspan = 5; hTitle.Border = iTextSharp.text.Rectangle.NO_BORDER; ptb.DefaultCell.BorderWidth = 2; ptb.DefaultCell.HorizontalAlignment = 1; hChaseNo.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hItemText.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hPartNo.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hRingi.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hVendor.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); ptb.AddCell(hTitle); ptb.AddCell(hChaseNo); ptb.AddCell(hItemText); ptb.AddCell(hPartNo); ptb.AddCell(hRingi); ptb.AddCell(hVendor); foreach (DataRow row in table.Rows) { string chaseNo = row.ItemArray[0].ToString(); string itemText = row.ItemArray[1].ToString(); PdfPCell cChaseNo = new PdfPCell(new Phrase(chaseNo, cellFont)); PdfPCell cItemText = new PdfPCell(new Phrase(itemText, cellFont)); PdfPCell cPartNo = new PdfPCell(new Phrase(row.ItemArray[2].ToString(), cellFont)); PdfPCell cRingi = new PdfPCell(new Phrase(row.ItemArray[3].ToString(), cellFont)); PdfPCell cVendor = new PdfPCell(new Phrase(row.ItemArray[4].ToString(), cellFont)); ptb.AddCell(cChaseNo); ptb.AddCell(cItemText); ptb.AddCell(cPartNo); ptb.AddCell(cRingi); ptb.AddCell(cVendor); string updateText = string.Format("update TB_MOULD_MAIN set mm_pdfid = '{0}', mm_status_code = 'A' where mm_chaseno = '{1}'", title, chaseNo); DataService.GetInstance().ExecuteNonQuery(updateText); string mpa = Mould.GetMpa(chaseNo); string vendor = Mould.GetVendor(chaseNo); //string faText = string.Format("insert into TB_FA_APPROVAL (f_chaseno, f_pdfid, f_status, f_desc, f_mpa, f_vendor)" + // " values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", chaseNo, title, "IPO 1st Approval", cItemText, mpa, vendor); string faText = string.Format("insert into TB_FA_APPROVAL (f_applicant, f_type, f_chaseno, f_pdfid, f_status, f_desc, f_mpa" + ", f_vendor, f_mould) values (N'{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}')", GlobalService.Owner, "Acquisition", chaseNo, title, itemText, DataUtil.GetMpa(chaseNo), DataUtil.GetVendor(chaseNo), DataUtil.GetMouldNo(chaseNo)); DataService.GetInstance().ExecuteNonQuery(faText); } doc.Add(ptb); doc.Close(); }
public static CompareResult Compare(bool useHash, Bitmap bmp1, Bitmap bmp2, out double err, out Bitmap diff) { CompareResult cr = CompareResult.ciCompareOk; int er = 0; err = 0; diff = new Bitmap(bmp1.Width, bmp1.Height); //Test to see if we have the same size of image if (bmp1.Size != bmp2.Size) { cr = CompareResult.ciSizeMismatch; err = 100; } else { //Convert each image to a byte array System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter(); byte[] btImage1 = new byte[1]; btImage1 = (byte[])ic.ConvertTo(bmp1, btImage1.GetType()); byte[] btImage2 = new byte[1]; btImage2 = (byte[])ic.ConvertTo(bmp2, btImage2.GetType()); //Compute a hash for each image SHA256Managed shaM = new SHA256Managed(); byte[] hash1 = shaM.ComputeHash(btImage1); byte[] hash2 = shaM.ComputeHash(btImage2); //Compare the hash values if (useHash) { for (int i = 0; i < hash1.Length && i < hash2.Length; i++) { if (hash1[i] != hash2[i]) { er++; cr = CompareResult.ciPixelMismatch; } } } else { int totalPixels = 0; er = 0; for (int x = 0; x < bmp1.Width; x++) { for (int y = 0; y < bmp1.Height; y++) { totalPixels++; if (bmp1.GetPixel(x, y) != bmp2.GetPixel(x, y)) { diff.SetPixel(x, y, Color.Black); er++; cr = CompareResult.ciPixelMismatch; } else diff.SetPixel(x, y, Color.White); } } System.Diagnostics.Debug.WriteLine("Total pixels:{0}", totalPixels); System.Diagnostics.Debug.WriteLine("Diff pixels:{0}", er); if (er > 0) err = (double)er / ((double)bmp1.Height * (double)bmp1.Width); else err = 0; if (err > 0) err = Math.Round(err*100, 1); if (err > 100) err = 100; } } return cr; }
public async Async.Task OneNoteAddPageMultipartWorkaround() { try { // Get the request URL for adding a page. string requestUrl = graphClient.Me.Onenote.Sections[firstSectionID].Pages.Request().RequestUrl; string title = "OneNoteAddPageMultipart test created this"; string htmlBody = $@"<!DOCTYPE html><html><head><title>{title}</title></head> <body>Generated from the test <p> <img src=""name:imageBlock1"" alt=""an image on the page"" width=""300"" /> </p> </body></html>"; string boundary = "MultiPartBoundary32541"; string contentType = "multipart/form-data; boundary=" + boundary; HttpResponseMessage response; // Create the presentation part. StringContent presentation = new StringContent(htmlBody); presentation.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data"); presentation.Headers.ContentDisposition.Name = "Presentation"; presentation.Headers.ContentType = new MediaTypeHeaderValue("text/html"); StreamContent image; System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); var buff = (byte[])converter.ConvertTo(Microsoft.Graph.Test.Properties.Resources.hamilton, typeof(byte[])); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(buff)) { // Create the image part. image = new StreamContent(ms); image.Headers.ContentDisposition = new ContentDispositionHeaderValue(@"form-data"); image.Headers.ContentDisposition.Name = "imageBlock1"; image.Headers.ContentType = new MediaTypeHeaderValue("image/png"); // Put the multiparts togeter MultipartContent multiPartContent = new MultipartContent("form-data", boundary); multiPartContent.Add(presentation); multiPartContent.Add(image); // Create the request message and add the content. HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Post, requestUrl); hrm.Content = multiPartContent; // Send the request and get the response. response = await graphClient.HttpProvider.SendAsync(hrm); } // Get the OneNote page that we created. if (response.IsSuccessStatusCode) { // Deserialize into OneNotePage object. var content = await response.Content.ReadAsStringAsync(); testPage = graphClient.HttpProvider.Serializer.DeserializeObject <OnenotePage>(content); Assert.IsNotNull(testPage, "We didn't deserialize the OnenotePage object."); Assert.IsTrue(testPage.GetType() == typeof(OnenotePage), $"Expected a OnenotePage object. Actual type is {testPage.GetType().ToString()} "); StringAssert.Contains(testPage.Title, title, "Expected: title matches, Actual: they don't match."); TestPageCleanUp(); } else { throw new ServiceException( new Error { Code = response.StatusCode.ToString(), Message = await response.Content.ReadAsStringAsync() }); } } catch (Microsoft.Graph.ServiceException e) { Assert.Fail("Error code: {0}", e.Error.Code); } catch (Exception e) { Assert.Fail("Error code: {0}", e.Message); } }
public void UpdateWorld() { foreach (var item in Form1.currentWorld.CurrentMap.ObjectCollection.ObjectReferences.GetNodes()) { ObjectReference r = (ObjectReference)item.Value; string path = "CurrentMap/ObjectCollection/ObjectReferences/" + item.Key + "/Position"; UpdateNode(r.Position.Location, path); } for (int i = 0; i < Form1.currentWorld.CurrentMap.Roads.Length; i++) { var r = Form1.currentWorld.CurrentMap.Roads[i]; MapNodes(r.Points, "CurrentMap/Roads/" + i + "/", "Points/"); } for (int i = 0; i < Form1.currentWorld.CurrentMap.Forests.Length; i++) { var r = Form1.currentWorld.CurrentMap.Forests[i]; MapNodes(r.Polygon, "CurrentMap/Forests/" + i + "/", "Polygon/"); } if (heightfieldBitmap == null) { heightfieldBitmap = new Image(); heightfieldBitmap.Height = Form1.currentWorld.CurrentMap.TerrainHeightfield.Size * PixelScale; heightfieldBitmap.Width = heightfieldBitmap.Height; heightfieldBitmap.HorizontalAlignment = HorizontalAlignment.Left; heightfieldBitmap.VerticalAlignment = VerticalAlignment.Top; var bmp = EGE.Resources.textureToBitmap(Form1.currentWorld.CurrentMap.TerrainHeightfield.TextureName); bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone); System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); BitmapImage bmpi = new BitmapImage(); bmpi.BeginInit(); bmpi.StreamSource = new MemoryStream((byte[])converter.ConvertTo(bmp, typeof(byte[]))); bmpi.EndInit(); heightfieldBitmap.Source = bmpi; map.Children.Add(heightfieldBitmap); } Canvas.SetZIndex(heightfieldBitmap, -5); }
public byte[] converterDemo(Image x) { System.Drawing.ImageConverter _imageConverter = new System.Drawing.ImageConverter(); byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[])); return(xByte); }
public static void ApplyFixedAssetPdf(DataTable table, string title, int mouldCount, int jigCount) { Document doc = new Document(PageSize.A4.Rotate(), 50, 50, 50, 50); string path = @"\\kdthk-dm1\MOSS$\CM\FixedAssets\" + title + ".pdf"; PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create)); doc.Open(); System.Drawing.Bitmap bitmap = System.Drawing.Image.FromHbitmap(Properties.Resources.img_kyocera.GetHbitmap()); var converter = new System.Drawing.ImageConverter(); Image image = Image.GetInstance((byte[])converter.ConvertTo(bitmap, typeof(byte[]))); image.SetAbsolutePosition(0, doc.PageSize.Height - image.Height); doc.Add(image); PdfPTable pdfTable = null; Font headerFont = FontFactory.GetFont("Calibri", 13); Font cellFont = FontFactory.GetFont("Calibri", 10); string datetime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); PdfPCell chTitle = new PdfPCell(new Phrase("FaNo: " + title + "\nDownload Datetime: " + datetime, headerFont)); PdfPCell chChaseNo = new PdfPCell(new Phrase("Chase No.", headerFont)); PdfPCell chItemText = new PdfPCell(new Phrase("Item Text", headerFont)); PdfPCell chItemCode = new PdfPCell(new Phrase("Item Code", headerFont)); PdfPCell chRingi = new PdfPCell(new Phrase("Ringi No.", headerFont)); PdfPCell chVendor = new PdfPCell(new Phrase("Vendor", headerFont)); pdfTable = new PdfPTable(5); pdfTable.SpacingBefore = 0; float width = PageSize.A4.Rotate().Width / 5; float[] headerWidths = { width - 50, width + 50, width - 50, width - 50, width + 100 }; pdfTable.SetWidths(headerWidths); pdfTable.WidthPercentage = 100; chTitle.HorizontalAlignment = Element.ALIGN_LEFT; chTitle.Colspan = 5; chTitle.Border = iTextSharp.text.Rectangle.NO_BORDER; pdfTable.DefaultCell.BorderWidth = 2; pdfTable.DefaultCell.HorizontalAlignment = 1; chChaseNo.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); chItemText.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); chItemCode.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); chRingi.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); chVendor.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); pdfTable.AddCell(chTitle); pdfTable.AddCell(chChaseNo); pdfTable.AddCell(chItemText); pdfTable.AddCell(chItemCode); pdfTable.AddCell(chRingi); pdfTable.AddCell(chVendor); foreach (DataRow row in table.Rows) { string chaseno = row.ItemArray[0].ToString(); PdfPCell crChaseNo = new PdfPCell(new Phrase(row.ItemArray[0].ToString(), cellFont)); PdfPCell crItemText = new PdfPCell(new Phrase(row.ItemArray[1].ToString(), cellFont)); PdfPCell crItemCode = new PdfPCell(new Phrase(row.ItemArray[2].ToString(), cellFont)); PdfPCell crRingi = new PdfPCell(new Phrase(row.ItemArray[3].ToString(), cellFont)); PdfPCell crVendor = new PdfPCell(new Phrase(row.ItemArray[4].ToString(), cellFont)); pdfTable.AddCell(crChaseNo); pdfTable.AddCell(crItemText); pdfTable.AddCell(crItemCode); pdfTable.AddCell(crRingi); pdfTable.AddCell(crVendor); } PdfPCell footerCell = new PdfPCell(new Phrase("\nMould: " + mouldCount + " Jigs: " + jigCount + "\nTotal: " + (mouldCount + jigCount))); footerCell.HorizontalAlignment = Element.ALIGN_LEFT; footerCell.Colspan = 5; footerCell.Border = iTextSharp.text.Rectangle.NO_BORDER; pdfTable.AddCell(footerCell); doc.Add(pdfTable); doc.Close(); }
public byte[] ImageToBytes(System.Drawing.Image img) { var converter = new System.Drawing.ImageConverter(); return (byte[])converter.ConvertTo(img, typeof(byte[])); }
public static Image recieve_image(byte[] buffer) { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); return((Image)converter.ConvertTo(buffer, typeof(Image))); }
public static byte[] ImageToByte(System.Drawing.Image img) { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); return((byte[])converter.ConvertTo(img, typeof(byte[]))); }
//PROCESO DE GENERACION DE COTIZACIÓN EN SERVIDOR. ARCHIVO PDF public void GenerarCotizacionPDF(int intCodigo) { try { //OBTENER DATOS DE COTIZACION string strCaracter = "0"; ENCotizacion oCotizacion = GetCotizacionCabecera(intCodigo); string strCliente = oCotizacion.Mail_Cliente.ToString().Trim(); string strOrdenCotizacion = oCotizacion.idCotizacion.ToString().PadLeft(10, strCaracter[0]); string strCelular = oCotizacion.TelefonoCliente.ToString(); string strVehiculo = oCotizacion.Descripcion_Modelo.ToString(); string strAno = oCotizacion.Anio.ToString(); string strValor = "USD$" + oCotizacion.ValorReferencial.ToString(); //Desarrollo //string strRutaCotizacion = @"F:\DigitalBrokers\PDF\COT-" + oCotizacion.idCotizacion + ".pdf"; //Produccion //string strRutaCotizacion = @"G:/PleskVhosts/digitalbrokers.pe/app.digitalbrokers.pe/Cotizaciones/PDF/COT-" + oCotizacion.idCotizacion + ".pdf"; //cambio fabian string strRutaCotizacion = @"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/Cotizaciones/PDF/COT-" + oCotizacion.idCotizacion + ".pdf"; //if (!Directory.Exists(RutaCotizacion + strFechaArchivo)) // Directory.CreateDirectory(RutaCotizacion + strFechaArchivo); //Obtener Detalle de Cotizacion y Articulos LNCotizacionDetalle olnCotizacionDetalle = new LNCotizacionDetalle(); ENCotizacionDetalle obeCotizacionDetalle = olnCotizacionDetalle.GetCotizacionDetalle(intCodigo); //OBTENER DATOS DE DETALLE DE COTIZACION string strRimacPrecio = "USD$" + obeCotizacionDetalle.Prima_Rimac.ToString().Trim(); string strMapfrePrecio = "USD$" + obeCotizacionDetalle.Prima_Mafre.ToString().Trim(); string strPositivaPrecio = "USD$" + obeCotizacionDetalle.Prima_LaPositiva.ToString().Trim(); string strPacificoPrecio = "USD$" + obeCotizacionDetalle.Prima_Pacifico.ToString().Trim(); string strHDIPrecio = "USD$" + obeCotizacionDetalle.Prima_HDI.ToString().Trim(); if (obeCotizacionDetalle.Prima_HDI == 0) { strHDIPrecio = "CONSULTAR"; } //REQUIERE USO DE GPS string strGPSRimac = obeCotizacionDetalle.GPS_Rimac.ToString().Trim(); string strGPSMapfre = obeCotizacionDetalle.GPS_Mafre.ToString().Trim(); string strGPSPositiva = obeCotizacionDetalle.GPS_LaPositiva.ToString().Trim(); string strGPSPacifico = obeCotizacionDetalle.GPS_Pacifico.ToString().Trim(); string strGPSHDI = obeCotizacionDetalle.GPS_HDI.ToString().Trim(); //ARMAR PDF DE COTIZACION //iTextSharp.text.Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0); Document doc = new Document(PageSize.A4); //PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(strRutaCotizacion, FileMode.Create)); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(strRutaCotizacion, FileMode.OpenOrCreate)); doc.Open(); //string fontpath = ConfigurationManager.AppSettings["RUTA_FONTS"]; //FontFactory.RegisterDirectory(fontpath); doc.NewPage(); //IMAGEN DESARROLLO //System.Drawing.Bitmap logo = new System.Drawing.Bitmap(@"F:\DigitalBrokers\logo\logodb.jpg"); //IMAGEN PRODUCCION //System.Drawing.Bitmap logo = new System.Drawing.Bitmap(@"G:/PleskVhosts/digitalbrokers.pe/Documentos/logodb.jpg"); System.Drawing.Bitmap logo = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/logodb.jpg"); System.Drawing.ImageConverter imgcon = new System.Drawing.ImageConverter(); byte[] bytelogo = (byte[])imgcon.ConvertTo(logo, typeof(byte[])); iImage(doc, writer, 10, 7, 56, 20, 0, bytelogo); iTexto(doc, writer, 10, 28, 123, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "DIGITAL BROKERS S.A.C. - CORREDORES DE SEGUROS"); iTexto(doc, writer, 10, 33, 123, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "DOM.FISCAL: " + "AV. AREQUIPA 2450 - OFICINA 1205, LINCE. LIMA-PE"); iTexto(doc, writer, 10, 37, 103, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "RUC: " + "20601943493 "); iTexto(doc, writer, 10, 41, 103, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "TELEFONO: " + " PERÚ(01) 759-7746"); //RECTANGULO DERECHO iRectangle(doc, writer, 145, 15, 50, 29, 0, 0, 1); //iRectangle(doc, writer, 115, 15, 82, 29, 0, 0, 2); 82 es el ancho del cuadrado 29= alto del cuadrado iTexto(doc, writer, 145, 18, 50, 6, 0, (int)TextAlignment.Center, "ARIAL", 15, "Bold", "Normal", "#000000", "COTIZACIÓN"); //if (oCotizacion.decMontoRecargo > 0) // iTexto(doc, writer, 115, 26, 82, 6, 0, (int)TextAlignment.Center, "ARIAL", 15, "Bold", "Normal", "#000000", "URGENTE (24 HORAS)"); //else // iTexto(doc, writer, 115, 26, 82, 6, 0, (int)TextAlignment.Center, "ARIAL", 15, "Bold", "Normal", "#000000", "NORMAL (48 HORAS)"); iTexto(doc, writer, 145, 35, 50, 6, 0, (int)TextAlignment.Center, "ARIAL", 15, "Bold", "Normal", "#000000", strOrdenCotizacion); //RECTANGULO IZQUIERDA iRectangle(doc, writer, 10, 50, 104, 26, 0, 4, 1); iTexto(doc, writer, 11, 51, 16, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "SEÑOR(ES)"); iTexto(doc, writer, 28, 51, 75, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": " + strCliente); iTexto(doc, writer, 11, 58, 16, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "N° CEL"); iTexto(doc, writer, 28, 58, 75, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": " + strCelular); iTexto(doc, writer, 11, 65, 16, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "VEHICULO"); iTexto(doc, writer, 28, 65, 75, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": " + strVehiculo); //iTexto(doc, writer, 11, 72, 16, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "LOCALIDAD"); //iTexto(doc, writer, 28, 72, 75, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": " + strLocalidad); //RECTANGULO DERECHA iRectangle(doc, writer, 115, 50, 82, 26, 0, 4, 1); iTexto(doc, writer, 116, 51, 20, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "USO"); iTexto(doc, writer, 137, 51, 20, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": PARTICULAR"); iTexto(doc, writer, 116, 58, 20, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "AÑO"); iTexto(doc, writer, 137, 58, 18, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", ": " + strAno); iTexto(doc, writer, 116, 65, 20, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", "SUMA ASE"); iTexto(doc, writer, 137, 65, 40, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Bold", "Normal", "#000000", ": " + strValor.Trim()); //iTexto(doc, writer, 150, 51, 24, 3, 0, (int)TextAlignment.Right, "ARIAL", 8, "Normal", "Normal", "#000000", "FECHA:"); //iTexto(doc, writer, 175, 51, 21, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", strFecha); //iTexto(doc, writer, 150, 58, 24, 3, 0, (int)TextAlignment.Right, "ARIAL", 8, "Normal", "Normal", "#000000", "PTO. VENTA:"); //iTexto(doc, writer, 175, 58, 21, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", strPuntoVenta); //iTexto(doc, writer, 150, 65, 24, 3, 0, (int)TextAlignment.Right, "ARIAL", 8, "Normal", "Normal", "#000000", "OP:"); //iTexto(doc, writer, 175, 65, 21, 3, 0, (int)TextAlignment.Left, "ARIAL", 8, "Normal", "Normal", "#000000", strIdOrden); //RECTANGULO DETALLE //iRectangle(doc, writer, 10, 79, 187, 165, 0, 4, 1); EL ORIGINAL iRectangle(doc, writer, 10, 79, 187, 40, 0, 4, 1); iRectangle(doc, writer, 10, 84, 187, 0, 0, 0, 0.5); iTexto(doc, writer, 11, 80, 05, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Bold", "Normal", "#000000", "#"); iTexto(doc, writer, 17, 80, 92, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Bold", "Normal", "#000000", "RIMAC"); iTexto(doc, writer, 69, 80, 30, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Bold", "Normal", "#000000", "MAPFRE"); iTexto(doc, writer, 110, 80, 39, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Bold", "Normal", "#000000", "LA POSITIVA"); iTexto(doc, writer, 147, 80, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Bold", "Normal", "#000000", "PACIFICO"); iTexto(doc, writer, 174, 80, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Bold", "Normal", "#000000", "HDI"); int intItem = 1; double y = 89; // inicio desde la ultima posicion double gps = 95; // linea debajo de los precios //AGREGANDO EL DETALLE DE LOS PRECIO A CADA UNA DE LAS COMPANIAS iTexto(doc, writer, 17, y, 92, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", strRimacPrecio); iTexto(doc, writer, 69, y, 120, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", strMapfrePrecio); iTexto(doc, writer, 110, y, 135, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", strPositivaPrecio); iTexto(doc, writer, 147, y, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", strPacificoPrecio); iTexto(doc, writer, 174, y, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", strHDIPrecio); //AGREGANDO EL USO DE GPS POR COMPAÑIA iTexto(doc, writer, 17, gps, 92, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "GPS: " + strGPSRimac); iTexto(doc, writer, 69, gps, 120, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "GPS: " + strGPSMapfre); iTexto(doc, writer, 110, gps, 135, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "GPS: " + strGPSPositiva); iTexto(doc, writer, 147, gps, 17, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "GPS: " + strGPSPacifico); iTexto(doc, writer, 174, gps, 17, 3, 0, (int)TextAlignment.Left, "ARIAL", 9, "Bold", "Normal", "#000000", "GPS: " + strGPSHDI); //foreach (var Articulo in lbeCotizacionDetalleCliente) //{ // iTexto(doc, writer, 11, y, 05, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Normal", "Normal", "#000000", intItem.ToString()); // iTexto(doc, writer, 17, y, 92, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.vchDescripcionArticulo.Trim()); // iTexto(doc, writer, 81, y, 30, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.intAlto.ToString("#0") + "CM * " + Articulo.intAncho.ToString("#0") + "COL"); // iTexto(doc, writer, 120, y, 39, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.vchFechaPublicacion); // iTexto(doc, writer, 147, y, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.decPrecioUnitario.ToString("#,##0.00###")); // iTexto(doc, writer, 179, y, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.decMontoNeto.ToString("#,##0.00")); // y = y + (3.5); // if (oCotizacion.decMontoRecargo > 0) // { // iTexto(doc, writer, 17, y, 50, 3, 0, (int)TextAlignment.Left, "ARIAL", 7, "Normal", "Normal", "#000000", "Recargo"); // iTexto(doc, writer, 179, y, 17, 3, 0, (int)TextAlignment.Right, "ARIAL", 7, "Normal", "Normal", "#000000", Articulo.decMontoRecargo.ToString("#,##0.00###")); // y = y + 3.5; // } // intItem++; //} //AGREGAR LOS BENEFICIOS Y COBERTURAS EN UNA IMAGEN //IMAGEN SLIP DESARROLLO //System.Drawing.Bitmap imagenCoberturas = new System.Drawing.Bitmap(@"F:\DigitalBrokers\Beneficios\Particular.jpg"); //INICIO IMAGEN SLIP PRODUCCION DE ACUERDO AL TIPO //System.Drawing.Bitmap imagenCoberturas = null; //if (oCotizacion.UsoVehiculo == "PARTICULAR") {imagenCoberturas = new System.Drawing.Bitmap(@"G:/PleskVhosts/digitalbrokers.pe/Documentos/Beneficios/Particular.jpg"); } //if (oCotizacion.UsoVehiculo == "CHINOS") { imagenCoberturas = new System.Drawing.Bitmap(@"G:/PleskVhosts/digitalbrokers.pe/Documentos/Beneficios/Chinos.jpg"); } //if (oCotizacion.UsoVehiculo == "PICK UP") { imagenCoberturas = new System.Drawing.Bitmap(@"G:/PleskVhosts/digitalbrokers.pe/Documentos/Beneficios/PickUp.jpg"); } //if (oCotizacion.UsoVehiculo == "CHINOS PICK UP") { imagenCoberturas = new System.Drawing.Bitmap(@"G:/PleskVhosts/digitalbrokers.pe/Documentos/Beneficios/chinos.jpg"); } //cambio fabian System.Drawing.Bitmap imagenCoberturas = null; if (oCotizacion.UsoVehiculo == "PARTICULAR") { imagenCoberturas = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/Beneficios/Particular.jpg"); } if (oCotizacion.UsoVehiculo == "CHINOS") { imagenCoberturas = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/Beneficios/Chinos.jpg"); } if (oCotizacion.UsoVehiculo == "PICK UP") { imagenCoberturas = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/Beneficios/PickUp.jpg"); } if (oCotizacion.UsoVehiculo == "CHINOS PICK UP") { imagenCoberturas = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/Beneficios/chinos.jpg"); } System.Drawing.ImageConverter img2con = new System.Drawing.ImageConverter(); byte[] byteImagen = (byte[])img2con.ConvertTo(imagenCoberturas, typeof(byte[])); iImage(doc, writer, 10, 120, 189, 100, 0, byteImagen); //FIN IMAGEN SLIP PRODUCCION DE ACUERDO AL TIPO //INICIO IMAGEN PROMOCIONAL DIGITAL BROKERS System.Drawing.Bitmap imgPublicidad = null; imgPublicidad = new System.Drawing.Bitmap(@"D:/trabajo/ROBERTO/2_Web.DigitalBrokers/Web.DigitalBrokers/Web.DigitalBrokers/documentos/Beneficios/Publicidad_GEN.jpg"); System.Drawing.ImageConverter imgPublicidadAdd = new System.Drawing.ImageConverter(); byte[] byteImagenPub = (byte[])imgPublicidadAdd.ConvertTo(imgPublicidad, typeof(byte[])); iImage(doc, writer, 10, 222, 189, 20, 0, byteImagenPub); //FIN IMAGEN PROMOCIONAL DIGITAL BROKERS //RECTANGULO ABAJO CONSOLIDADO iRectangle(doc, writer, 10, 245, 187, 30, 0, 4, 1); //Linea vertical iRectangle(doc, writer, 145, 245, 0, 30, 0, 0, 0.5); //Lineas horizontales iRectangle(doc, writer, 145, 255, 52, 0, 0, 0, 0.5); iRectangle(doc, writer, 145, 265, 52, 0, 0, 0, 0.5); //iTexto(doc, writer, 149, 248, 27, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", "SUBTOTAL S/"); //iTexto(doc, writer, 180, 248, 16, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", strSubTotal); //iTexto(doc, writer, 149, 258, 27, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", "I.G.V. (18% ) S/"); //iTexto(doc, writer, 180, 258, 16, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", strIgv); //iTexto(doc, writer, 149, 268, 27, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", "TOTAL S/"); //iTexto(doc, writer, 180, 268, 16, 4, 0, (int)TextAlignment.Right, "ARIAL", 9, "Bold", "Normal", "#000000", strTotal); //TEXTO DE COTIZACION iTexto(doc, writer, 13, 251, 180, 3, 0, (int)TextAlignment.Left, "ARIAL", 12, "Bold", "Normal", "#000000", "Esta cotización tiene una vigencia de 7 días calendario"); doc.Close(); } catch (Exception err) { throw err; } }