From 09814eac6887ca32d010de6dd082c6b1d4731ecc Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Mon, 20 Oct 2025 11:12:25 -0400 Subject: [PATCH] Add --title-url=URL option to rem2pdf. --- rem2pdf/bin/rem2pdf.in | 8 ++++++++ rem2pdf/lib/Remind/PDF.pm | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/rem2pdf/bin/rem2pdf.in b/rem2pdf/bin/rem2pdf.in index 3333a4f5..51ff8f47 100644 --- a/rem2pdf/bin/rem2pdf.in +++ b/rem2pdf/bin/rem2pdf.in @@ -48,6 +48,7 @@ my $settings = { entry_font => 'Sans', small_cal_font => 'Sans', + title_url => '', title_size => 14, header_size => 12, daynum_size => 14, @@ -122,6 +123,7 @@ Options: --daynum-color=RRGGBB Set day number color --smallcal-color=RRGGBB Set small calendar color --bg-color=RRGGBB Set background color +--title-url=URL Link calendar title to URL --verbose, -v Print progress messages --help Display this help EOF @@ -142,6 +144,7 @@ my $ret = GetOptions('landscape|l' => \$settings->{landscape}, 'wrap|y' => \$settings->{wrap_calendar}, 'height|h=i' => \$settings->{height}, 'title-font=s' => \$settings->{title_font}, + 'title-url=s' => \$settings->{title_url}, 'header-font=s' => \$settings->{header_font}, 'daynum-font=s' => \$settings->{daynum_font}, 'entry-font=s' => \$settings->{entry_font}, @@ -572,6 +575,11 @@ you supply 3 hex digits, then they are effectively doubled, so that The color of the calendar title at the top of the page. +=item --title-url=URL + +Make the calendar title a link to URL. Note that no syntax checking is +done on the URL; it's up to you to make sure it is valid. + =item --header-color=RGB The color of the weekday names in the header row. diff --git a/rem2pdf/lib/Remind/PDF.pm b/rem2pdf/lib/Remind/PDF.pm index c6570cb2..96560f8c 100644 --- a/rem2pdf/lib/Remind/PDF.pm +++ b/rem2pdf/lib/Remind/PDF.pm @@ -792,6 +792,8 @@ sub draw_title my ($self, $cr, $settings) = @_; my $title = $self->{monthname} . ' ' . $self->{year}; + my $url = $settings->{title_url} // ''; + # set_page_label not available in older versions of Cairo eval { $cr->get_target()->set_page_label($title); }; my $layout = Pango::Cairo::create_layout($cr); @@ -804,7 +806,13 @@ sub draw_title $cr->save(); $self->set_cr_color($cr, $settings->{title_color}); $cr->move_to($settings->{width}/2 - $w/2, $settings->{margin_top}); + if ($url ne '') { + $cr->tag_begin(Cairo::TAG_LINK, "uri='$url'"); + } Pango::Cairo::show_layout($cr, $layout); + if ($url ne '') { + $cr->tag_end(Cairo::TAG_LINK); + } $cr->restore(); return $h + $settings->{margin_top} + $settings->{border_size}; }