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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - C# - Using AddImageFromString with Drawing.Imaging
  FAQ FAQ  Forum Search   Register Register  Login Login

C# - Using AddImageFromString with Drawing.Imaging

 Post Reply Post Reply
Author
Message
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Topic: C# - Using AddImageFromString with Drawing.Imaging
    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");

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store