2 * Copyright (C) 2001, 2002 The Mir-coders group
4 * This file is part of Mir.
6 * Mir is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Mir is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Mir; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * In addition, as a special exception, The Mir-coders gives permission to link
21 * the code of this program with any library licensed under the Apache Software License,
22 * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
23 * (or with modified versions of the above that use the same license as the above),
24 * and distribute linked combinations including the two. You must obey the
25 * GNU General Public License in all respects for all of the code used other than
26 * the above mentioned libraries. If you modify this file, you may extend this
27 * exception to your version of the file, but you are not obligated to do so.
28 * If you do not wish to do so, delete this exception statement from your version.
30 package mircoders.pdf;
32 import java.io.ByteArrayOutputStream;
33 import java.io.IOException;
34 import java.net.MalformedURLException;
36 import com.lowagie.text.BadElementException;
37 import com.lowagie.text.Document;
38 import com.lowagie.text.DocumentException;
39 import com.lowagie.text.Element;
40 import com.lowagie.text.Font;
41 import com.lowagie.text.Image;
42 import com.lowagie.text.PageSize;
43 import com.lowagie.text.Paragraph;
44 import com.lowagie.text.Phrase;
45 import com.lowagie.text.pdf.BaseFont;
46 import com.lowagie.text.pdf.ColumnText;
47 import com.lowagie.text.pdf.PdfContentByte;
48 import com.lowagie.text.pdf.PdfTemplate;
49 import com.lowagie.text.pdf.PdfWriter;
51 import gnu.regexp.REException;
52 import gnu.regexp.REMatch;
53 import gnu.regexp.REMatchEnumeration;
55 import mir.config.MirPropertiesConfiguration;
56 import mir.config.MirPropertiesConfiguration$PropertiesConfigExc;
57 import mir.entity.EntityList;
58 import mir.log.LoggerWrapper;
59 import mir.misc.StringUtil;
60 import mir.util.DateTimeFunctions;
61 import mircoders.entity.EntityContent;
62 import mircoders.entity.EntityImages;
63 import mircoders.storage.DatabaseContentToMedia;
65 public class PDFGenerator{
67 public Document document;
68 public PdfWriter writer;
69 public PdfContentByte cb;
70 public String localImageDir;
71 public float currentYPosition;
72 public int currentPage;
73 public float pageWidth;
74 public float pageHeight;
75 public float verticalMargin;
76 public float horizontalMargin;
78 public float bottomEdge;
79 public float rightEdge;
80 public float leftEdge;
82 public int maxImageHeight;
83 public int maxImageWidth;
84 protected LoggerWrapper logger;
86 public int indexFontSize;
87 public int indexLineHeight;
88 public int indexFontFamily;
90 public float footerHeight;
91 public String footerText;
92 public int footerFontSize;
93 public int footerFontFamily;
95 public int metaHeight;
96 public int metaFontSize;
97 public int metaFontFamily;
99 public int descriptionLineHeight;
100 public int descriptionFontSize;
101 public int descriptionFontFamily;
103 public int contentLineHeight;
104 public int contentFontSize;
105 public int contentFontFamily;
107 public int sourceLineHeight;
108 public int sourceFontSize;
109 public int sourceFontFamily;
111 public int bigImageCaptionFontSize;
112 public int bigImageCaptionFontFamily;
114 protected MirPropertiesConfiguration configuration;
117 public PDFGenerator(ByteArrayOutputStream out){
118 logger = new LoggerWrapper("PDFGenerator");
120 configuration = MirPropertiesConfiguration.instance();
122 catch (PropertiesConfigExc e) {
123 throw new RuntimeException("Can't get configuration: " + e.getMessage());
125 localImageDir=configuration.getString("Producer.Image.Path");
128 indexFontSize = Integer.parseInt(configuration.getString("PDF.Index.FontSize"));
129 indexLineHeight = Integer.parseInt(configuration.getString("PDF.Index.LineHeight"));
130 indexFontFamily = getFontByName(configuration.getString("PDF.Index.FontFamily"));
132 footerText = configuration.getString("PDF.Footer.String");
133 footerFontSize = Integer.parseInt(configuration.getString("PDF.Footer.FontSize"));
134 footerFontFamily = getFontByName(configuration.getString("PDF.Footer.FontFamily"));
135 footerHeight = Integer.parseInt(configuration.getString("PDF.Footer.Height"));;
137 metaFontSize = Integer.parseInt(configuration.getString("PDF.Meta.FontSize"));
138 metaFontFamily = getFontByName(configuration.getString("PDF.Meta.FontFamily"));
139 metaHeight = Integer.parseInt(configuration.getString("PDF.Meta.Height"));;
141 descriptionFontSize = Integer.parseInt(configuration.getString("PDF.Description.FontSize"));
142 descriptionLineHeight = Integer.parseInt(configuration.getString("PDF.Description.LineHeight"));
143 descriptionFontFamily = getFontByName(configuration.getString("PDF.Description.FontFamily"));
145 contentFontSize = Integer.parseInt(configuration.getString("PDF.Content.FontSize"));
146 contentLineHeight = Integer.parseInt(configuration.getString("PDF.Content.LineHeight"));
147 contentFontFamily = getFontByName(configuration.getString("PDF.Content.FontFamily"));
149 sourceFontSize = Integer.parseInt(configuration.getString("PDF.Source.FontSize"));
150 sourceLineHeight = Integer.parseInt(configuration.getString("PDF.Source.LineHeight"));
151 sourceFontFamily = getFontByName(configuration.getString("PDF.Source.FontFamily"));
153 bigImageCaptionFontSize = Integer.parseInt(configuration.getString("PDF.BigImageCaption.FontSize"));
154 bigImageCaptionFontFamily = getFontByName(configuration.getString("PDF.BigImageCaption.FontFamily"));
157 catch (NumberFormatException e){
161 // step 1: make a document
163 String pageSize = configuration.getString("PDF.Pagesize");
165 if (pageSize.equals("LETTER")){
166 document = new Document(PageSize.LETTER);
171 document = new Document(PageSize.A4);
176 maxImageHeight = 250;
181 horizontalMargin = 20;
185 topEdge=pageHeight-verticalMargin;
186 bottomEdge=verticalMargin;
187 rightEdge=pageWidth-horizontalMargin;
188 leftEdge=horizontalMargin;
190 currentYPosition=topEdge;
193 String headerText = configuration.getString("PDF.Title.String");
196 writer = PdfWriter.getInstance(document, out);
197 cb = writer.getDirectContent();
200 addHeader(headerText);
202 catch(DocumentException de) {
203 logger.error(de.getMessage());
212 public void addHeader(String headerText){
213 int titleFontSize=Integer.parseInt(configuration.getString("PDF.Title.FontSize"));
214 int titleLineHeight=Integer.parseInt(configuration.getString("PDF.Title.LineHeight"));
215 String titleFontFamily=configuration.getString("PDF.Title.FontFamily");
216 String headerImage=configuration.getString("PDF.Header.Image");
217 int headerImageHeight = Integer.parseInt(configuration.getString("PDF.Header.ImageHeight"));
220 if ((! headerImage.equals("")) && headerImageHeight != 0){
221 PdfTemplate template = cb.createTemplate(rightEdge-horizontalMargin,headerImageHeight);
223 float toYPosition=currentYPosition - headerImageHeight;
224 Image theImage = Image.getInstance(headerImage);
225 theImage.setAbsolutePosition(0,0);
226 // theImage.scaleAbsolute(img_width,img_height);
227 template.addImage(theImage);
230 cb.addTemplate(template,leftEdge,toYPosition);
231 currentYPosition = toYPosition;
233 if (! headerText.equals("")){
234 ColumnText ct = new ColumnText(cb);
236 ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
237 float[] rightCol = {rightEdge,currentYPosition,rightEdge,currentYPosition-titleLineHeight};
238 float[] leftCol = {leftEdge,currentYPosition,leftEdge,currentYPosition-titleLineHeight};
239 ct.setColumns(leftCol,rightCol);
240 ct.setYLine(currentYPosition);
241 ct.setAlignment(Element.ALIGN_CENTER);
244 currentYPosition = currentYPosition - titleLineHeight;
247 catch(DocumentException de) {
248 logger.error(de.getMessage());
250 catch(MalformedURLException de) {
251 logger.error(de.getMessage());
253 catch(IOException de) {
254 logger.error(de.getMessage());
257 public void addIndexItem(EntityContent entityContent){
260 ColumnText ict = new ColumnText(cb);
261 String theTitle = entityContent.getValue("title");
262 String theCreator = entityContent.getValue("creator");
263 Phrase titleP=new Phrase(" - " + theTitle,new Font(indexFontFamily,indexFontSize,Font.BOLD));
264 Phrase creatorP=new Phrase( " :: " + theCreator,new Font(indexFontFamily,indexFontSize));
265 float toYPosition = currentYPosition - indexLineHeight;
266 float[] leftIndexCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
267 float[] rightIndexCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
269 ict.addText(creatorP);
270 ict.setColumns(leftIndexCols,rightIndexCols);
271 ict.setYLine(currentYPosition);
272 ict.setAlignment(Element.ALIGN_LEFT);
274 currentYPosition = toYPosition;
276 catch(DocumentException de) {
277 logger.error(de.getMessage());
284 private int addTextLine(ColumnText ct,int lineHeight,int alignment,float left, float right){
285 logger.debug("adding a line of text");
286 if (! enoughY(lineHeight)){
289 float toYPosition = currentYPosition - lineHeight;
290 float[] leftContentCols = {left,currentYPosition,left,toYPosition};
291 float[] rightContentCols = {right,currentYPosition,right,toYPosition};
292 ct.setColumns(leftContentCols,rightContentCols);
293 ct.setYLine(currentYPosition);
294 ct.setAlignment(alignment);
297 currentYPosition = toYPosition;
300 catch(DocumentException de) {
301 logger.error(de.getMessage());
306 public void addLine(){
308 cb.moveTo(rightEdge, currentYPosition-5);
309 cb.lineTo(leftEdge, currentYPosition-5);
311 currentYPosition = currentYPosition - 10;
315 public void addFooter(){
317 ColumnText fct = new ColumnText(cb);
319 cb.moveTo(rightEdge, bottomEdge+footerHeight-5);
320 cb.lineTo(leftEdge, bottomEdge+footerHeight-5);
322 float[] leftFooterCols = {leftEdge,bottomEdge+footerHeight-1,leftEdge,bottomEdge};
323 float[] rightFooterCols = {rightEdge,bottomEdge+footerHeight-1,rightEdge,bottomEdge};
325 Paragraph footerP=new Paragraph(footerText,new Font(footerFontFamily,footerFontSize));
326 fct.addText(footerP);
328 fct.setColumns(leftFooterCols,rightFooterCols);
329 fct.setYLine(bottomEdge+footerHeight-1);
330 fct.setAlignment(Element.ALIGN_JUSTIFIED);
333 Paragraph numberP=new Paragraph((new Integer(currentPage)).toString(),new Font(footerFontFamily,footerFontSize,Font.BOLD));
334 fct.addText(numberP);
335 fct.setAlignment(Element.ALIGN_RIGHT);
339 catch (DocumentException de){
340 logger.error(de.getMessage());
346 public void newPage(){
352 currentYPosition=topEdge;
354 catch(DocumentException de) {
355 logger.error(de.getMessage());
359 public void addArticleSeparator(){
365 cb.moveTo(rightEdge, currentYPosition-5);
366 cb.lineTo(leftEdge, currentYPosition-5);
368 currentYPosition = currentYPosition - 10;
371 public void addArticleMetaInfo(ColumnText ct,String theTitle,String theCreator,String theDate){
372 //see if we have room for the author and title
374 if (! enoughY(metaHeight)){
378 Paragraph titleP=new Paragraph(theTitle+"\n",new Font(metaFontFamily,metaFontSize,Font.BOLD));
379 Paragraph whowhenP=new Paragraph(theCreator + " " + theDate ,new Font(metaFontFamily,metaFontSize));
381 ct.addText(whowhenP);
383 ct.setYLine(currentYPosition);
384 ct.setAlignment(Element.ALIGN_LEFT);
386 float toYPosition = currentYPosition - metaHeight;
387 float[] leftHeadCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
388 float[] rightHeadCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
390 ct.setColumns(leftHeadCols,rightHeadCols);
393 currentYPosition = toYPosition;
395 catch(DocumentException de) {
396 logger.error(de.getMessage());
401 public void addArticleDescription(ColumnText ct,String theDescription){
402 // Now we add the description, one line at a time, the ct should be empty at this point
405 Paragraph descP=new Paragraph(theDescription,new Font(descriptionFontFamily,descriptionFontSize,Font.BOLD));
408 // every article has a description, so we can assume that:
409 int status = ColumnText.NO_MORE_COLUMN;
412 while ((status & ColumnText.NO_MORE_TEXT) == 0 && brake >0){
413 //there is still text left in the description.
414 status = addTextLine(ct,descriptionLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
418 logger.error("runaway description...try increasing the line height or decreasing the font size");
421 public void addArticleContent(ColumnText ct,String theContent,EntityList images){
422 //let's go ahead and add in all the body text
423 Paragraph contentP=new Paragraph(theContent,new Font(contentFontFamily,contentFontSize));
424 ct.addText(contentP);
426 int contentLinesBeforeImages=3;
427 //and assume we have at least one line of text in the content
428 int status = ColumnText.NO_MORE_COLUMN;
430 // let's add a little bit of text, like a couple of lines
432 while (((status & ColumnText.NO_MORE_TEXT) == 0) && x<contentLinesBeforeImages){
433 status=addTextLine(ct,contentLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
437 boolean addImageOnLeft = true; //we will alternate within articles
438 while (images.hasNext()){
440 EntityImages currentImage=(EntityImages) images.next();
441 float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
442 float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
443 if (img_height>maxImageHeight){
444 img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue();
445 img_height=maxImageHeight;
447 if (img_width>maxImageWidth){
448 img_height=(new Float((new Float(img_height*(maxImageWidth/img_width))).intValue())).floatValue();
449 img_width=maxImageWidth;
452 String img_title=currentImage.getValue("title");
453 String img_path=currentImage.getValue("publish_path");
455 if ((status & ColumnText.NO_MORE_TEXT) == 0){
456 // there is still text, so add an image which will have text wrapped around it, then add the text which
457 // will be on the left or the right of the image
459 float templateMinimumHeight = img_height+20;
460 float templateWidth = img_width+10;
461 float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
463 PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
466 //here we need a page check
467 if (! enoughY((new Float(templateHeight)).intValue())){
468 //ok, well just fill text to the bottom then
469 float toYPosition = bottomEdge+footerHeight;
470 float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
471 float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
472 ct.setColumns(leftBottomCols,rightBottomCols);
473 ct.setYLine(currentYPosition);
474 ct.setAlignment(Element.ALIGN_JUSTIFIED);
478 catch(DocumentException de) {
479 logger.error(de.getMessage());
484 float toYPosition=currentYPosition - templateHeight;
487 Image theImage = Image.getInstance(localImageDir+img_path);
488 theImage.scaleAbsolute(img_width,img_height);
489 theImage.setAbsolutePosition(5,13);
491 template.addImage(theImage);
492 template.beginText();
493 BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
494 template.setFontAndSize(bf, 8);
495 template.setTextMatrix(5, 3);
496 template.showText(img_title);
499 catch(BadElementException de) {
500 logger.error(de.getMessage());
502 catch(DocumentException de) {
503 logger.error(de.getMessage());
505 catch (MalformedURLException de){
506 logger.error(de.getMessage());
508 catch (IOException de){
509 logger.error(de.getMessage());
513 float leftImageTextEdge=leftEdge;
514 float rightImageTextEdge=rightEdge;
518 cb.addTemplate(template,leftEdge,toYPosition);
519 leftImageTextEdge=leftEdge+templateWidth+5;
520 addImageOnLeft = false;
523 cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
524 rightImageTextEdge = rightEdge-templateWidth-5;
525 addImageOnLeft = true;
528 logger.debug("adding template at " + leftEdge + "," + toYPosition);
530 //and fill some text while we are at it
532 float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
533 float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
534 ct.setColumns(leftBottomCols,rightBottomCols);
535 ct.setYLine(currentYPosition);
536 ct.setAlignment(Element.ALIGN_JUSTIFIED);
539 currentYPosition=toYPosition;
541 catch(DocumentException de) {
542 logger.error(de.getMessage());
548 //add an image on the left with a big caption to the right
549 currentYPosition = currentYPosition - 10;
550 float templateMinimumHeight = img_height;
551 float templateWidth = img_width;
552 float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
553 PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
554 if (! enoughY((new Float(templateHeight)).intValue())){
557 float toYPosition=currentYPosition - templateHeight;
559 Image theImage = Image.getInstance(localImageDir+img_path);
560 theImage.setAbsolutePosition(0,13);
561 theImage.scaleAbsolute(img_width,img_height);
562 template.addImage(theImage);
564 catch(BadElementException de) {
565 logger.error(de.getMessage());
567 catch(DocumentException de) {
568 logger.error(de.getMessage());
570 catch(MalformedURLException de) {
571 logger.error(de.getMessage());
573 catch(IOException de) {
574 logger.error(de.getMessage());
577 cb.addTemplate(template,leftEdge,toYPosition);
580 ColumnText cct = new ColumnText(cb);
581 float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
582 float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
584 Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
585 cct.addText(captionP);
586 cct.setColumns(leftCaptionCols,rightCaptionCols);
587 cct.setYLine(currentYPosition-5);
588 cct.setAlignment(Element.ALIGN_LEFT);
591 currentYPosition=toYPosition;
593 catch(DocumentException de) {
594 logger.error(de.getMessage());
599 //add the rest of the text which might be left
601 while ((status & ColumnText.NO_MORE_TEXT) == 0 && brake > 0){
602 status=addTextLine(ct,contentLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
606 logger.error("runaway content....try decreasing font size or increasing line height");
609 private void addArticleSource(ColumnText ct,String theSource){
610 Paragraph sourceP = new Paragraph(theSource,new Font(sourceFontFamily,sourceFontSize,Font.BOLD));
612 addTextLine(ct,sourceLineHeight,Element.ALIGN_RIGHT,leftEdge,rightEdge);
616 private boolean enoughY(int heightOfBlockToAdd){
617 if ((currentYPosition - heightOfBlockToAdd - footerHeight) < bottomEdge )
624 public void add(EntityContent entityContent){
625 logger.error("adding a content Entity");
635 * --image without text
639 EntityList images=DatabaseContentToMedia.getInstance().getImages(entityContent);
640 String isHTML = entityContent.getValue("is_html");
641 String theTitle = entityContent.getValue("title");
642 String theCreator = entityContent.getValue("creator");
643 String theDate = DateTimeFunctions.advancedDateFormat(
644 configuration.getString("RDF.Meta.DateFormat"),
645 StringUtil.convertMirInternalDateToDate(entityContent.getValue("webdb_create")),
646 configuration.getString("Mir.DefaultTimezone"));
649 String theDescriptionRaw = entityContent.getValue("description");
650 String theContentRaw = entityContent.getValue("content_data");
651 String theSource = configuration.getString("Producer.ProductionHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getValue("publish_path") + entityContent.getValue("id") + ".shtml";
655 String theContent = "";
656 String theDescription = "";
658 if (isHTML.equals("1")){
663 RE nobackslashr = new RE("\r");
664 theContent= nobackslashr.substituteAll(theContentRaw,"");
666 RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
667 theContent = HxTag.substituteAll(theContent,"\n\n");
669 RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
670 theContent = ListItemTag.substituteAll(theContent,"\n * ");
672 RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
673 theContent = ListTag.substituteAll(theContent,"\n");
675 RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
676 theContent= DivTag.substituteAll(theContent,"\n");
678 RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
679 theContent= PTag.substituteAll(theContent,"\n ");
681 RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
682 theContent= PTagClose.substituteAll(theContent,"\n");
684 RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
685 theContent= BRTag.substituteAll(theContent,"\n");
687 RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
688 REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
689 String theContentCopy=theContent;
690 while (atags.hasMoreMatches()){
691 REMatch atag = atags.nextMatch();
692 String atagString=atag.toString();
693 String atagStringHref=atag.toString(1);
694 String atagStringText=atag.toString(2);
695 int begin=theContentCopy.indexOf(atagString);
696 theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
698 theContent=theContentCopy;
700 RE noTags = new RE("<[^>]*>");
701 theContent= noTags.substituteAll(theContent," ");
703 theContent=mir.util.Translate.decode(theContent);
705 RE re1 = new RE("\r?\n\r?\n");
706 String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
708 RE re2 = new RE("\r?\n");
709 String theDescription2 = re2.substituteAll(theDescription1," ");
711 RE re3 = new RE("BREAKHERE");
712 theDescription = re3.substituteAll(theDescription2,"\n ");
716 catch(REException ree){
717 logger.error(ree.getMessage());
722 RE re1 = new RE("\r?\n\r?\n");
723 String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
724 String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
726 RE re2 = new RE("\r?\n");
727 String theContent2 = re2.substituteAll(theContent1," ");
728 String theDescription2 = re2.substituteAll(theDescription1," ");
730 RE re3 = new RE("BREAKHERE");
731 theContent = " " + re3.substituteAll(theContent2,"\n ");
732 theDescription = re3.substituteAll(theDescription2,"\n ");
735 catch(REException ree){
736 logger.error(ree.getMessage());
740 addArticleSeparator();
742 ColumnText ct = new ColumnText(cb);
744 addArticleMetaInfo(ct,theTitle,theCreator,theDate);
745 addArticleDescription(ct,theDescription);
746 addArticleContent(ct,theContent,images);
747 addArticleSource(ct,theSource);
751 public int getFontByName(String fontName) {
753 if (fontName.equalsIgnoreCase("helvetica")){
754 theFont = Font.HELVETICA;
757 if (fontName.equalsIgnoreCase("courier")) {
758 theFont = Font.COURIER;
761 if (fontName.equalsIgnoreCase("times")) {
762 theFont = Font.TIMES_ROMAN;
765 logger.error("using helvetica because I can't get font for name: "+fontName);
766 theFont = Font.HELVETICA;