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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Android rotating images when added to PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

124559 Jun 14,2016 05:07 PM UTC Jun 20,2016 12:46 PM UTC Xamarin.Android 6
loading
Tags: PDF
Ezra McNichols
Asked On June 14, 2016 05:07 PM UTC

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?

Praveenkumar H [Syncfusion]
Replied On 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 


Ezra McNichols
Replied On 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

Praveenkumar H [Syncfusion]
Replied On 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 


Praveenkumar H [Syncfusion]
Replied On 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 


Ezra McNichols
Replied On 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

Praveenkumar H [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;