The Source URL and Links inside the exported PDF needs to be rendered as Hyperlinks to be correctly usefull, verifying the code print.pages.inc was found that this was returning the tag P not an hyperlink: "<p><strong>" . t('Links') . "</strong><br />$url_list</p>";
The main problem is if we try to generate a pdf and the path is too long the line will break and the path will be cutted invalidating the same. Another point found is that for the adobe and other tools that render pdf files if the path isn't a hyperlink this will not be clickable, i have attached the code with some modification into the print.pages.inc file, if you guys could please review it i will appreciatte,
/**
* Returns HTML for the source URL line of the print template.
*
* @param array $vars
* An associative array containing:
* - $url: the URL to the full node view.
* - $node: the node object.
* - $cid; comment ID of the comment to display.
*
* @return string
* HTML text with the footer
*
* @ingroup themeable
* @ingroup print_themeable
*/
function theme_print_sourceurl($vars) {
$sourceurl_date = variable_get('print_sourceurl_date', PRINT_SOURCEURL_DATE_DEFAULT);
$url = is_int($vars['cid']) ? $vars['url'] . '#comment-' . $vars['cid'] : $vars['url'];
$output = '<strong>' . t('Source URL');
if ($sourceurl_date && isset($vars['node'])) {
$output .= ' (';
$date = format_date($vars['node']->changed, 'short');
$output .= empty($vars['node']->nid) ? t('retrieved on !date', array('!date' => $date)) : t('modified on !date', array('!date' => $date));
$output .= ')';
}
$new_url = explode("base_url", $url);
$output .= ':</strong>' ."<a href=".$new_url[1].">". $url . '</a>';
return $output;
}
/**
* Returns HTML for the URL list of the print template.
*
* @param array $vars
* An empty associative array
*
* @return string
* HTML text with the URL list
*
* @ingroup themeable
* @ingroup print_themeable
*/
function theme_print_url_list($vars) {
global $_print_urls;
// Display the collected links at the bottom of the page. Code once taken from Kjartan Mannes' project.module
if (!empty($_print_urls)) {
$urls = _print_friendly_urls();
$max = count($urls);
$url_list = '';
foreach ($urls as $key => $url) {
drupal_alter('print_url_list', $url);
$new_url = explode("base_url", $url);
$url_list .= "<a href=".$new_url[1]." target='_blank'>". '[' . ($key + 1) . '] ' . check_plain($url) . "</a>\n";
}
if (!empty($url_list)) {
return "<p><strong>" . t('Links') . "</strong><br />$url_list</p>";
}
else {
return '';
}
}
}
Thanks,
Vitor.
Comment | File | Size | Author |
---|---|---|---|
#5 | renderhyperlink-printpdf_2897361.patch | 1.47 KB | Vitor Grillo |
#4 | renderhyperlink-printpdf_2897361.patch | 664 bytes | Vitor Grillo |
#3 | renderhyperlink-printpdf_2897361.patch | 1.2 KB | Vitor Grillo |
Comments
Comment #2
Vitor Grillo CreditAttribution: Vitor Grillo commentedComment #3
Vitor Grillo CreditAttribution: Vitor Grillo commentedComment #4
Vitor Grillo CreditAttribution: Vitor Grillo commentedDon't use this patch, submitted wrong.
Comment #5
Vitor Grillo CreditAttribution: Vitor Grillo commentedFollow new patch with the $base_url fixed.
Comment #6
Vitor Grillo CreditAttribution: Vitor Grillo at CI&T commentedComment #7
renatogI applied patch #5 and really works good.
#RTBC
Comment #9
renatogCommitted to the dev branch.
Thank you very much for your contribution, @vitor-grillo.
Best,