1

All other formats (png,tiff,gif) work! Only jpeg/jpg doesn't work.

When I run the code, I am accepted to see an image in the pdf at the given location. All of the format work fine. I am able to see the image. But when I read a .jpeg/jpg image from the stream, the area where the image is suppose to be at is blank.

No Exceptions thrown.

Code Executes just fine.

Just Image is not placed in the pdf

I am using this version of pdfsharp: 1.32.3057.0

Here is the code that I am using:

AmazonS3Client client;
using (client = new AmazonS3Client(accessKey, secretKey))
{
    GetObjectRequest request = new GetObjectRequest
    {
        BucketName = bucket,
        Key = //File Location

    using (GetObjectResponse response = client.GetObject(request))
    {
        Image imgFromStream = Image.FromStream(response.ResponseStream, true, true);
        XImage image = XImage.FromGdiPlusImage(imgFromStream);
        gfx.DrawImage(image, layoutItem.Left, layoutItem.Top, image.PointWidth, image.PointHeight);
    }

}
jmogera
  • 1,689
  • 3
  • 30
  • 65

1 Answers1

0

This is using PDFSharp- MigraDoc, to add a image you can do this:

            string pic= HostingEnvironment.MapPath("~/Images/somePic.png");

And then you pass it onto some cell:

            var image = row.Cells[0].AddImage(pic);

In order to place your image to a specific area you need to align it. I have used .png but .jpg will work too. This is another post that can help you LINK

Community
  • 1
  • 1
  • 1
    The image are not in my local directory as they are coming from AWS S3. Also png works fine, its jpeg's don't – jmogera Jun 27 '14 at 17:11