Skip to content

Commit

Permalink
ImagesToPdfDocumentConverter: adds ability to turn off reading image/…
Browse files Browse the repository at this point in the history
…page rotation from exif
  • Loading branch information
ediweissmann committed May 12, 2020
1 parent dd26e51 commit dd0ac8b
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class ImagesToPdfDocumentConverter {
private PDDocumentHandler documentHandler;
private PageImageWriter imageWriter;

private boolean shouldReadRotationFromExif = true;

public ImagesToPdfDocumentConverter() {
this.documentHandler = new PDDocumentHandler();
documentHandler.setCreatorOnPDDocument();
Expand Down Expand Up @@ -121,8 +123,10 @@ public PDDocumentHandler addPage(Source<?> source, PDRectangle pageSize, PageOri
float y = ((int) mediaBox.getHeight() - height) / 2;

imageWriter.append(page, image, new Point((int) x, (int) y), width, height, null, 0);
int rotation = ExifHelper.getRotationBasedOnExifOrientation(source);
page.setRotation(rotation);
if(this.shouldReadRotationFromExif) {
int rotation = ExifHelper.getRotationBasedOnExifOrientation(source);
page.setRotation(rotation);
}

afterImage(image);
} catch (TaskIOException e) {
Expand Down Expand Up @@ -200,4 +204,12 @@ public void failedImage(Source<?> source, TaskIOException e) throws TaskExceptio
public PDDocumentHandler getDocumentHandler() {
return documentHandler;
}

public boolean isShouldReadRotationFromExif() {
return shouldReadRotationFromExif;
}

public void setShouldReadRotationFromExif(boolean shouldReadRotationFromExif) {
this.shouldReadRotationFromExif = shouldReadRotationFromExif;
}
}

0 comments on commit dd0ac8b

Please sign in to comment.