Changeset 0c8aad in indico for indico/MaKaC/PDFinterface/conference.py
- Timestamp:
- 10/21/09 15:00:04 (4 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 9881d7
- Parents:
- 924ae4 (diff), 242192 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Pedro Ferreira <jose.pedro.ferreira@…> (10/21/09 14:59:13)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (10/21/09 15:00:04)
- File:
-
- 1 edited
-
indico/MaKaC/PDFinterface/conference.py (modified) (137 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/PDFinterface/conference.py
r9033fd r0c8aad 80 80 81 81 class ProgrammeToPDF(PDFBase): 82 82 83 83 def __init__(self, conf, doc=None, story=None, tz=None): 84 84 self._conf = conf … … 89 89 PDFBase.__init__(self, doc, story) 90 90 self._title = _("Conference Scientific Programme") 91 91 92 92 def firstPage(self, c, doc): 93 93 c.saveState() … … 114 114 c.drawRightString(self._PAGE_WIDTH - inch, 0.75 * inch, nowutc().strftime("%A %d %B %Y")) 115 115 c.restoreState() 116 116 117 117 def laterPages(self, c, doc): 118 118 c.saveState() … … 121 121 c.drawRightString(self._PAGE_WIDTH - inch, self._PAGE_HEIGHT - 0.75 * inch, nowutc().strftime("%A %d %B %Y")) 122 122 c.restoreState() 123 123 124 124 def getBody(self, story=None): 125 125 if not story: … … 128 128 style.alignment = TA_JUSTIFY 129 129 for track in self._conf.getTrackList(): 130 130 131 131 bogustext = track.getTitle() 132 132 p = Paragraph(bogustext, styles["Heading1"]) … … 140 140 141 141 class AbstractToPDF(PDFBase): 142 142 143 143 def __init__(self, conf, abstract, doc=None, story=None, tz=None): 144 144 self._conf = conf … … 154 154 self._PAGE_HEIGHT = defaultPageSize[1] 155 155 self._PAGE_WIDTH = defaultPageSize[0] 156 156 157 157 def firstPage(self, c, doc): 158 158 c.saveState() … … 172 172 if not showLogo: 173 173 self._drawWrappedString(c, escape(self._conf.getTitle()), height=self._PAGE_HEIGHT - 2*inch) 174 174 175 175 c.setFont('Times-Bold', 25) 176 176 #c.drawCentredString(self._PAGE_WIDTH/2, self._PAGE_HEIGHT - inch - 5*cm, self._abstract.getTitle()) … … 203 203 text= _("""<b> _("Contribution type")</b> : %s""")%escape(str(self._abstract.getContribType())) 204 204 return text 205 205 206 206 def getBody(self, story=None, indexedFlowable={}, level=1 ): 207 207 if not story: 208 208 story = self._story 209 209 210 210 style = ParagraphStyle({}) 211 211 style.fontSize = 12 … … 213 213 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 214 214 story.append(p) 215 215 216 216 story.append(Spacer(inch, 0.5*cm, part=escape(self._abstract.getTitle()))) 217 218 style = ParagraphStyle({}) 217 218 style = ParagraphStyle({}) 219 219 style.alignment = TA_CENTER 220 220 style.fontSize = 25 … … 223 223 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 224 224 story.append(p) 225 225 226 226 indexedFlowable[p] = {"text":escape(self._abstract.getTitle()), "level":1} 227 227 228 228 style = ParagraphStyle({}) 229 229 style.fontName = "LinuxLibertine" … … 237 237 #p = Preformatted(escape(res), style, part=escape(self._abstract.getTitle())) 238 238 #story.append(p) 239 239 240 240 story.append(Spacer(inch, 0.5*cm, part=escape(self._abstract.getTitle()))) 241 241 … … 244 244 name = field.getName() 245 245 value = self._abstract.getField(id).strip() 246 if value: #id not in ["content"] and 246 if value: #id not in ["content"] and 247 247 styleHead = ParagraphStyle({}) 248 248 styleHead.firstLineIndent = -45 … … 250 250 text = "<b>%s</b> :" % name 251 251 p = Paragraph(text, styleHead, part=escape(self._abstract.getTitle())) 252 story.append(p) 252 story.append(p) 253 253 l=value.split("\n") 254 254 res=[] … … 259 259 story.append(p) 260 260 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 261 261 262 262 style = ParagraphStyle({}) 263 263 style.firstLineIndent = -80 … … 270 270 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 271 271 story.append(p) 272 272 273 273 story.append(Spacer(inch, 0.2*cm)) 274 274 275 275 style = ParagraphStyle({}) 276 276 style.firstLineIndent = -35 … … 281 281 listAuthor.append( "%s (%s)"%(escape(author.getFullName()), escape(author.getAffiliation()) ) ) 282 282 text += " ; ".join(listAuthor) 283 283 284 284 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 285 285 story.append(p) 286 286 287 287 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 288 288 289 289 style = ParagraphStyle({}) 290 290 style.firstLineIndent = -45 … … 297 297 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 298 298 story.append(p) 299 299 300 300 story.append(Spacer(inch, 0.5*cm, part=escape(self._abstract.getTitle()))) 301 301 style = ParagraphStyle({}) … … 304 304 p = Paragraph(self._getTrackText(), style, part=escape(self._abstract.getTitle())) 305 305 story.append(p) 306 306 307 307 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 308 308 tmp= _("""--_("not specified")--""") … … 312 312 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 313 313 story.append(p) 314 314 315 315 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 316 316 317 317 text = _("""<b> _("Submitted by")</b> : %s""")%escape(self._abstract.getSubmitter().getFullName()) 318 318 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 319 319 story.append(p) 320 320 321 321 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 322 322 323 323 text = _("""<b> _("Submitted on")</b> %s""")%self._abstract.getSubmissionDate().strftime("%A %d %B %Y") 324 324 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 325 325 story.append(p) 326 326 327 327 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 328 328 329 329 text = _("""<b> _("Last modified on")</b> : %s""")%self._abstract.getModificationDate().strftime("%A %d %B %Y") 330 330 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 331 331 story.append(p) 332 332 333 333 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 334 334 335 335 text = _("""<b> _("Comments")</b> : """) 336 336 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 337 337 story.append(p) 338 338 339 339 style = ParagraphStyle({}) 340 340 style.leftIndent = 40 … … 342 342 p = Preformatted(text, style, part=escape(self._abstract.getTitle())) 343 343 story.append(p) 344 344 345 345 return story 346 346 347 347 348 348 class AbstractsToPDF(PDFWithTOC): 349 349 350 350 def __init__(self, conf, abstractList, tz=None): 351 351 self._conf = conf … … 357 357 self._title = _("Abstracts book") 358 358 PDFWithTOC.__init__(self) 359 359 360 360 def firstPage(self, c, doc): 361 361 c.saveState() … … 375 375 if not showLogo: 376 376 self._drawWrappedString(c, escape(self._conf.getTitle()), height=self._PAGE_HEIGHT - 2*inch) 377 377 378 378 c.setFont('Times-Bold', 35) 379 379 c.drawCentredString(self._PAGE_WIDTH/2, self._PAGE_HEIGHT/2, self._title) … … 383 383 c.drawString(0.5*inch, 0.5*inch, str(urlHandlers.UHConferenceDisplay.getURL(self._conf))) 384 384 c.restoreState() 385 385 386 386 def laterPages(self, c, doc): 387 387 388 388 c.saveState() 389 389 c.setFont('Times-Roman', 9) … … 400 400 c.drawString(inch, 0.75 * inch, nowutc().strftime("%A %d %B %Y")) 401 401 c.restoreState() 402 403 402 403 404 404 def getBody(self): 405 405 for abstract in self._abstracts: … … 410 410 411 411 class ConfManagerAbstractToPDF(AbstractToPDF): 412 412 413 413 def _getTrackText(self): 414 414 text = _("""<b> _("Track classification")</b> : """) … … 453 453 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 454 454 story.append(p) 455 455 456 456 for track in self._abstract.getTrackListSorted(): 457 457 status = self._abstract.getTrackJudgement(track) … … 482 482 modifier = "" 483 483 comments = "" 484 484 485 485 story.append(Spacer(inch, 0.5*cm, part=escape(self._abstract.getTitle()))) 486 486 487 487 status = self._abstract.getCurrentStatus() 488 488 style = ParagraphStyle({}) … … 492 492 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 493 493 story.append(p) 494 494 495 495 story.append(Spacer(inch, 0.1*cm, part=escape(self._abstract.getTitle()))) 496 496 497 497 status = self._abstract.getCurrentStatus() 498 498 style = ParagraphStyle({}) … … 502 502 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 503 503 story.append(p) 504 504 505 505 #story.append(Spacer(inch, 0.1*cm, part=self._abstract.getTitle())) 506 506 507 507 status = self._abstract.getCurrentStatus() 508 508 style = ParagraphStyle({}) … … 512 512 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 513 513 story.append(p) 514 514 515 515 #story.append(Spacer(inch, 0.1*cm, part=self._abstract.getTitle())) 516 516 517 517 status = self._abstract.getCurrentStatus() 518 518 style = ParagraphStyle({}) … … 522 522 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 523 523 story.append(p) 524 524 525 525 #story.append(Spacer(inch, 0.1*cm, part=self._abstract.getTitle())) 526 526 527 527 status = self._abstract.getCurrentStatus() 528 528 style = ParagraphStyle({}) … … 535 535 536 536 class ConfManagerAbstractsToPDF(AbstractsToPDF): 537 537 538 538 def getBody(self): 539 539 for abstract in self._abstracts: … … 544 544 545 545 class TrackManagerAbstractToPDF(AbstractToPDF): 546 546 547 547 def __init__(self, conf, abstract, track, doc=None, story=None, tz=None): 548 548 AbstractToPDF.__init__(self, conf, abstract, doc, story, tz=tz) … … 562 562 text= _("""<b> _("Contribution type")</b> : %s""")%escape(str(self._abstract.getContribType())) 563 563 return text 564 564 565 565 def getBody(self, story=None, indexedFlowable={}, level=1 ): 566 566 if not story: … … 568 568 #get the common abstract content from parent 569 569 AbstractToPDF.getBody(self, story, indexedFlowable, level ) 570 570 571 571 #add info for the track manager 572 572 status=AbstractStatusTrackViewFactory.getStatus(self._track,self._abstract) … … 621 621 if modifier or modifDate: 622 622 text += " (%s)"%" - ".join( [modifier, modifDate]) 623 623 624 624 else: 625 625 text = _("""<b> _("Status")</b> : _("SUBMITTED")""") 626 626 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 627 627 story.append(p) 628 629 630 628 629 630 631 631 #story.append(Spacer(inch, 0.1*cm, part=self._abstract.getTitle())) 632 632 633 633 if res: 634 634 status = self._abstract.getCurrentStatus() … … 638 638 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 639 639 story.append(p) 640 641 640 641 642 642 if comments: 643 643 status = self._abstract.getCurrentStatus() … … 647 647 p = Paragraph(text, style, part=escape(self._abstract.getTitle())) 648 648 story.append(p) 649 649 650 650 story.append(Spacer(inch, 0.2*cm, part=escape(self._abstract.getTitle()))) 651 651 652 652 if conflictText: 653 653 style = ParagraphStyle({}) … … 655 655 p = Paragraph( _(""" _("In conflict with"): """), style, part=escape(self._abstract.getTitle())) 656 656 story.append(p) 657 657 658 658 style = ParagraphStyle({}) 659 659 style.leftIndent = 60 … … 663 663 664 664 class TrackManagerAbstractsToPDF(AbstractsToPDF): 665 665 666 666 def __init__(self, conf, track, abstractList, tz=None): 667 667 AbstractsToPDF.__init__(self, conf, abstractList, tz) 668 668 self._track = track 669 669 670 670 def getBody(self): 671 671 for abstract in self._abstracts: … … 676 676 677 677 class ContribToPDF(PDFBase): 678 678 679 679 def __init__(self, conf, contrib, doc=None, story=None, tz=None): 680 680 self._conf = conf … … 690 690 self._PAGE_HEIGHT = defaultPageSize[1] 691 691 self._PAGE_WIDTH = defaultPageSize[0] 692 692 693 693 def firstPage(self, c, doc): 694 694 c.saveState() … … 717 717 #c.drawString(0.5*inch, 0.5*inch, Config.getInstance().getBaseURL()) 718 718 c.restoreState() 719 719 720 720 def getBody(self, story=None, indexedFlowable={}, level=1 ): 721 721 if not story: 722 722 story = self._story 723 723 724 724 style = ParagraphStyle({}) 725 725 style.fontSize = 12 … … 727 727 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 728 728 story.append(p) 729 729 730 730 story.append(Spacer(inch, 0.5*cm, part=escape(self._contrib.getTitle()))) 731 732 style = ParagraphStyle({}) 731 732 style = ParagraphStyle({}) 733 733 style.alignment = TA_CENTER 734 734 style.fontSize = 25 … … 737 737 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 738 738 story.append(p) 739 739 740 740 if self._contrib.isScheduled(): 741 style = ParagraphStyle({}) 741 style = ParagraphStyle({}) 742 742 style.alignment = TA_CENTER 743 743 style.fontSize = 12 … … 746 746 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 747 747 story.append(p) 748 748 749 749 indexedFlowable[p] = {"text":escape(self._contrib.getTitle()), "level":1} 750 750 751 751 story.append(Spacer(inch, 1*cm, part=escape(self._contrib.getTitle()))) 752 752 753 753 style = ParagraphStyle({}) 754 754 style.fontName = "LinuxLibertine" 755 755 style.fontSize = 9 756 p = Paragraph(escape(self._contrib.getDescription()), style, part=escape(self._contrib.getTitle()))757 story.append(p)758 759 story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle())))760 756 #p = Paragraph(escape(self._contrib.getDescription()), style, part=escape(self._contrib.getTitle())) 757 #story.append(p) 758 759 #story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle()))) 760 761 761 for field in self._conf.getAbstractMgr().getAbstractFieldsMgr().getActiveFields(): 762 762 fid = field.getId() 763 763 name = field.getName() 764 764 value = self._contrib.getField(fid).strip() 765 if value: #id not in ["content"] and 765 if value: #id not in ["content"] and 766 766 styleHead = ParagraphStyle({}) 767 767 styleHead.firstLineIndent = -55 768 768 styleHead.leftIndent = 45 769 text = "<b>%s</b> :" % name 769 text = "<b>%s</b> :" % name 770 770 p = Paragraph(text, styleHead, part=escape(self._contrib.getTitle())) 771 story.append(p) 771 story.append(p) 772 772 l=value.split("\n") 773 773 res=[] … … 778 778 story.append(p) 779 779 story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle()))) 780 780 781 781 story.append(Spacer(inch, 0.5*cm, part=escape(self._contrib.getTitle()))) 782 782 783 783 style = ParagraphStyle({}) 784 784 style.firstLineIndent = -80 … … 791 791 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 792 792 story.append(p) 793 793 794 794 story.append(Spacer(inch, 0.2*cm)) 795 795 796 796 style = ParagraphStyle({}) 797 797 style.firstLineIndent = -35 … … 802 802 listAuthor.append( "%s (%s)"%(escape(author.getFullName()), escape(author.getAffiliation()) ) ) 803 803 text += " ; ".join(listAuthor) 804 804 805 805 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 806 806 story.append(p) 807 807 808 808 story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle()))) 809 809 810 810 style = ParagraphStyle({}) 811 811 style.firstLineIndent = -45 … … 818 818 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 819 819 story.append(p) 820 820 821 821 story.append(Spacer(inch, 0.5*cm, part=escape(self._contrib.getTitle()))) 822 822 style = ParagraphStyle({}) … … 831 831 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 832 832 story.append(p) 833 833 834 834 story.append(Spacer(inch, 0.5*cm, part=escape(self._contrib.getTitle()))) 835 835 836 836 style = ParagraphStyle({}) 837 837 style.firstLineIndent = -90 … … 845 845 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 846 846 story.append(p) 847 847 848 848 story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle()))) 849 849 850 850 tmp=_("""--_("not specified")--""") 851 851 if self._contrib.getType(): … … 854 854 p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 855 855 story.append(p) 856 856 857 857 # TB: Do we really need to display the submitssion info of a contribution? 858 858 #story.append(Spacer(inch, 0.2*cm, part=escape(self._contrib.getTitle()))) 859 859 860 860 #text = "<b>Submitted by</b> : %s"%escape(self._contrib.getSubmitter().getFullName()) 861 861 #p = Paragraph(text, style, part=escape(self._contrib.getTitle())) 862 862 #story.append(p) 863 863 864 864 return story 865 865 866 866 class ConfManagerContribToPDF(ContribToPDF): 867 867 868 868 def getBody(self, story=None, indexedFlowable={}, level=1 ): 869 869 if not story: 870 870 story = self._story 871 871 872 872 #get the common contribution content from parent 873 873 ContribToPDF.getBody(self, story, indexedFlowable, level ) 874 874 875 875 #add info for the conference manager 876 876 877 877 878 878 class ContributionBook(PDFBase): 879 879 880 880 def __init__(self,conf,contribList,aw,tz=None): 881 881 self._conf=conf … … 892 892 self._doc.topMargin=1.5*cm 893 893 self._doc.bottomMargin=1*cm 894 894 895 895 def firstPage(self,c,doc): 896 896 c.saveState() … … 909 909 height-=2*cm 910 910 c.drawCentredString(self._PAGE_WIDTH/2.0,height, 911 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 911 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 912 912 self._conf.getAdjustedEndDate(self._tz).strftime("%A %d %B %Y"))) 913 913 if self._conf.getLocation(): … … 919 919 c.drawCentredString(self._PAGE_WIDTH/2.0,height,\ 920 920 self._title) 921 self._drawWrappedString(c, "%s / %s"%(self._conf.getTitle(),self._title), width=inch, height=0.75*inch, font='Times-Roman', size=9, color=(0.5,0.5,0.5), align="left", maximumWidth=self._PAGE_WIDTH-3.5*inch, measurement=inch, lineSpacing=0.15) 921 self._drawWrappedString(c, "%s / %s"%(self._conf.getTitle(),self._title), width=inch, height=0.75*inch, font='Times-Roman', size=9, color=(0.5,0.5,0.5), align="left", maximumWidth=self._PAGE_WIDTH-3.5*inch, measurement=inch, lineSpacing=0.15) 922 922 c.drawRightString(self._PAGE_WIDTH-inch,0.75*inch, 923 923 nowutc().strftime("%A %d %B %Y")) 924 924 c.restoreState() 925 925 926 926 def laterPages(self,c,doc): 927 927 c.saveState() … … 1008 1008 1009 1009 class ContribsToPDF(PDFWithTOC): 1010 1010 1011 1011 def __init__(self, conf, contribList, tz=None): 1012 1012 self._conf = conf … … 1018 1018 self._title = _("Contributions book") 1019 1019 PDFWithTOC.__init__(self) 1020 1020 1021 1021 def firstPage(self, c, doc): 1022 1022 c.saveState() … … 1045 1045 c.drawString(0.5*inch, 0.5*inch, str(urlHandlers.UHConferenceDisplay.getURL(self._conf))) 1046 1046 c.restoreState() 1047 1047 1048 1048 def laterPages(self, c, doc): 1049 1049 1050 1050 c.saveState() 1051 1051 c.setFont('Times-Roman', 9) … … 1062 1062 c.drawString(inch, 0.75 * inch, nowutc().strftime("%A %d %B %Y")) 1063 1063 c.restoreState() 1064 1065 1064 1065 1066 1066 def getBody(self): 1067 1067 for contrib in self._contribs: … … 1069 1069 temp.getBody(self._story, indexedFlowable=self._indexedFlowable, level=1) 1070 1070 self._story.append(PageBreak()) 1071 1071 1072 1072 class ConfManagerContribsToPDF(ContribsToPDF): 1073 1073 1074 1074 def getBody(self): 1075 1075 for contrib in self._contribs: 1076 1076 temp = ConfManagerContribToPDF(self._conf, contrib,tz=self._tz) 1077 1077 temp.getBody(self._story, indexedFlowable=self._indexedFlowable, level=1) 1078 self._story.append(PageBreak()) 1078 self._story.append(PageBreak()) 1079 1079 1080 1080 class TimetablePDFFormat: … … 1102 1102 if not params.has_key("showContribId"): 1103 1103 self.contribId = False 1104 1104 1105 1105 self.speakerTitle = True 1106 1106 if not params.has_key("showSpeakerTitle"): 1107 1107 self.speakerTitle = False 1108 1108 1109 1109 self.contribAbstract = False 1110 1110 if params.has_key("showAbstract"): 1111 1111 self.contribAbstract = True 1112 1112 1113 1113 self.contribPosterAbstract = True 1114 1114 if params.has_key("dontShowPosterAbstract"): 1115 1115 self.contribPosterAbstract = False 1116 1116 1117 1117 self.newPagePerSession = False 1118 1118 if params.has_key("newPagePerSession"): … … 1146 1146 if not params.has_key("showCoverPage"): 1147 1147 self.coverPage = False 1148 1148 1149 1149 self.tableContents=True 1150 1150 if not params.has_key("showTableContents"): 1151 1151 self.tableContents = False 1152 1152 1153 1153 self.logo = False 1154 1154 … … 1161 1161 def showContribAbstract(self): 1162 1162 return self.contribAbstract 1163 1163 1164 1164 def showContribPosterAbstract(self): 1165 1165 return self.contribPosterAbstract … … 1194 1194 def showTableContents(self): 1195 1195 return self.tableContents 1196 1196 1197 1197 1198 1198 def sortEntries(x,y): … … 1206 1206 1207 1207 class TimeTablePlain(PDFWithTOC): 1208 1208 1209 1209 def __init__(self,conf,aw,showSessions=[],showDays=[],sortingCrit=None, ttPDFFormat=None, 1210 1210 pagesize='A4', fontsize = 'normal', firstPageNumber = '1', showSpeakerAffiliation=False, tz=None): … … 1258 1258 self._story.append(self._toc) 1259 1259 self._story.append(PageBreak()) 1260 1260 1261 1261 def firstPage(self,c,doc): 1262 1262 if self._ttPDFFormat.showCoverPage(): … … 1276 1276 height-=2*cm 1277 1277 c.drawCentredString(self._PAGE_WIDTH/2.0,height, 1278 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 1278 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 1279 1279 self._conf.getAdjustedEndDate(self._tz).strftime("%A %d %B %Y"))) 1280 1280 if self._conf.getLocation(): … … 1289 1289 nowutc().strftime("%A %d %B %Y")) 1290 1290 c.restoreState() 1291 1291 1292 1292 def laterPages(self,c,doc): 1293 1293 1294 1294 c.saveState() 1295 1295 maxi=self._PAGE_WIDTH-2*cm … … 1303 1303 def _defineStyles(self): 1304 1304 self._styles={} 1305 1305 1306 1306 dayStyle=getSampleStyleSheet()["Heading1"] 1307 1307 dayStyle.fontSize = modifiedFontSize(dayStyle.fontSize, self._fontsize) 1308 1308 self._styles["day"]=dayStyle 1309 1309 1310 1310 sessionTitleStyle=getSampleStyleSheet()["Heading2"] 1311 1311 sessionTitleStyle.fontSize = modifiedFontSize(12.0, self._fontsize) 1312 1312 self._styles["session_title"]=sessionTitleStyle 1313 1313 1314 1314 sessionDescriptionStyle=getSampleStyleSheet()["Heading2"] 1315 1315 sessionDescriptionStyle.fontSize = modifiedFontSize(10.0, self._fontsize) 1316 1316 self._styles["session_description"] = sessionDescriptionStyle 1317 1317 1318 1318 self._styles["table_body"]=getSampleStyleSheet()["Normal"] 1319 1319 1320 1320 convenersStyle=getSampleStyleSheet()["Normal"] 1321 1321 convenersStyle.fontSize = modifiedFontSize(10.0, self._fontsize) 1322 1322 convenersStyle.leftIndent=10 1323 1323 self._styles["conveners"]=convenersStyle 1324 1324 1325 1325 subContStyle=getSampleStyleSheet()["Normal"] 1326 1326 subContStyle.fontSize=modifiedFontSize(10.0, self._fontsize) … … 1405 1405 for subc in contrib.getSubContributionList(): 1406 1406 if not subc.canAccess(self._aw): 1407 return 1407 return 1408 1408 lt=[] 1409 1409 captionText="- [%s] %s"%(escape(subc.getId()),escape(subc.getTitle())) … … 1440 1440 else: 1441 1441 l.append(["",caption,speakers]) 1442 1442 1443 1443 1444 1444 def _processPosterContribution(self,contrib,l): … … 1556 1556 entriesOnDay=self._conf.getSchedule().getEntriesOnDay(day) 1557 1557 entriesOnDay.sort(sortEntries) 1558 for entry in entriesOnDay: 1558 for entry in entriesOnDay: 1559 1559 #Session slot 1560 1560 if isinstance(entry,schedule.LinkedTimeSchEntry) and \ … … 1618 1618 l=[] 1619 1619 ts = deepcopy(originalts) 1620 if sessionSlot.getSession().getScheduleType()=="poster": 1620 if sessionSlot.getSession().getScheduleType()=="poster": 1621 1621 if self._sortingCrit is not None: 1622 1622 cl=[] … … 1661 1661 date="%s"%escape(sEntry.getAdjustedStartDate(self._tz).strftime("%H:%M")) 1662 1662 date=self._fontify(date,10) 1663 1663 1664 1664 lt=[] 1665 1665 captionText="%s"%escape(sEntry.getTitle()) … … 1771 1771 if self._ttPDFFormat.showNewPagePerSession(): 1772 1772 res.append(PageBreak()) 1773 1773 1774 1774 return res 1775 1775 … … 1779 1779 if not story: 1780 1780 story=self._story 1781 if not self._ttPDFFormat.showCoverPage(): 1781 if not self._ttPDFFormat.showCoverPage(): 1782 1782 s = ParagraphStyle({}) 1783 1783 s.fontName = "Times-Bold" … … 1788 1788 story.append(p) 1789 1789 story.append(Spacer(1,0.4*inch)) 1790 1790 1791 1791 currentDay=self._conf.getSchedule().getAdjustedStartDate(self._tz) 1792 1792 while currentDay.strftime("%Y-%m-%d")<=self._conf.getSchedule().getAdjustedEndDate(self._tz).strftime("%Y-%m-%d"): … … 1804 1804 self._indexedFlowable[p]={"text":currentDay.strftime("%A %d %B %Y"), "level":1} 1805 1805 for entry in dayEntries: 1806 story.append(entry) 1806 story.append(entry) 1807 1807 if not self._ttPDFFormat.showNewPagePerSession(): 1808 1808 story.append(PageBreak()) … … 1810 1810 1811 1811 class SimplifiedTimeTablePlain(PDFBase): 1812 1812 1813 1813 def __init__(self,conf,aw,showSessions=[],showDays=[],sortingCrit=None, ttPDFFormat=None, pagesize = 'A4', fontsize = 'normal', tz=None): 1814 1814 self._conf=conf … … 1963 1963 story.append(Spacer(1,0.4*inch)) 1964 1964 for entry in dayEntries: 1965 story.append(entry) 1965 story.append(entry) 1966 1966 currentDay+=timedelta(days=1) 1967 1967 1968 1968 class AbstractBook(PDFBase): 1969 1969 1970 1970 def __init__(self,conf,aw,sortBy,tz=None): 1971 1971 self._conf=conf … … 1985 1985 self._doc.topMargin=1.5*cm 1986 1986 self._doc.bottomMargin=1*cm 1987 1987 1988 1988 def firstPage(self,c,doc): 1989 1989 c.saveState() … … 2001 2001 height-=2*cm 2002 2002 c.drawCentredString(self._PAGE_WIDTH/2.0,height, 2003 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 2003 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 2004 2004 self._conf.getAdjustedEndDate(self._tz).strftime("%A %d %B %Y"))) 2005 2005 if self._conf.getLocation(): … … 2011 2011 c.drawCentredString(self._PAGE_WIDTH/2.0,height,\ 2012 2012 self._title) 2013 self._drawWrappedString(c, "%s / %s"%(self._conf.getTitle(),self._title), width=inch, height=0.75*inch, font='Times-Roman', size=9, color=(0.5,0.5,0.5), align="left", maximumWidth=self._PAGE_WIDTH-3.5*inch, measurement=inch, lineSpacing=0.15) 2013 self._drawWrappedString(c, "%s / %s"%(self._conf.getTitle(),self._title), width=inch, height=0.75*inch, font='Times-Roman', size=9, color=(0.5,0.5,0.5), align="left", maximumWidth=self._PAGE_WIDTH-3.5*inch, measurement=inch, lineSpacing=0.15) 2014 2014 c.drawRightString(self._PAGE_WIDTH-inch,0.75*inch, 2015 2015 nowutc().strftime("%A %d %B %Y")) 2016 2016 c.restoreState() 2017 2017 2018 2018 def laterPages(self,c,doc): 2019 2019 c.saveState() … … 2121 2121 2122 2122 class ProceedingsTOC(PDFBase): 2123 2123 2124 2124 def __init__(self, conf, trackDict=None, trackOrder=None, contribList=None, npages=None, doc=None, story=None, tz=None): 2125 2125 self._conf = conf … … 2137 2137 self._title = _("Proceedings") 2138 2138 self._PAGE_HEIGHT = defaultPageSize[1] 2139 self._PAGE_WIDTH = defaultPageSize[0] 2140 2139 self._PAGE_WIDTH = defaultPageSize[0] 2140 2141 2141 def firstPage(self,c,doc): 2142 2142 c.saveState() … … 2155 2155 height-=2*cm 2156 2156 c.drawCentredString(self._PAGE_WIDTH/2.0,height, 2157 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 2157 "%s - %s"%(self._conf.getAdjustedStartDate(self._tz).strftime("%A %d %B %Y"), 2158 2158 self._conf.getAdjustedEndDate(self._tz).strftime("%A %d %B %Y"))) 2159 2159 if self._conf.getLocation(): … … 2166 2166 c.setFillColorRGB(0.5,0.5,0.5) 2167 2167 c.restoreState() 2168 2168 2169 2169 def laterPages(self,c,doc): 2170 2170 c.saveState() … … 2175 2175 c.drawCentredString(self._PAGE_WIDTH/2.0,0.5*cm,"%s "%Int2Romans.int_to_roman(doc.page-1)) 2176 2176 c.restoreState() 2177 2177 2178 2178 def getBody(self, story=None, indexedFlowable={}, level=1 ): 2179 2179 if not story: … … 2190 2190 p = Paragraph(text, style) 2191 2191 story.append(p) 2192 2192 2193 2193 story.append(Spacer(inch, 0.5*cm)) 2194 2194 2195 2195 styleAuthor = ParagraphStyle({}) 2196 2196 styleAuthor.leading = 10 … … 2213 2213 styleContrib.firstLineIndent=0 2214 2214 styleContrib.leftIndent=0 2215 2215 2216 2216 styleTrack = ParagraphStyle({}) 2217 2217 styleTrack.fontName = "Times-Bold" … … 2254 2254 self._story.append(t) 2255 2255 self._story.append(Spacer(inch, 2*cm)) 2256 2256 2257 2257 return story 2258 2258 … … 2274 2274 l.append(["", ""]) 2275 2275 return i 2276 2276 2277 2277 def _getAbrName(self, author): 2278 2278 res = author.getFamilyName() … … 2287 2287 2288 2288 class ProceedingsChapterSeparator(PDFBase): 2289 2289 2290 2290 def __init__(self, track, doc=None, story=None): 2291 2291 self._track = track … … 2296 2296 self._title = _("Proceedings") 2297 2297 self._PAGE_HEIGHT = defaultPageSize[1] 2298 self._PAGE_WIDTH = defaultPageSize[0] 2299 2298 self._PAGE_WIDTH = defaultPageSize[0] 2299 2300 2300 def firstPage(self,c,doc): 2301 2301 c.saveState() … … 2309 2309 c.setFillColorRGB(0.5,0.5,0.5) 2310 2310 c.restoreState() 2311 2311 2312 2312 def laterPages(self,c,doc): 2313 2313 c.saveState() … … 2318 2318 #c.drawCentredString(self._PAGE_WIDTH/2.0,0.5*cm,"Page %d "%doc.page) 2319 2319 c.restoreState() 2320 2320 2321 2321 def getBody(self, story=None, indexedFlowable={}, level=1 ): 2322 2322 if not story: … … 2345 2345 return result 2346 2346 int_to_roman = staticmethod(int_to_roman) 2347 2347 2348 2348 2349 2349 class RegistrantsListToPDF(PDFBase): 2350 2350 2351 2351 def __init__(self, conf,doc=None, story=[],list=None, display=["Institution", "Phone", "City", "Country"]): 2352 2352 self._conf = conf … … 2358 2358 self._PAGE_HEIGHT = landscape(A4)[1] 2359 2359 self._PAGE_WIDTH = landscape(A4)[0] 2360 2360 2361 2361 def firstPage(self, c, doc): 2362 2362 c.saveState() … … 2371 2371 c.drawRightString(self._PAGE_WIDTH - inch,self._PAGE_HEIGHT-1*cm, "%s"%(nowutc().strftime("%d %B %Y, %H:%M"))) 2372 2372 c.restoreState() 2373 2373 2374 2374 def getBody(self, story=None, indexedFlowable={}, level=1 ): 2375 2375 if not story: … … 2383 2383 p.spaceAfter = 30 2384 2384 story.append(p) 2385 2385 2386 2386 styleRegistrant = ParagraphStyle({}) 2387 2387 styleRegistrant.leading = 10 … … 2393 2393 styleRegistrant.leftIndent=10 2394 2394 styleRegistrant.firstLineIndent=0 2395 2395 2396 2396 tsRegs=TableStyle([('VALIGN',(0,0),(-1,-1),"MIDDLE"), 2397 2397 ('LINEBELOW',(0,0),(-1,0), 1, colors.black), … … 2401 2401 lp = [] 2402 2402 lp.append(Paragraph( _("""<b> _("Name")</b>"""), styleRegistrant)) 2403 2403 2404 2404 for key in self._display: 2405 2405 if key in ["Email", "Position", "LastName", "FirstName", "Institution", "Phone", "City", "Country", "Address", "RegistrationDate"]: … … 2540 2540 Class used to print the Badges for the registrants 2541 2541 """ 2542 2542 2543 2543 """ 2544 2544 The following dictionary maps the names of the fonts, as returned by the javascript in WConfModifBadgeDesign.tpl, … … 2556 2556 #,'Bitstream Cyberbit':['Bitstream-Cyberbit', 'Bitstream-Cyberbit', 'Bitstream-Cyberbit', 'Bitstream-Cyberbit'] 2557 2557 } 2558 2558 2559 2559 """ The following dictionary maps the sizes of the items, as returned by the javascript in WConfModifBadgeDesign.tpl, 2560 2560 to actual font sizes in points, as ReportLab needs. … … 2568 2568 'xx-large':24 2569 2569 } 2570 2570 2571 2571 """ The following dictionary maps the possible text alignments, as returned by the javascript in WConfModifBadgeDesign.tpl, 2572 2572 to ReportLab constants. … … 2577 2577 'Justified':TA_JUSTIFY 2578 2578 } 2579 2579 2580 2580 """ The following dictionary maps the possible text colors, as returned by the javascript in WConfModifBadgeDesign.tpl, 2581 2581 to ReportLab color constants. … … 2593 2593 'white': colors.white 2594 2594 } 2595 2596 2597 def __init__(self, conf, badgeTemplate, marginTop, marginBottom, marginLeft, marginRight, marginColumns, marginRows, pagesize, registrantList):2595 2596 2597 def __init__(self, conf, badgeTemplate, marginTop, marginBottom, marginLeft, marginRight, marginColumns, marginRows, pagesize, drawDashedRectangles, registrantList): 2598 2598 """ Constructor 2599 2599 conf: the conference for which the badges are printed, as a Conference object. … … 2609 2609 The badges will be drawn aligned to the left. 2610 2610 """ 2611 2611 2612 2612 self.__conf = conf 2613 2613 self.__badgeTemplate = badgeTemplate … … 2623 2623 else: 2624 2624 self.__registrantList = [self.__conf.getRegistrantById(id) for id in registrantList] 2625 2625 2626 2626 self.__size = PDFSizes().PDFpagesizes[pagesize] 2627 2627 self.__width, self.__height = self.__size 2628 2628 2629 self.__drawDashedRectangles = drawDashedRectangles 2630 2629 2631 setTTFonts() 2630 2631 2632 2633 2632 2634 def getPDFBin(self): 2633 2635 """ Returns the data of the PDF file to be printed 2634 2636 """ 2635 2637 2636 2638 self.__fileDummy = FileDummy() 2637 2639 self.__canvas = canvas.Canvas(self.__fileDummy, pagesize = self.__size) … … 2639 2641 nBadgesHorizontal = int((self.__width - self.__marginLeft * cm - self.__marginRight * cm + self.__marginColumns * cm + 0.01*cm) / 2640 2642 ((self.__badgeTemplate.getWidthInCm() + self.__marginColumns) * cm)) 2641 2642 2643 2644 2643 2645 nBadgesVertical = int((self.__height - self.__marginTop * cm - self.__marginBottom * cm + self.__marginRows * cm + 0.01*cm) / 2644 2646 ((self.__badgeTemplate.getHeightInCm() + self.__marginRows) * cm)) 2645 2647 2646 2648 # We get an instance of the position generator 2647 2649 p = RegistrantsListToBadgesPDF.__position_generator( … … 2649 2651 self.__badgeTemplate.getWidthInCm() * cm, self.__badgeTemplate.getHeightInCm() * cm, 2650 2652 self.__marginLeft * cm, self.__marginTop * cm, self.__marginColumns * cm, self.__marginRows * cm) 2651 2653 2652 2654 if nBadgesHorizontal == 0 or nBadgesVertical == 0: 2653 2655 raise NoReportError( _("The template dimensions are too large for the page size you selected")) 2654 2656 2655 2657 # We print a badge for each registrant 2656 2658 for registrant in self.__registrantList: … … 2667 2669 posx, posy = p.next() 2668 2670 self.__draw_badge(registrant, posx, posy) 2669 2671 2670 2672 self.__canvas.save() 2671 2673 return self.__fileDummy.getData() 2672 2674 2673 def __position_generator(cls, 2674 nBadgesHorizontal, nBadgesVertical, 2675 badgeWidth, badgeHeight, 2675 def __position_generator(cls, 2676 nBadgesHorizontal, nBadgesVertical, 2677 badgeWidth, badgeHeight, 2676 2678 marginLeft, marginTop, 2677 2679 interColumnMargin, interRowMargin): … … 2680 2682 When there are no more positions available in a page, it throws a StopIteration exception. 2681 2683 """ 2682 2684 2683 2685 nx = 0 2684 2686 ny = 0 … … 2699 2701 (posx, posy) is the position of the top left corner of a badge. 2700 2702 """ 2701 2703 2702 2704 # We draw a dashed rectangle around the badge 2703 self.__canvas.saveState() 2704 self.__canvas.setDash(1,5) 2705 self.__canvas.rect(posx, self.__height - posy - self.__badgeTemplate.getHeightInCm() * cm, 2706 self.__badgeTemplate.getWidthInCm() * cm, self.__badgeTemplate.getHeightInCm() * cm) 2707 self.__canvas.restoreState() 2708 2705 if self.__drawDashedRectangles: 2706 self.__canvas.saveState() 2707 self.__canvas.setDash(1,5) 2708 self.__canvas.rect(posx, self.__height - posy - self.__badgeTemplate.getHeightInCm() * cm, 2709 self.__badgeTemplate.getWidthInCm() * cm, self.__badgeTemplate.getHeightInCm() * cm) 2710 self.__canvas.restoreState() 2711 2709 2712 # We draw the background if we find it. 2710 2713 usedBackgroundId = self.__badgeTemplate.getUsedBackgroundId() … … 2713 2716 posx, self.__height - posy - self.__badgeTemplate.getHeightInCm() * cm, 2714 2717 self.__badgeTemplate.getWidthInCm() * cm, self.__badgeTemplate.getHeightInCm() * cm) 2715 2716 2718 2719 2717 2720 # We draw the items of the badge 2718 2721 for item in self.__badgeTemplate.getItems(): 2719 2722 2720 2723 # First we determine the actual text that has to be drawed. 2721 2724 action = BadgeDesignConfiguration().items_actions[item.getName()] … … 2724 2727 text = action 2725 2728 elif isinstance(action, types.MethodType): 2726 # If the action is a method, depending on which class owns the method, we pass a 2729 # If the action is a method, depending on which class owns the method, we pass a 2727 2730 # different object to the method. 2728 2731 if action.im_class == Registrant: … … 2751 2754 else: 2752 2755 text = _("Error") 2753 2756 2754 2757 if not isinstance(text, basestring): 2755 2758 text = str(text) … … 2762 2765 style.fontSize = RegistrantsListToBadgesPDF.__fontSizes[item.getFontSize()] 2763 2766 style.leading = style.fontSize 2764 2767 2765 2768 if item.isBold() and item.isItalic(): 2766 2769 style.fontName = style.fontName = RegistrantsListToBadgesPDF.__fonts[item.getFont()][3] … … 2771 2774 else: 2772 2775 style.fontName = style.fontName = RegistrantsListToBadgesPDF.__fonts[item.getFont()][0] 2773 2776 2774 2777 p = Paragraph(text, style) 2775 2778 2776 2779 itemx = self.__badgeTemplate.pixelsToCm(item.getX()) * cm 2777 2780 itemy = self.__badgeTemplate.pixelsToCm(item.getY()) * cm 2778 2781 2779 2782 availableWidth = self.__badgeTemplate.pixelsToCm(item.getWidth()) * cm 2780 2783 availableHeight = (self.__badgeTemplate.getHeightInCm() 2781 2784 - self.__badgeTemplate.pixelsToCm(item.getY()) \ 2782 2785 ) * cm 2783 2786 2784 2787 w,h = p.wrap(availableWidth, availableHeight) 2785 2788 2786 2789 if w > availableWidth or h > availableHeight: 2787 2790 ## TODO: give warnings 2788 2791 pass 2789 2792 2790 2793 p.drawOn(self.__canvas, posx + itemx, self.__height - posy - itemy - h) 2791 2794 … … 2795 2798 Class used to print a lecture's poster 2796 2799 """ 2797 2800 2798 2801 """ The following dictionary maps the names of the fonts, as returned by the javascript in WConfModifPosterDesign.tpl, 2799 2802 to actual TTF font names. … … 2810 2813 #,'Bitstream Cyberbit':['Bitstream-Cyberbit', 'Bitstream-Cyberbit', 'Bitstream-Cyberbit', 'Bitstream-Cyberbit'] 2811 2814 } 2812 2813 2815 2816 2814 2817 """ The following dictionary maps the possible text alignments, as returned by the javascript in WConfModifPosterDesign.tpl, 2815 2818 to ReportLab constants. … … 2820 2823 'Justified':TA_JUSTIFY 2821 2824 } 2822 2825 2823 2826 """ The following dictionary maps the possible text colors, as returned by the javascript in WConfModifPosterDesign.tpl, 2824 2827 to ReportLab color constants. … … 2836 2839 'white': colors.white 2837 2840 } 2838 2839 2841 2842 2840 2843 def __init__(self, conf, posterTemplate, marginH, marginV, pagesize, tz=None): 2841 2844 """ Constructor … … 2848 2851 either a list of registrant id's 2849 2852 """ 2850 2853 2851 2854 self.__conf = conf 2852 2855 if not tz: … … 2857 2860 self.__marginH = marginH 2858 2861 self.__marginV = marginV 2859 2862 2860 2863 self.__size = PDFSizes().PDFpagesizes[pagesize] 2861 2864 self.__width, self.__height = self.__size 2862 2865 2863 2866 setTTFonts() 2864 2867 2865 2868 """ The following function maps the sizes of the items, as returned by the javascript in WConfModifPosterDesign.tpl, 2866 2869 to actual font sizes in points, as ReportLab needs. … … 2874 2877 return None 2875 2878 __extract_size = classmethod (__extract_size) 2876 2877 2879 2880 2878 2881 def getPDFBin(self): 2879 2882 """ Returns the data of the PDF file to be printed 2880 2883 """ 2881 2884 2882 2885 self.__fileDummy = FileDummy() 2883 2886 self.__canvas = canvas.Canvas(self.__fileDummy, pagesize = self.__size) 2884 2887 2885 2888 self.__draw_poster(self.__marginH * cm, self.__marginV * cm) 2886 2889 2887 2890 self.__canvas.save() 2888 2891 return self.__fileDummy.getData() 2889 2892 2890 2893 def __draw_background(self, file, position, posx, posy): 2891 2894 2892 2895 img = Image.open(file) 2893 2896 2894 2897 imgWidth, imgHeight = img.size 2895 2898 … … 2906 2909 height = self.__posterTemplate.pixelsToCm(imgHeight) 2907 2910 width = self.__posterTemplate.pixelsToCm(imgWidth) 2908 2911 2909 2912 posterWidth = self.__posterTemplate.getWidthInCm() 2910 2913 posterHeight = self.__posterTemplate.getHeightInCm() 2911 2912 if width > posterWidth or height > posterHeight: 2913 2914 if width > posterWidth: 2915 ratio = float(posterWidth)/width; 2914 2915 if width > posterWidth or height > posterHeight: 2916 2917 if width > posterWidth: 2918 ratio = float(posterWidth)/width; 2916 2919 width = posterWidth; 2917 2920 height = height*ratio 2918 2921 2919 2922 x_1 = posx; 2920 2923 y_1 = posy + (posterHeight - height)/2.0; 2921 2924 2922 2925 2923 2926 if height > posterHeight: 2924 ratio = float(posterHeight)/height; 2927 ratio = float(posterHeight)/height; 2925 2928 height = posterHeight; 2926 2929 width = width*ratio 2927 x_1 = posx + (posterWidth - width)/2.0; 2930 x_1 = posx + (posterWidth - width)/2.0; 2928 2931 y_1 = posy; 2929 2932 else: 2930 2933 x_1 = posx + (posterWidth - self.__posterTemplate.pixelsToCm(imgWidth))/2.0 2931 2934 y_1 = posy + (posterHeight - self.__posterTemplate.pixelsToCm(imgHeight))/2.0 2932 2935 2933 2936 self.__canvas.drawImage(file, 2934 2937 x_1 * cm, y_1 * cm, … … 2939 2942 """ Draws a poster, for a given registrant, at the position (posx, posy). 2940 2943 (posx, posy) is the position of the top left corner of a poster. 2941 """ 2942 2944 """ 2945 2943 2946 # We draw the background if we find it. 2944 2947 usedBackgroundId = self.__posterTemplate.getUsedBackgroundId() 2945 2948 2946 2949 if usedBackgroundId != -1 and self.__posterTemplate.getBackground(usedBackgroundId)[1] is not None: 2947 2950 2948 2951 self.__draw_background(self.__posterTemplate.getBackground(usedBackgroundId)[1].getFilePath(), 2949 self.__posterTemplate.getBackgroundPosition(usedBackgroundId),posx,posy) 2950 2952 self.__posterTemplate.getBackgroundPosition(usedBackgroundId),posx,posy) 2953 2951 2954 # We draw the items of the poster 2952 2955 for item in self.__posterTemplate.getItems(): 2953 2956 2954 2957 # First we determine the actual text that has to be drawed. 2955 2958 action = PosterDesignConfiguration().items_actions[item.getName()] 2956 2959 2957 2960 if isinstance(action, str): 2958 2961 # If for this kind of item we have to draw always the same string, let's draw it. … … 2960 2963 text = [action] 2961 2964 elif isinstance(action, types.MethodType): 2962 # If the action is a method, depending on which class owns the method, we pass a 2965 # If the action is a method, depending on which class owns the method, we pass a 2963 2966 # different object to the method. 2964 2967 if action.im_class == conference.Conference: … … 2974 2977 # -it must have a getValue(object) method, to which a Conference instance or a 2975 2978 # PosterTemplateItem instance must be passed, depending on the result of the getArgumentType() method. 2976 argumentType = action.getArgumentType() 2979 argumentType = action.getArgumentType() 2977 2980 if action.__name__ == "ConferenceChairperson": 2978 2981 #this specific case may need more than one line 2979 2982 chairList = action.getValue(self.__conf) 2980 2983 2981 2984 # 'text' is a list of lines 2982 2985 text = [] … … 2987 2990 else: 2988 2991 text.append(chair.getDirectFullName()) 2989 2992 2990 2993 elif argumentType == conference.Conference: 2991 2994 text = [action.getValue(self.__conf)] … … 2996 2999 else: 2997 3000 text = [_("Error")] 2998 3001 2999 3002 text = map(escape,text) 3000 3003 3001 3004 #style definition for the Paragraph used to draw the text. 3002 3005 style = ParagraphStyle({}) … … 3005 3008 style.fontSize = LectureToPosterPDF.__extract_size(item.getFontSize()) 3006 3009 style.leading = style.fontSize 3007 3010 3008 3011 if item.isBold() and item.isItalic(): 3009 3012 style.fontName = style.fontName = LectureToPosterPDF.__fonts[item.getFont()][3] … … 3014 3017 else: 3015 3018 style.fontName = style.fontName = LectureToPosterPDF.__fonts[item.getFont()][0] 3016 3019 3017 3020 availableWidth = self.__posterTemplate.pixelsToCm(item.getWidth()) * cm 3018 3021 availableHeight = (self.__posterTemplate.getHeightInCm() 3019 3022 - self.__posterTemplate.pixelsToCm(item.getY()) \ 3020 3023 ) * cm 3021 3024 3022 3025 w,h = 0,0 3023 3026 itemx = self.__posterTemplate.pixelsToCm(item.getX()) * cm 3024 3027 itemy = self.__posterTemplate.pixelsToCm(item.getY()) * cm 3025 3028 3026 3029 # now, we iterate over the line set 3027 3030 for line in text: … … 3032 3035 3033 3036 itemy += h 3034 3037 3035 3038 w,h = p.wrap(availableWidth, availableHeight) 3036 3039 3037 3040 if w > availableWidth or h > availableHeight: 3038 3041 ## TODO: warnings 3039 pass 3040 3042 pass 3043 3041 3044 # finally, draw 3042 3045 p.drawOn(self.__canvas, posx + itemx, self.__height - posy - itemy - h)
Note: See TracChangeset
for help on using the changeset viewer.
