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;
33 import gnu.regexp.REException;
34 import gnu.regexp.REMatch;
35 import gnu.regexp.REMatchEnumeration;
37 import java.io.ByteArrayOutputStream;
38 import java.io.IOException;
39 import java.net.MalformedURLException;
40 import java.util.Iterator;
42 import mir.config.MirPropertiesConfiguration;
43 import mir.entity.EntityBrowser;
44 import mir.log.LoggerWrapper;
45 import mir.misc.StringUtil;
46 import mir.util.DateTimeFunctions;
47 import mircoders.entity.EntityContent;
48 import mircoders.entity.EntityImages;
49 import mircoders.storage.DatabaseImages;
51 import com.lowagie.text.BadElementException;
52 import com.lowagie.text.Document;
53 import com.lowagie.text.DocumentException;
54 import com.lowagie.text.Element;
55 import com.lowagie.text.Font;
56 import com.lowagie.text.Image;
57 import com.lowagie.text.PageSize;
58 import com.lowagie.text.Paragraph;
59 import com.lowagie.text.Phrase;
60 import com.lowagie.text.pdf.BaseFont;
61 import com.lowagie.text.pdf.ColumnText;
62 import com.lowagie.text.pdf.PdfContentByte;
63 import com.lowagie.text.pdf.PdfTemplate;
64 import com.lowagie.text.pdf.PdfWriter;
66 public class PDFGenerator{
68 public Document document;
69 public PdfWriter writer;
70 public PdfContentByte cb;
71 public String localImageDir;
72 public float currentYPosition;
73 public int currentPage;
74 public float pageWidth;
75 public float pageHeight;
76 public float verticalMargin;
77 public float horizontalMargin;
79 public float bottomEdge;
80 public float rightEdge;
81 public float leftEdge;
83 public int maxImageHeight;
84 public int maxImageWidth;
85 protected LoggerWrapper logger;
87 public int indexFontSize;
88 public int indexLineHeight;
89 public int indexFontFamily;
91 public float footerHeight;
92 public String footerText;
93 public int footerFontSize;
94 public int footerFontFamily;
96 public int metaHeight;
97 public int metaFontSize;
98 public int metaFontFamily;
100 public int descriptionLineHeight;
101 public int descriptionFontSize;
102 public int descriptionFontFamily;
104 public int contentLineHeight;
105 public int contentFontSize;
106 public int contentFontFamily;
108 public int sourceLineHeight;
109 public int sourceFontSize;
110 public int sourceFontFamily;
112 public int bigImageCaptionFontSize;
113 public int bigImageCaptionFontFamily;
115 protected MirPropertiesConfiguration configuration;
118 public PDFGenerator(ByteArrayOutputStream out){
119 logger = new LoggerWrapper("PDFGenerator");
121 configuration = MirPropertiesConfiguration.instance();
123 catch (MirPropertiesConfiguration.PropertiesConfigExc e) {
124 throw new RuntimeException("Can't get configuration: " + e.getMessage());
126 localImageDir=configuration.getString("Producer.Image.Path");
129 indexFontSize = Integer.parseInt(configuration.getString("PDF.Index.FontSize"));
130 indexLineHeight = Integer.parseInt(configuration.getString("PDF.Index.LineHeight"));
131 indexFontFamily = getFontByName(configuration.getString("PDF.Index.FontFamily"));
133 footerText = configuration.getString("PDF.Footer.String");
134 footerFontSize = Integer.parseInt(configuration.getString("PDF.Footer.FontSize"));
135 footerFontFamily = getFontByName(configuration.getString("PDF.Footer.FontFamily"));
136 footerHeight = Integer.parseInt(configuration.getString("PDF.Footer.Height"));;
138 metaFontSize = Integer.parseInt(configuration.getString("PDF.Meta.FontSize"));
139 metaFontFamily = getFontByName(configuration.getString("PDF.Meta.FontFamily"));
140 metaHeight = Integer.parseInt(configuration.getString("PDF.Meta.Height"));;
142 descriptionFontSize = Integer.parseInt(configuration.getString("PDF.Description.FontSize"));
143 descriptionLineHeight = Integer.parseInt(configuration.getString("PDF.Description.LineHeight"));
144 descriptionFontFamily = getFontByName(configuration.getString("PDF.Description.FontFamily"));
146 contentFontSize = Integer.parseInt(configuration.getString("PDF.Content.FontSize"));
147 contentLineHeight = Integer.parseInt(configuration.getString("PDF.Content.LineHeight"));
148 contentFontFamily = getFontByName(configuration.getString("PDF.Content.FontFamily"));
150 sourceFontSize = Integer.parseInt(configuration.getString("PDF.Source.FontSize"));
151 sourceLineHeight = Integer.parseInt(configuration.getString("PDF.Source.LineHeight"));
152 sourceFontFamily = getFontByName(configuration.getString("PDF.Source.FontFamily"));
154 bigImageCaptionFontSize = Integer.parseInt(configuration.getString("PDF.BigImageCaption.FontSize"));
155 bigImageCaptionFontFamily = getFontByName(configuration.getString("PDF.BigImageCaption.FontFamily"));
158 catch (NumberFormatException e){
162 // step 1: make a document
164 String pageSize = configuration.getString("PDF.Pagesize");
166 if (pageSize.equals("LETTER")){
167 document = new Document(PageSize.LETTER);
172 document = new Document(PageSize.A4);
177 maxImageHeight = 250;
182 horizontalMargin = 20;
186 topEdge=pageHeight-verticalMargin;
187 bottomEdge=verticalMargin;
188 rightEdge=pageWidth-horizontalMargin;
189 leftEdge=horizontalMargin;
191 currentYPosition=topEdge;
194 String headerText = configuration.getString("PDF.Title.String");
197 writer = PdfWriter.getInstance(document, out);
198 cb = writer.getDirectContent();
201 addHeader(headerText);
203 catch(DocumentException de) {
204 logger.error(de.getMessage());
213 public void addHeader(String headerText){
214 int titleFontSize=Integer.parseInt(configuration.getString("PDF.Title.FontSize"));
215 int titleLineHeight=Integer.parseInt(configuration.getString("PDF.Title.LineHeight"));
216 String titleFontFamily=configuration.getString("PDF.Title.FontFamily");
217 String headerImage=configuration.getString("PDF.Header.Image");
218 int headerImageHeight = Integer.parseInt(configuration.getString("PDF.Header.ImageHeight"));
221 if ((! headerImage.equals("")) && headerImageHeight != 0){
222 PdfTemplate template = cb.createTemplate(rightEdge-horizontalMargin,headerImageHeight);
224 float toYPosition=currentYPosition - headerImageHeight;
225 Image theImage = Image.getInstance(headerImage);
226 theImage.setAbsolutePosition(0,0);
227 // theImage.scaleAbsolute(img_width,img_height);
228 template.addImage(theImage);
231 cb.addTemplate(template,leftEdge,toYPosition);
232 currentYPosition = toYPosition;
234 if (! headerText.equals("")){
235 ColumnText ct = new ColumnText(cb);
237 ct.addText(new Phrase(headerText, new Font(getFontByName(titleFontFamily), titleFontSize,Font.BOLD)));
238 float[] rightCol = {rightEdge,currentYPosition,rightEdge,currentYPosition-titleLineHeight};
239 float[] leftCol = {leftEdge,currentYPosition,leftEdge,currentYPosition-titleLineHeight};
240 ct.setColumns(leftCol,rightCol);
241 ct.setYLine(currentYPosition);
242 ct.setAlignment(Element.ALIGN_CENTER);
245 currentYPosition = currentYPosition - titleLineHeight;
248 catch(DocumentException de) {
249 logger.error(de.getMessage());
251 catch(MalformedURLException de) {
252 logger.error(de.getMessage());
254 catch(IOException de) {
255 logger.error(de.getMessage());
258 public void addIndexItem(EntityContent entityContent){
261 ColumnText ict = new ColumnText(cb);
262 String theTitle = entityContent.getValue("title");
263 String theCreator = entityContent.getValue("creator");
264 Phrase titleP=new Phrase(" - " + theTitle,new Font(indexFontFamily,indexFontSize,Font.BOLD));
265 Phrase creatorP=new Phrase( " :: " + theCreator,new Font(indexFontFamily,indexFontSize));
266 float toYPosition = currentYPosition - indexLineHeight;
267 float[] leftIndexCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
268 float[] rightIndexCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
270 ict.addText(creatorP);
271 ict.setColumns(leftIndexCols,rightIndexCols);
272 ict.setYLine(currentYPosition);
273 ict.setAlignment(Element.ALIGN_LEFT);
275 currentYPosition = toYPosition;
277 catch(DocumentException de) {
278 logger.error(de.getMessage());
285 private int addTextLine(ColumnText ct,int lineHeight,int alignment,float left, float right){
286 logger.debug("adding a line of text");
287 if (! enoughY(lineHeight)){
290 float toYPosition = currentYPosition - lineHeight;
291 float[] leftContentCols = {left,currentYPosition,left,toYPosition};
292 float[] rightContentCols = {right,currentYPosition,right,toYPosition};
293 ct.setColumns(leftContentCols,rightContentCols);
294 ct.setYLine(currentYPosition);
295 ct.setAlignment(alignment);
298 currentYPosition = toYPosition;
301 catch(DocumentException de) {
302 logger.error(de.getMessage());
307 public void addLine(){
309 cb.moveTo(rightEdge, currentYPosition-5);
310 cb.lineTo(leftEdge, currentYPosition-5);
312 currentYPosition = currentYPosition - 10;
316 public void addFooter(){
318 ColumnText fct = new ColumnText(cb);
320 cb.moveTo(rightEdge, bottomEdge+footerHeight-5);
321 cb.lineTo(leftEdge, bottomEdge+footerHeight-5);
323 float[] leftFooterCols = {leftEdge,bottomEdge+footerHeight-1,leftEdge,bottomEdge};
324 float[] rightFooterCols = {rightEdge,bottomEdge+footerHeight-1,rightEdge,bottomEdge};
326 Paragraph footerP=new Paragraph(footerText,new Font(footerFontFamily,footerFontSize));
327 fct.addText(footerP);
329 fct.setColumns(leftFooterCols,rightFooterCols);
330 fct.setYLine(bottomEdge+footerHeight-1);
331 fct.setAlignment(Element.ALIGN_JUSTIFIED);
334 Paragraph numberP=new Paragraph((new Integer(currentPage)).toString(),new Font(footerFontFamily,footerFontSize,Font.BOLD));
335 fct.addText(numberP);
336 fct.setAlignment(Element.ALIGN_RIGHT);
340 catch (DocumentException de){
341 logger.error(de.getMessage());
347 public void newPage(){
353 currentYPosition=topEdge;
355 catch(DocumentException de) {
356 logger.error(de.getMessage());
360 public void addArticleSeparator(){
366 cb.moveTo(rightEdge, currentYPosition-5);
367 cb.lineTo(leftEdge, currentYPosition-5);
369 currentYPosition = currentYPosition - 10;
372 public void addArticleMetaInfo(ColumnText ct,String theTitle,String theCreator,String theDate){
373 //see if we have room for the author and title
375 if (! enoughY(metaHeight)){
379 Paragraph titleP=new Paragraph(theTitle+"\n",new Font(metaFontFamily,metaFontSize,Font.BOLD));
380 Paragraph whowhenP=new Paragraph(theCreator + " " + theDate ,new Font(metaFontFamily,metaFontSize));
382 ct.addText(whowhenP);
384 ct.setYLine(currentYPosition);
385 ct.setAlignment(Element.ALIGN_LEFT);
387 float toYPosition = currentYPosition - metaHeight;
388 float[] leftHeadCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
389 float[] rightHeadCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
391 ct.setColumns(leftHeadCols,rightHeadCols);
394 currentYPosition = toYPosition;
396 catch(DocumentException de) {
397 logger.error(de.getMessage());
402 public void addArticleDescription(ColumnText ct,String theDescription){
403 // Now we add the description, one line at a time, the ct should be empty at this point
406 Paragraph descP=new Paragraph(theDescription,new Font(descriptionFontFamily,descriptionFontSize,Font.BOLD));
409 // every article has a description, so we can assume that:
410 int status = ColumnText.NO_MORE_COLUMN;
413 while ((status & ColumnText.NO_MORE_TEXT) == 0 && brake >0){
414 //there is still text left in the description.
415 status = addTextLine(ct,descriptionLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
419 logger.error("runaway description...try increasing the line height or decreasing the font size");
422 public void addArticleContent(ColumnText ct,String theContent,Iterator images){
423 //let's go ahead and add in all the body text
424 Paragraph contentP=new Paragraph(theContent,new Font(contentFontFamily,contentFontSize));
425 ct.addText(contentP);
427 int contentLinesBeforeImages=3;
428 //and assume we have at least one line of text in the content
429 int status = ColumnText.NO_MORE_COLUMN;
431 // let's add a little bit of text, like a couple of lines
433 while (((status & ColumnText.NO_MORE_TEXT) == 0) && x<contentLinesBeforeImages){
434 status=addTextLine(ct,contentLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
438 boolean addImageOnLeft = true; //we will alternate within articles
439 while (images.hasNext()){
441 EntityImages currentImage=(EntityImages) images.next();
442 float img_width=(new Float(currentImage.getValue("img_width"))).floatValue();
443 float img_height=(new Float(currentImage.getValue("img_height"))).floatValue();
444 if (img_height>maxImageHeight){
445 img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue();
446 img_height=maxImageHeight;
448 if (img_width>maxImageWidth){
449 img_height=(new Float((new Float(img_height*(maxImageWidth/img_width))).intValue())).floatValue();
450 img_width=maxImageWidth;
453 String img_title=currentImage.getValue("title");
454 String img_path=currentImage.getValue("publish_path");
456 if ((status & ColumnText.NO_MORE_TEXT) == 0){
457 // there is still text, so add an image which will have text wrapped around it, then add the text which
458 // will be on the left or the right of the image
460 float templateMinimumHeight = img_height+20;
461 float templateWidth = img_width+10;
462 float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
464 PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
467 //here we need a page check
468 if (! enoughY((new Float(templateHeight)).intValue())){
469 //ok, well just fill text to the bottom then
470 float toYPosition = bottomEdge+footerHeight;
471 float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
472 float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
473 ct.setColumns(leftBottomCols,rightBottomCols);
474 ct.setYLine(currentYPosition);
475 ct.setAlignment(Element.ALIGN_JUSTIFIED);
479 catch(DocumentException de) {
480 logger.error(de.getMessage());
485 float toYPosition=currentYPosition - templateHeight;
488 Image theImage = Image.getInstance(localImageDir+img_path);
489 theImage.scaleAbsolute(img_width,img_height);
490 theImage.setAbsolutePosition(5,13);
492 template.addImage(theImage);
493 template.beginText();
494 BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
495 template.setFontAndSize(bf, 8);
496 template.setTextMatrix(5, 3);
497 template.showText(img_title);
500 catch(BadElementException de) {
501 logger.error(de.getMessage());
503 catch(DocumentException de) {
504 logger.error(de.getMessage());
506 catch (MalformedURLException de){
507 logger.error(de.getMessage());
509 catch (IOException de){
510 logger.error(de.getMessage());
514 float leftImageTextEdge=leftEdge;
515 float rightImageTextEdge=rightEdge;
519 cb.addTemplate(template,leftEdge,toYPosition);
520 leftImageTextEdge=leftEdge+templateWidth+5;
521 addImageOnLeft = false;
524 cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
525 rightImageTextEdge = rightEdge-templateWidth-5;
526 addImageOnLeft = true;
529 logger.debug("adding template at " + leftEdge + "," + toYPosition);
531 //and fill some text while we are at it
533 float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
534 float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
535 ct.setColumns(leftBottomCols,rightBottomCols);
536 ct.setYLine(currentYPosition);
537 ct.setAlignment(Element.ALIGN_JUSTIFIED);
540 currentYPosition=toYPosition;
542 catch(DocumentException de) {
543 logger.error(de.getMessage());
549 //add an image on the left with a big caption to the right
550 currentYPosition = currentYPosition - 10;
551 float templateMinimumHeight = img_height;
552 float templateWidth = img_width;
553 float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
554 PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
555 if (! enoughY((new Float(templateHeight)).intValue())){
558 float toYPosition=currentYPosition - templateHeight;
560 Image theImage = Image.getInstance(localImageDir+img_path);
561 theImage.setAbsolutePosition(0,13);
562 theImage.scaleAbsolute(img_width,img_height);
563 template.addImage(theImage);
565 catch(BadElementException de) {
566 logger.error(de.getMessage());
568 catch(DocumentException de) {
569 logger.error(de.getMessage());
571 catch(MalformedURLException de) {
572 logger.error(de.getMessage());
574 catch(IOException de) {
575 logger.error(de.getMessage());
578 cb.addTemplate(template,leftEdge,toYPosition);
581 ColumnText cct = new ColumnText(cb);
582 float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
583 float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
585 Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
586 cct.addText(captionP);
587 cct.setColumns(leftCaptionCols,rightCaptionCols);
588 cct.setYLine(currentYPosition-5);
589 cct.setAlignment(Element.ALIGN_LEFT);
592 currentYPosition=toYPosition;
594 catch(DocumentException de) {
595 logger.error(de.getMessage());
600 //add the rest of the text which might be left
602 while ((status & ColumnText.NO_MORE_TEXT) == 0 && brake > 0){
603 status=addTextLine(ct,contentLineHeight,Element.ALIGN_JUSTIFIED,leftEdge,rightEdge);
607 logger.error("runaway content....try decreasing font size or increasing line height");
610 private void addArticleSource(ColumnText ct,String theSource){
611 Paragraph sourceP = new Paragraph(theSource,new Font(sourceFontFamily,sourceFontSize,Font.BOLD));
613 addTextLine(ct,sourceLineHeight,Element.ALIGN_RIGHT,leftEdge,rightEdge);
617 private boolean enoughY(int heightOfBlockToAdd){
618 if ((currentYPosition - heightOfBlockToAdd - footerHeight) < bottomEdge )
625 public void add(EntityContent entityContent){
626 logger.error("adding a content Entity");
636 * --image without text
640 Iterator images = new EntityBrowser(
641 DatabaseImages.getInstance(),
642 "exists (select * from content_x_media where content_id=" + entityContent.getId() + " and media_id=id)",
643 "id desc", 30, -1, 0);
645 String isHTML = entityContent.getValue("is_html");
646 String theTitle = entityContent.getValue("title");
647 String theCreator = entityContent.getValue("creator");
648 String theDate = DateTimeFunctions.advancedDateFormat(
649 configuration.getString("RDF.Meta.DateFormat"),
650 StringUtil.convertMirInternalDateToDate(entityContent.getValue("webdb_create")),
651 configuration.getString("Mir.DefaultTimezone"));
654 String theDescriptionRaw = entityContent.getValue("description");
655 String theContentRaw = entityContent.getValue("content_data");
656 String theSource = configuration.getString("Producer.ProductionHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getValue("publish_path") + entityContent.getValue("id") + ".shtml";
660 String theContent = "";
661 String theDescription = "";
663 if (isHTML.equals("1")){
668 RE nobackslashr = new RE("\r");
669 theContent= nobackslashr.substituteAll(theContentRaw,"");
671 RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
672 theContent = HxTag.substituteAll(theContent,"\n\n");
674 RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
675 theContent = ListItemTag.substituteAll(theContent,"\n * ");
677 RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
678 theContent = ListTag.substituteAll(theContent,"\n");
680 RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
681 theContent= DivTag.substituteAll(theContent,"\n");
683 RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
684 theContent= PTag.substituteAll(theContent,"\n ");
686 RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
687 theContent= PTagClose.substituteAll(theContent,"\n");
689 RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
690 theContent= BRTag.substituteAll(theContent,"\n");
692 RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
693 REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
694 String theContentCopy=theContent;
695 while (atags.hasMoreMatches()){
696 REMatch atag = atags.nextMatch();
697 String atagString=atag.toString();
698 String atagStringHref=atag.toString(1);
699 String atagStringText=atag.toString(2);
700 int begin=theContentCopy.indexOf(atagString);
701 theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
703 theContent=theContentCopy;
705 RE noTags = new RE("<[^>]*>");
706 theContent= noTags.substituteAll(theContent," ");
708 theContent=mir.util.Translate.decode(theContent);
710 RE re1 = new RE("\r?\n\r?\n");
711 String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
713 RE re2 = new RE("\r?\n");
714 String theDescription2 = re2.substituteAll(theDescription1," ");
716 RE re3 = new RE("BREAKHERE");
717 theDescription = re3.substituteAll(theDescription2,"\n ");
721 catch(REException ree){
722 logger.error(ree.getMessage());
727 RE re1 = new RE("\r?\n\r?\n");
728 String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
729 String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
731 RE re2 = new RE("\r?\n");
732 String theContent2 = re2.substituteAll(theContent1," ");
733 String theDescription2 = re2.substituteAll(theDescription1," ");
735 RE re3 = new RE("BREAKHERE");
736 theContent = " " + re3.substituteAll(theContent2,"\n ");
737 theDescription = re3.substituteAll(theDescription2,"\n ");
740 catch(REException ree){
741 logger.error(ree.getMessage());
745 addArticleSeparator();
747 ColumnText ct = new ColumnText(cb);
749 addArticleMetaInfo(ct,theTitle,theCreator,theDate);
750 addArticleDescription(ct,theDescription);
751 addArticleContent(ct,theContent,images);
752 addArticleSource(ct,theSource);
756 public int getFontByName(String fontName) {
758 if (fontName.equalsIgnoreCase("helvetica")){
759 theFont = Font.HELVETICA;
762 if (fontName.equalsIgnoreCase("courier")) {
763 theFont = Font.COURIER;
766 if (fontName.equalsIgnoreCase("times")) {
767 theFont = Font.TIMES_ROMAN;
770 logger.error("using helvetica because I can't get font for name: "+fontName);
771 theFont = Font.HELVETICA;