We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Android rotating images when added to PDF

We're currently having an issue when creating PDF's out of images.

We have a set of images and need a PDF with one image per page.
We've written a shared class that uses Syncfusion to do this. 

For each path, we do:

using (var fileStream = new FileStream(path, FileMode.Open)) 
{
    var pdfImage = PdfImage.FromStream(fileStream);
    pageGraphics.DrawImage(pdfImage, CenteredRectangleThatFitsInPage(page, pdfImage));
}

CenteredRectangleThatFitsInPage computes a rectangle to center and maintain aspect ratio.

 It works just fine in iOS.

In Android, pictures taken in Landscape work just fine, but pictures taken in Portrait appear rotated into Landscape once converted to the PDF.

It appears that calling

PDFImage.FromStream(fileStream)

doesn't respect the EXIF data for the orientation.

Any thoughts?

6 Replies

PH Praveenkumar H Syncfusion Team June 15, 2016 12:46 PM UTC

Hi Mcnichols, 

Thank you for using syncfusion products, 

We are not able to reproduce the issue in our side, Can you please provide us the code snippet for the function “CenteredRectangleThatFitsInPage”, it will help us to find the actual issue. 

Please let us know if you need further assistance. 

With Regards, 
Praveen 



EM Ezra McNichols June 15, 2016 04:28 PM UTC

Attached is the full DocumentAssembler class we're using. 

It takes a list of image paths, an output folder, and an output file name.

If you pass it files that were taken on an iOS physical device, it works regardless of picture orientation.

If you pass it images that were taken on an Android, such as an LG G4 or a Samsung S6Edge+, landscape images get inserted fine and portrait images get rotated.


Attachment: DocumentAssembler_7582fea8.zip


PH Praveenkumar H Syncfusion Team June 16, 2016 12:43 PM UTC

Hi McNichols, 

Thank you for your update, 

We are currently creating the sample  and checking in android platform with your code and let you know the full details by tomorrow 16 June 2016. 

Please let us know if you need further assistance. 

With Regards, 
Praveen 



PH Praveenkumar H Syncfusion Team June 17, 2016 09:09 AM UTC

Hi McNichols, 

Thank you for your patience, 

We have tried your code snippet in android platform and we are not able to reproduce the issue, I have attached the output document and sample for your reference. 


Please provide us the images which causes the issue so that we will analyze further in this. 

With Regards, 
Praveen 



EM Ezra McNichols June 17, 2016 08:09 PM UTC

I modified your solution so that it takes a picture, creates a PDF out of it, and displays the PDF.

I've tested it on 3 different devices - a Samsung S5, a Samsung S6 Edge+, and an LG G4.

On each of the 3 devices, if you take the picture in landscape mode it shows up rotated in the PDF.

My modified version is attached. If you deploy it to a physical Android device and try the above steps, you will see the rotated PDF.

Thanks,
Ezra


Attachment: PDFFormTesting_c9bc6fbf.zip


PH Praveenkumar H Syncfusion Team June 20, 2016 12:46 PM UTC

Hi McNichols, 
 
Thank you for your update, 
 
We have created the Direct-trac support incident to this forum for further follow up, please login in your direct trac account to get the incident. 
 

With Regards, 
Praveen 


Loader.
Live Chat Icon For mobile
Up arrow icon