you can put a banner image on your pdfs
authorjohn <john>
Sun, 18 May 2003 15:05:36 +0000 (15:05 +0000)
committerjohn <john>
Sun, 18 May 2003 15:05:36 +0000 (15:05 +0000)
source/default.properties
source/mircoders/pdf/PDFGenerator.java
web/img/pdfbanner.png [new file with mode: 0755]

index ef6d5bf..e6a3b13 100755 (executable)
@@ -265,6 +265,10 @@ Producer.HTML2FOStyleSheet=/some/dir/mir/etc/producer/html2fo.xsl
 #
 
 
+# an image which will appear at the top of the first page
+PDF.Header.Image=/home/john/mir/web/img/pdfbanner.png
+PDF.Header.ImageHeight=70
+
 # a single line of big text which will appear at the top of the first page of all generated pdfs
 
 PDF.Title.String=INDYMEDIA SOMEWHERE
index 7679103..bdfcdbe 100755 (executable)
@@ -214,27 +214,47 @@ public class PDFGenerator{
     int titleFontSize=Integer.parseInt(configuration.getString("PDF.Title.FontSize"));
     int titleLineHeight=Integer.parseInt(configuration.getString("PDF.Title.LineHeight"));
     String titleFontFamily=configuration.getString("PDF.Title.FontFamily");
-    
+    String headerImage=configuration.getString("PDF.Header.Image");
+    int headerImageHeight = Integer.parseInt(configuration.getString("PDF.Header.ImageHeight"));
+
     try {
-           
-      ColumnText ct = new ColumnText(cb);   
-      //add a basic header
-      ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
-      float[] rightCol = {rightEdge,topEdge,rightEdge,topEdge-titleLineHeight};
-      float[] leftCol = {leftEdge,topEdge,leftEdge,topEdge-titleLineHeight};
-      ct.setColumns(leftCol,rightCol);
-      ct.setYLine(topEdge);
-      ct.setAlignment(Element.ALIGN_CENTER);
-      ct.go();
+      if ((! headerImage.equals("")) && headerImageHeight != 0){
+       PdfTemplate template = cb.createTemplate(rightEdge-horizontalMargin,headerImageHeight); 
+       
+       float toYPosition=currentYPosition - headerImageHeight;
+       Image theImage = Image.getInstance(headerImage);
+       theImage.setAbsolutePosition(0,0); 
+       //      theImage.scaleAbsolute(img_width,img_height);
+       template.addImage(theImage);
       
-      currentYPosition = currentYPosition - titleLineHeight;
+       
+       cb.addTemplate(template,leftEdge,toYPosition);
+       currentYPosition = toYPosition;
+      }
+      if (! headerText.equals("")){
+       ColumnText ct = new ColumnText(cb);   
+       //add a basic header
+       ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
+       float[] rightCol = {rightEdge,currentYPosition,rightEdge,currentYPosition-titleLineHeight};
+       float[] leftCol = {leftEdge,currentYPosition,leftEdge,currentYPosition-titleLineHeight};
+       ct.setColumns(leftCol,rightCol);
+       ct.setYLine(currentYPosition);
+       ct.setAlignment(Element.ALIGN_CENTER);
+       ct.go();
       
+       currentYPosition = currentYPosition - titleLineHeight;
+      }
     }
     catch(DocumentException de) {
       logger.error(de.getMessage());
     }
+    catch(MalformedURLException de) {
+      logger.error(de.getMessage());
+    }
+    catch(IOException de) {
+      logger.error(de.getMessage());
+    }
   }
-
   public void addIndexItem(EntityContent entityContent){
     try {
 
diff --git a/web/img/pdfbanner.png b/web/img/pdfbanner.png
new file mode 100755 (executable)
index 0000000..f4eeedb
Binary files /dev/null and b/web/img/pdfbanner.png differ