- 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;
+ 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;
-
- if ((status & ColumnText.NO_MORE_TEXT) == 0){
- // there is still text, so add an image which will have text wrapped around it, then add the text which
- // will be on the left or the right of the image
-
- float templateMinimumHeight = img_height+20;
- float templateWidth = img_width+10;
- float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
-
- PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
-
-
- //here we need a page check
- if (! enoughY((new Float(templateHeight)).intValue())){
- //ok, well just fill text to the bottom then
- float toYPosition = bottomEdge+footerHeight;
- float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
- float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
- ct.setColumns(leftBottomCols,rightBottomCols);
- ct.setYLine(currentYPosition);
- ct.setAlignment(Element.ALIGN_JUSTIFIED);
- try{
- status=ct.go();
- }
- catch(DocumentException de) {
- logger.error(de.getMessage());
- }
- newPage();
- }
-
- float toYPosition=currentYPosition - templateHeight;
-
- try {
- Image theImage = Image.getInstance(localImageDir+img_path);
- theImage.scaleAbsolute(img_width,img_height);
- theImage.setAbsolutePosition(5,13);
-
- template.addImage(theImage);
- template.beginText();
- BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
- template.setFontAndSize(bf, 8);
- template.setTextMatrix(5, 3);
- template.showText(img_title);
- template.endText();
- }
- catch(BadElementException de) {
- logger.error(de.getMessage());
- }
- catch(DocumentException de) {
- logger.error(de.getMessage());
- }
- catch (MalformedURLException de){
- logger.error(de.getMessage());
- }
- catch (IOException de){
- logger.error(de.getMessage());
- }
-
-
- float leftImageTextEdge=leftEdge;
- float rightImageTextEdge=rightEdge;
-
-
- if (addImageOnLeft){
- cb.addTemplate(template,leftEdge,toYPosition);
- leftImageTextEdge=leftEdge+templateWidth+5;
- addImageOnLeft = false;
- }
- else {
- cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
- rightImageTextEdge = rightEdge-templateWidth-5;
- addImageOnLeft = true;
- }
-
- logger.debug("adding template at " + leftEdge + "," + toYPosition);
-
- //and fill some text while we are at it
-
- float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
- float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
- ct.setColumns(leftBottomCols,rightBottomCols);
- ct.setYLine(currentYPosition);
- ct.setAlignment(Element.ALIGN_JUSTIFIED);
- try{
- status=ct.go();
- currentYPosition=toYPosition;
- }
- catch(DocumentException de) {
- logger.error(de.getMessage());
- }
-
-
+
+ if ((status & ColumnText.NO_MORE_TEXT) == 0){
+ // there is still text, so add an image which will have text wrapped around it, then add the text which
+ // will be on the left or the right of the image
+
+ float templateMinimumHeight = img_height+20;
+ float templateWidth = img_width+10;
+ float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
+
+ PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
+
+
+ //here we need a page check
+ if (! enoughY((new Float(templateHeight)).intValue())){
+ //ok, well just fill text to the bottom then
+ float toYPosition = bottomEdge+footerHeight;
+ float[] leftBottomCols = {leftEdge,currentYPosition,leftEdge,toYPosition};
+ float[] rightBottomCols = {rightEdge,currentYPosition,rightEdge,toYPosition};
+ ct.setColumns(leftBottomCols,rightBottomCols);
+ ct.setYLine(currentYPosition);
+ ct.setAlignment(Element.ALIGN_JUSTIFIED);
+ try{
+ status=ct.go();
+ }
+ catch(DocumentException de) {
+ logger.error(de.getMessage());
+ }
+ newPage();
+ }
+
+ float toYPosition=currentYPosition - templateHeight;
+
+ try {
+ Image theImage = Image.getInstance(localImageDir+img_path);
+ theImage.scaleAbsolute(img_width,img_height);
+ theImage.setAbsolutePosition(5,13);
+
+ template.addImage(theImage);
+ template.beginText();
+ BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
+ template.setFontAndSize(bf, 8);
+ template.setTextMatrix(5, 3);
+ template.showText(img_title);
+ template.endText();
+ }
+ catch(BadElementException de) {
+ logger.error(de.getMessage());
+ }
+ catch(DocumentException de) {
+ logger.error(de.getMessage());
+ }
+ catch (MalformedURLException de){
+ logger.error(de.getMessage());
+ }
+ catch (IOException de){
+ logger.error(de.getMessage());
+ }
+
+
+ float leftImageTextEdge=leftEdge;
+ float rightImageTextEdge=rightEdge;
+
+
+ if (addImageOnLeft){
+ cb.addTemplate(template,leftEdge,toYPosition);
+ leftImageTextEdge=leftEdge+templateWidth+5;
+ addImageOnLeft = false;
+ }
+ else {
+ cb.addTemplate(template,rightEdge-templateWidth,toYPosition);
+ rightImageTextEdge = rightEdge-templateWidth-5;
+ addImageOnLeft = true;
+ }
+
+ logger.debug("adding template at " + leftEdge + "," + toYPosition);
+
+ //and fill some text while we are at it
+
+ float[] leftBottomCols = {leftImageTextEdge,currentYPosition,leftImageTextEdge,toYPosition};
+ float[] rightBottomCols = {rightImageTextEdge,currentYPosition,rightImageTextEdge,toYPosition};
+ ct.setColumns(leftBottomCols,rightBottomCols);
+ ct.setYLine(currentYPosition);
+ ct.setAlignment(Element.ALIGN_JUSTIFIED);
+ try{
+ status=ct.go();
+ currentYPosition=toYPosition;
+ }
+ catch(DocumentException de) {
+ logger.error(de.getMessage());
+ }
+
+
- else {
- //add an image on the left with a big caption to the right
- currentYPosition = currentYPosition - 10;
- float templateMinimumHeight = img_height;
- float templateWidth = img_width;
- float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
- PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
- if (! enoughY((new Float(templateHeight)).intValue())){
- newPage();
- }
- float toYPosition=currentYPosition - templateHeight;
- try{
- Image theImage = Image.getInstance(localImageDir+img_path);
- theImage.setAbsolutePosition(0,13);
- theImage.scaleAbsolute(img_width,img_height);
- template.addImage(theImage);
- }
- catch(BadElementException de) {
- logger.error(de.getMessage());
- }
- catch(DocumentException de) {
- logger.error(de.getMessage());
- }
- catch(MalformedURLException de) {
- logger.error(de.getMessage());
- }
- catch(IOException de) {
- logger.error(de.getMessage());
- }
-
- cb.addTemplate(template,leftEdge,toYPosition);
-
- // add a big caption
- ColumnText cct = new ColumnText(cb);
- float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
- float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
-
- Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
- cct.addText(captionP);
- cct.setColumns(leftCaptionCols,rightCaptionCols);
- cct.setYLine(currentYPosition-5);
- cct.setAlignment(Element.ALIGN_LEFT);
- try{
- cct.go();
- currentYPosition=toYPosition;
- }
- catch(DocumentException de) {
- logger.error(de.getMessage());
- }
+ else {
+ //add an image on the left with a big caption to the right
+ currentYPosition = currentYPosition - 10;
+ float templateMinimumHeight = img_height;
+ float templateWidth = img_width;
+ float templateHeight = templateMinimumHeight+contentLineHeight-(templateMinimumHeight % contentLineHeight);
+ PdfTemplate template = cb.createTemplate(templateWidth,templateHeight);
+ if (! enoughY((new Float(templateHeight)).intValue())){
+ newPage();
+ }
+ float toYPosition=currentYPosition - templateHeight;
+ try{
+ Image theImage = Image.getInstance(localImageDir+img_path);
+ theImage.setAbsolutePosition(0,13);
+ theImage.scaleAbsolute(img_width,img_height);
+ template.addImage(theImage);
+ }
+ catch(BadElementException de) {
+ logger.error(de.getMessage());
+ }
+ catch(DocumentException de) {
+ logger.error(de.getMessage());
+ }
+ catch(MalformedURLException de) {
+ logger.error(de.getMessage());
+ }
+ catch(IOException de) {
+ logger.error(de.getMessage());
+ }
+
+ cb.addTemplate(template,leftEdge,toYPosition);
+
+ // add a big caption
+ ColumnText cct = new ColumnText(cb);
+ float[] leftCaptionCols = {leftEdge+templateWidth+5,currentYPosition-5,leftEdge+templateWidth+5,toYPosition};
+ float[] rightCaptionCols = {rightEdge,currentYPosition-5,rightEdge,toYPosition};
+
+ Paragraph captionP=new Paragraph(img_title,new Font(bigImageCaptionFontFamily,bigImageCaptionFontSize,Font.BOLD));
+ cct.addText(captionP);
+ cct.setColumns(leftCaptionCols,rightCaptionCols);
+ cct.setYLine(currentYPosition-5);
+ cct.setAlignment(Element.ALIGN_LEFT);
+ try{
+ cct.go();
+ currentYPosition=toYPosition;
+ }
+ catch(DocumentException de) {
+ logger.error(de.getMessage());
+ }
-
-
-
- try {
- RE nobackslashr = new RE("\r");
- theContent= nobackslashr.substituteAll(theContentRaw,"");
-
- RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
- theContent = HxTag.substituteAll(theContent,"\n\n");
-
- RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
- theContent = ListItemTag.substituteAll(theContent,"\n * ");
-
- RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
- theContent = ListTag.substituteAll(theContent,"\n");
-
- RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
- theContent= DivTag.substituteAll(theContent,"\n");
-
- RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
- theContent= PTag.substituteAll(theContent,"\n ");
-
- RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
- theContent= PTagClose.substituteAll(theContent,"\n");
-
- RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
- theContent= BRTag.substituteAll(theContent,"\n");
-
- RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
- REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
- String theContentCopy=theContent;
- while (atags.hasMoreMatches()){
- REMatch atag = atags.nextMatch();
- String atagString=atag.toString();
- String atagStringHref=atag.toString(1);
- String atagStringText=atag.toString(2);
- int begin=theContentCopy.indexOf(atagString);
- theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
- }
- theContent=theContentCopy;
-
- RE noTags = new RE("<[^>]*>");
- theContent= noTags.substituteAll(theContent," ");
-
- theContent=mir.util.Translate.decode(theContent);
-
- RE re1 = new RE("\r?\n\r?\n");
- String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
-
- RE re2 = new RE("\r?\n");
- String theDescription2 = re2.substituteAll(theDescription1," ");
-
- RE re3 = new RE("BREAKHERE");
- theDescription = re3.substituteAll(theDescription2,"\n ");
-
+
+
+
+ try {
+ RE nobackslashr = new RE("\r");
+ theContent= nobackslashr.substituteAll(theContentRaw,"");
+
+ RE HxTag = new RE("</?h[1-6][^>]*>",RE.REG_ICASE);
+ theContent = HxTag.substituteAll(theContent,"\n\n");
+
+ RE ListItemTag = new RE("<li[^>]*>",RE.REG_ICASE);
+ theContent = ListItemTag.substituteAll(theContent,"\n * ");
+
+ RE ListTag = new RE("<(u|o)l[^>]*>",RE.REG_ICASE);
+ theContent = ListTag.substituteAll(theContent,"\n");
+
+ RE DivTag = new RE("</?div[^>]*>",RE.REG_ICASE);
+ theContent= DivTag.substituteAll(theContent,"\n");
+
+ RE PTag = new RE("<(p|P)([:space:]+[^>]*)?>");
+ theContent= PTag.substituteAll(theContent,"\n ");
+
+ RE PTagClose = new RE("</(p|P)([:space:]+[^>]*)?>");
+ theContent= PTagClose.substituteAll(theContent,"\n");
+
+ RE BRTag = new RE("<(br|BR)([:space:]+[^>]*)?>");
+ theContent= BRTag.substituteAll(theContent,"\n");
+
+ RE ATagAll = new RE("<a[^>]*href=(?:\"|\')([^#\"\'][^\'\"]+)(?:\"|\')[^>]*>(.*?)</a>",RE.REG_ICASE);
+ REMatchEnumeration atags= ATagAll.getMatchEnumeration(theContent);
+ String theContentCopy=theContent;
+ while (atags.hasMoreMatches()){
+ REMatch atag = atags.nextMatch();
+ String atagString=atag.toString();
+ String atagStringHref=atag.toString(1);
+ String atagStringText=atag.toString(2);
+ int begin=theContentCopy.indexOf(atagString);
+ theContentCopy=theContentCopy.substring(0,begin) + atagStringText + " ["+ atagStringHref + "] " + theContentCopy.substring(begin+atagString.length());
+ }
+ theContent=theContentCopy;
+
+ RE noTags = new RE("<[^>]*>");
+ theContent= noTags.substituteAll(theContent," ");
+
+ theContent=mir.util.Translate.decode(theContent);
+
+ RE re1 = new RE("\r?\n\r?\n");
+ String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
+
+ RE re2 = new RE("\r?\n");
+ String theDescription2 = re2.substituteAll(theDescription1," ");
+
+ RE re3 = new RE("BREAKHERE");
+ theDescription = re3.substituteAll(theDescription2,"\n ");
+
- try {
- RE re1 = new RE("\r?\n\r?\n");
- String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
- String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
-
- RE re2 = new RE("\r?\n");
- String theContent2 = re2.substituteAll(theContent1," ");
- String theDescription2 = re2.substituteAll(theDescription1," ");
-
- RE re3 = new RE("BREAKHERE");
- theContent = " " + re3.substituteAll(theContent2,"\n ");
- theDescription = re3.substituteAll(theDescription2,"\n ");
+ try {
+ RE re1 = new RE("\r?\n\r?\n");
+ String theContent1 = re1.substituteAll(theContentRaw,"BREAKHERE");
+ String theDescription1 = re1.substituteAll(theDescriptionRaw,"BREAKHERE");
+
+ RE re2 = new RE("\r?\n");
+ String theContent2 = re2.substituteAll(theContent1," ");
+ String theDescription2 = re2.substituteAll(theDescription1," ");
+
+ RE re3 = new RE("BREAKHERE");
+ theContent = " " + re3.substituteAll(theContent2,"\n ");
+ theDescription = re3.substituteAll(theDescription2,"\n ");