Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
C# - Using AddImageFromString with Drawing.Imaging |
Post Reply |
Author | |
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Posted: 20 Jun 12 at 12:43PM |
Bitmap bmp = new Bitmap("ThomasCook.bmp"); // Create a memory stream and save the bitmap to it Stream st = new MemoryStream(); bmp.Save(st, System.Drawing.Imaging.ImageFormat.Bmp); // Convert the stream to a byte[] so we can use it with AddImageFromString st.Position = 0; byte[] Buffer = new byte[st.Length]; st.Read(Buffer, 0, (int)st.Length); st.Dispose(); int id = QP.AddImageFromString(Buffer, 0); QP.SelectImage(id); QP.SetOrigin(1); int dpix = QP.ImageHorizontalResolution(); int dpiy = QP.ImageVerticalResolution(); if (dpix == 0) dpix = 96; if (dpiy == 0) dpiy = 96; int xx = QP.ImageWidth(); int yy = QP.ImageHeight(); double ImageWidthInPoints = (double)QP.ImageWidth() / dpix * 72.0; // assumming dpi units double ImageHeightInPoints = (double)QP.ImageHeight() / dpiy * 72.0; QP.DrawImage(0, 0, ImageWidthInPoints, ImageHeightInPoints); Buffer = null; GC.Collect(); QP.SaveToFile("out.pdf"); |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store