private void AddSideBySideImage(ref IGroup Sect1HeadGroup, string URLFirst, string URLSecond) { try { m_PDFImageCount = m_PDFImageCount + 2; //draw 2 images, side by side and add to SECTION System.Drawing.Image imageOne = System.Drawing.Image.FromFile(URLFirst); int sourceWidthFirst = imageOne.Width;//go from HorizontalResolution to find size//1277//2480 int sourceHeightFirst = imageOne.Height; float nPercent = GetPercentShrink(sourceWidthFirst);//only for check[CheckImagePercentShrink(int SourceWidth)] int destWidthFirst = (int)(sourceWidthFirst * nPercent); int destHeightFirst = (int)(sourceHeightFirst * nPercent); System.Drawing.Image imageTwo = System.Drawing.Image.FromFile(URLSecond); int sourceWidthSecond = imageTwo.Width;//go from HorizontalResolution to find size//1277//2480 int sourceHeightSecond = imageTwo.Height; nPercent = GetPercentShrink(sourceWidthSecond); int destWidthSecond = (int)(sourceWidthSecond * nPercent); int destHeightSecond = (int)(sourceHeightSecond * nPercent); //full size int newImageWidth = destWidthFirst + destWidthSecond; int newImageHeight = destHeightFirst > destHeightSecond ? destHeightFirst : destHeightSecond; System.Drawing.Bitmap newImageBmp = new System.Drawing.Bitmap(newImageWidth, newImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Drawing.Graphics newImageGrx = System.Drawing.Graphics.FromImage(newImageBmp); newImageGrx.DrawImage(imageOne, 0, 0, destWidthFirst, destHeightFirst); newImageGrx.DrawImage(imageTwo, destWidthFirst, 0, destWidthFirst, destHeightSecond); //------------------------------------------------------------------------ Infragistics.Documents.Graphics.Image tif = new Infragistics.Documents.Graphics.Image((System.Drawing.Image)newImageBmp); Infragistics.Documents.Report.IImage siteImage = Sect1HeadGroup.AddImage(tif); //siteImage.KeepRatio = true; //------------------------------------------------------------------------ //must - disposing objects after use newImageBmp.Dispose(); newImageGrx.Dispose(); imageOne.Dispose(); imageTwo.Dispose(); //------------------------------------------------------------------------ } catch (Exception e) { throw new Exception("Failed to add images to PDF.\nURL Front [" + URLFirst + "].\nURL Back [" + URLSecond + "].\n" + e.Message); } } private void AddSingleImage(ref IGroup Sect1HeadGroup, string URLFirst) { try { m_PDFImageCount++; System.Drawing.Image imageOne = System.Drawing.Image.FromFile(URLFirst); int sourceWidthFirst = imageOne.Width;//go from HorizontalResolution to find size//1277//2480 int sourceHeightFirst = imageOne.Height; float nPercent = GetPercentShrink(sourceWidthFirst); int destWidthFirst = (int)(sourceWidthFirst * nPercent); int destHeightFirst = (int)(sourceHeightFirst * nPercent); System.Drawing.Bitmap newImageBmp = new System.Drawing.Bitmap(destWidthFirst, destHeightFirst); System.Drawing.Graphics newImageGrx = System.Drawing.Graphics.FromImage((System.Drawing.Image)newImageBmp); newImageGrx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; newImageGrx.DrawImage(imageOne, 0, 0, destWidthFirst, destHeightFirst); //------------------------------------------------------------------------ Infragistics.Documents.Graphics.Image tif = new Infragistics.Documents.Graphics.Image((System.Drawing.Image)newImageBmp); Infragistics.Documents.Report.IImage siteImage = Sect1HeadGroup.AddImage(tif); //siteImage.KeepRatio = true; //------------------------------------------------------------------------ //must - disposing objects after use newImageBmp.Dispose(); newImageGrx.Dispose(); imageOne.Dispose(); //------------------------------------------------------------------------ } catch (Exception e) { throw new Exception("Failed to add single image to PDF.\nURL [" + URLFirst + "].\n" + e.Message); } } private byte[] SaveToMemory() { byte[] bytesPDF = null; try { using (System.IO.MemoryStream theStream = new System.IO.MemoryStream()) { m_PDFDoc.Publish(theStream, FileFormat.PDF); bytesPDF = (byte[])Array.CreateInstance(typeof(byte), theStream.Length); theStream.Position = 0; theStream.Read(bytesPDF, 0, (int)theStream.Length); theStream.Close(); } } catch (Exception e) { throw new Exception("Failed to convert to PDF document to IO Memory Stream.\n" + e.Message); } //----------------------------------------------------------------------------------- return bytesPDF; } private void SaveToFS(string URLPdf) { try { m_PDFDoc.Publish(URLPdf, FileFormat.PDF); } catch (Exception e) { throw new Exception("Failed to store to PDF document to FS.\nURL:" + URLPdf + "\n" + e.Message); } }