Report Generator Image Rotation

4 visualizaciones (últimos 30 días)
Yannick Saenger
Yannick Saenger el 30 de En. de 2017
Respondida: Paul Kinnucan el 14 de Feb. de 2017
Hi, I'm trying to write a code which saves matlabfigures as jpg-images and imports it afterwards into the report content to create a PDF. My problem is that some of these images need to be rotated 90 degrees. I'm writing the code programatically not using the reportgenerator interface. Here is my the important part of my code:
saveas(gcf,'Daten/Report/Plot4.jpg');
Plot4_Image = Image('Daten/Report/Plot4.jpg');
Plot4_Image.Style = {ScaleToFit, PaperOrientation(Landscape)};
append(Report,Plot4_Image);
Of course this is throwing an error because there is no attibute Paperorientation for mlreportgen.dom.image.style but you get the idea what i wanna do. It semms like this should be a simple task but i just can't get the hang of it. I want the image to be rotated + 90° and fill a whole page in the PDF. I've looked into changing the orientation when the image is first saved as well but it seems like saveas has the default orientation portrait and i don't really wanna change the code of it because for all the other images portrait is fine.
Hope someone can help me!
Cheers Yannick

Respuestas (1)

Paul Kinnucan
Paul Kinnucan el 14 de Feb. de 2017
Rotating an image and printing it on a landscape page in your report is doable but not easy. Here is a recipe:
  1. Save the image as a jpg image.
  2. Rotate the image 90 degrees using the imrotate function--requires the MATLAB Image Processing Toolbox or your own rotate function (see image rotation examples)
  3. Save the rotated image.
  4. Wrap the rotated image in a DOM Image object.
  5. Save your report's current page layout.
  6. Append a landscape page layout to your report.
  7. Append the rotated image object to your report.
  8. Clone your original page layout.
  9. Append the cloned page layout to restore your report's original page layout.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by