Hello, I find a bug on Document.addImageReference(Image
image, string imageName), the following code reproduce
the problem:
pdfDocument doc = new pdfDocument("Test", "Diego Mesa
Tabares");
System.Drawing.Image image =
System.Drawing.Image.FromFile(@"..\..\DigitalSignatureClasses.jpg");
doc.addImageReference(image,"DS");
//Thrown an exception, addImageReference dispose the
image
Console.WriteLine(image.Height);
pdfPage page = doc.addPage();
page.addImage(doc.getImageReference("DS"), 0, 500);
doc.createPDF("TestImageNewOutput.pdf");
After add an image reference and try to call some
method on the image that you add, you get an exception,
the problem is that pdfImageReference constructor
dispose the image!!
I fix the bug on the attach file.
-Other thing that I found is that when you use the
method Page.AddImage(pdfImageReference reference, int
x, int y) sharpPDF use the image width and image height
in pixels, by this reason the image output is too big,
the following code shows that:
pdfDocument doc = new pdfDocument("Test", "Diego
Mesa Tabares");
doc.addImageReference(@"..\..\DigitalSignatureClasses.jpg","DS");
pdfPage page = doc.addPage();
//imageReference contains the image height and width
in pixels, using them as default values the pdf output
//is too big. Using the image resolution we can
calculate a better image output size by default.
//See source code for details
page.addImage(doc.getImageReference("DS"), 0, 500);
doc.createPDF("TestImageOutput.pdf");
I fix the problem too, I attach the code and two pdf
files showing the different outputs.
Thanks to the sharpPDF developments, they are doing a
great job!!!
pdfImageReference.cs, imageElement.cs, Test.cs, TestImageOldOutput.pdf, TestImageNewOutput.pdf