Scale Image to Fit Page
这个例子显示,PDF和单词报告,如何to scale a large image to fit on a page.
Import the DOM and Report API packages so you do not have to use long, fully-qualified class names.
importmlreportgen.dom.*importmlreportgen.report.*
Create and open a report.
% To create a Word report, change the output type from "pdf" to "docx".rpt = Report("myreport","pdf"); open(rpt);
Specify an image that is too large to fit on the page.
imgPath = which("landOcean.jpg");
Add a heading to the report.
heading = Heading1("Unscaled Image"); add(rpt,heading);
Add the image to the report using the DOMImageclass.
img1 = Image(imgPath); add(rpt,img1);
Add a heading to the report.
heading = Heading1("Image Scaled to Fit on a Page"); add(rpt,heading);
Use the DOMScaleToFitformat to scale the image to fit on the page and then, add the scaled image to the report.
img2 = Image(imgPath); img2.Style = [img2.Style {ScaleToFit}]; add(rpt,img2);
Close and view the report.
close(rpt); rptview(rpt);