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!
Adding Drawing.Bitmap |
Post Reply |
Author | |
Jim Sullivan
Team Player Joined: 10 Nov 05 Location: United States Status: Offline Points: 36 |
Post Options
Thanks(0)
Posted: 23 Jun 09 at 8:06PM |
I'm using ASP.NET and one of my systems generates a Drawing.Bitmap object. I need to then add that to my PDF. I tried encoding the bitmap and then using AddImageFromString, but it doesn't seem to work.
Has anyone else tried to use an AddImage function to add a bitmap from memory, not from a file?
bmp is the drawing.bitmap and enc is a Text.Encoding
|
|
Jim Sullivan
Team Player Joined: 10 Nov 05 Location: United States Status: Offline Points: 36 |
Post Options
Thanks(0)
|
I created a new app so that I could isolate my requrements. Here's the function:
The variable y returns a 0, meaning that it couldn't add the image.
|
|
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
|
This is probably just an error in your post, but you've listed both QuickPDFDLL0712 and QuickPDFDLL0713 there, which won't work.
|
|
Jim Sullivan
Team Player Joined: 10 Nov 05 Location: United States Status: Offline Points: 36 |
Post Options
Thanks(0)
|
Well... since I'm using the DLL and the wrapper, it does work. The 12 one just references the namespace, which I can set to anything I want. The only time it would cause a problem is if the function call within the DLL were changed. Or I'd be missing a reference to a new function. Neither applies in this case.
But anyway, I threw this code together in a new project, and my original project has all of the references correct.
|
|
deabrew
Newbie Joined: 19 Jan 09 Status: Offline Points: 43 |
Post Options
Thanks(0)
|
Jim,
Did you get any further with this?
|
|
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
|
Hi Jim, It looks as if you're trying to convert from a byte array to a string and then back to a byte array. The code we've provided below should provide a more direct way. The ToArray method of the stream class returns a byte array that can be passed directly to the AddImageFromString function. -------------------------- Dim bitmap As New Bitmap(100, 100) Dim graphics As Graphics = graphics.FromImage(bitmap) Dim brush As New SolidBrush(Color.Red) graphics.FillRectangle(brush, 0, 0, 100, 100) brush = New SolidBrush(Color.Blue) graphics.FillEllipse(brush, 20, 20, 60, 60) Dim ms As New IO.MemoryStream() bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp) Dim imageData As Byte() = ms.ToArray() Dim qp As New QuickPDFDLL0714.PDFLibrary("<path>\QuickPDFDLL0714.dll") qp.UnlockKey("<Insert License Key>") ' Set the images to be compressed qp.CompressImages(1) ' Load the image from the byte array qp.AddImageFromString(imageData, 0) ' Draw the image onto the page qp.DrawImage(100, 500, 200, 200) ' Save the PDF qp.SaveToFile("<path>\system.drawing.pdf") -------------------------- I hope this helps. Cheers, - Rowan.
|
|
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