Print

Print


Author: [log in to unmask]
Date: Tue May  5 23:36:16 2015
New Revision: 2916

Log:
scale images instead of going "yeah, 60 percent should fit anything"

Modified:
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java

Modified: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java	(original)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java	Tue May  5 23:36:16 2015
@@ -42,7 +42,7 @@
     public static void write(List<IPlotter> plotters, String fileName, List<String> runData) throws IOException {
         
         // Open the document and the writer.
-        Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);
+        Document document = new Document(PageSize.LETTER.rotate(), 50, 50, 50, 50);
         PdfWriter writer;
         try {
             writer = PdfWriter.getInstance(document, new FileOutputStream(fileName));
@@ -106,9 +106,9 @@
             iTextImage = com.itextpdf.text.Image.getInstance(writer, awtImage, 1f);
         } catch (BadElementException e) {
             throw new IOException(e);
-        }                 
-        iTextImage.setAbsolutePosition(50, 50);
-        iTextImage.scalePercent(60);
+        }
+        iTextImage.scaleToFit(document.getPageSize());
+        iTextImage.setAlignment(Element.ALIGN_CENTER);
         try {
             document.add(iTextImage);
         } catch (DocumentException e) {