Skip to content

Commit 2b855cb

Browse files
author
Stephen
committed
v2.0
Added Title Line/Image positioning, Configurable fields for title line (type + meta), fixed barcode integration
1 parent 2c38ef9 commit 2b855cb

File tree

8 files changed

+69
-14
lines changed

8 files changed

+69
-14
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ Download the whole diretory and rename to "pdf_export". Then you can install it
1515

1616
- Resource Types to exclude (pick from list). This will hide PDF Export link from the view pages of those resources.
1717
- Fonts: can configure a filepath (relative to webroot, not a URL) to a custom font (ttf file) that sits on your server for heading (usually bold) and body/list text (usually regular).
18-
- URL to image to use as header
19-
- Exclude title from top of PDF
20-
- Fields to include (2 fields, multiselect and comma separated list of metadata field IDs, ie: 67,73,78,etc)
18+
- URL to image to use as header
19+
- Position header image
20+
- Exclude title header from top of PDF
21+
- Choose fields for title header
2122
- Image size to use in PDF. Defaults to "hdr", but for some installs this is huge and unnecessary.
2223
- Set image height (inches)
24+
- Position title line and image horizontally (L,C,R)
25+
- Fields to include (2 fields, multiselect and comma separated list of metadata field IDs, ie: 67,73,78,etc)
2326
- Integration with [whereabouts plugin](https://github.com/ssuess/resourcespace-plugin-whereabouts) (if installed)
27+
- Integration with [rs_barcode plugin](https://github.com/ssuess/rs_barcode) (if installed)
2428

2529

2630
## Changelog
31+
* `v 2.0` - Added Title Line/Image positioning, Configurable fields for title line (type + meta), fixed barcode integration
2732
* `v 1.9` - Fixed crashing bug in collection div, added special perm check (pdf) for config rights. Fix square img problem.
2833
* `v 1.8` - Output barcode from specified field
2934
* `v 1.7` - New config exclude title, fix if no logo specified, allow full height image (to margin)

config/config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
$pdf_export_admin_edit_access=array();
99
$pdf_export_logo_url ="";
1010
$pdf_export_logo_deets=".5,.3,0,.5";
11+
$pdf_export_title_array="8,12";
1112
$pdf_export_exclude_title=false;
13+
$pdf_export_includetype_title=true;
1214
$pdf_export_fields_include=array();
1315
$pdf_export_fields_include_hidden ="";
1416
$pdf_export_ttf_header_font_path="";
1517
$pdf_export_ttf_list_font_path="";
1618
$pdf_export_imagesizeid="";
1719
$pdf_export_imgheight="6";
20+
$pdf_export_imagejustify="L";
1821
$pdf_export_whereabouts_integration=false;
1922
$pdf_export_barcode=false;
2023
$pdf_export_barcode_field="80";

include/general.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function create_pdf_export_pdf($ref,$is_collection=false,$size="letter",$cleanup
4141
# This leaves the pdfs and jpg previews in filestore/annotate so that they can be grabbed later.
4242
# $cleanup will result in a slightly different path that is not cleaned up afterwards.
4343

44-
global $pdf_export_barcode_field,$pdf_export_barcode_type,$pdf_export_barcode,$pdf_export_exclude_title,$pdf_export_logo_deets,$pdf_export_imgheight,$onetimenotes,$pdf_export_whereabouts_integration,$pdf_export_imagesizeid,$pdf_export_ttf_list_font_path,$pdf_export_ttf_header_font_path,$pdf_export_fields_include_hidden,$pdf_export_logo_url,$contact_sheet_preview_size,$pdf_output_only_annotated,$lang,$userfullname,$view_title_field,$baseurl,$imagemagick_path,$imagemagick_colorspace,$ghostscript_path,$previewpage,$storagedir,$storageurl,$pdf_export_font,$access,$k;
44+
global $pdf_export_title_array,$pdf_export_includetype_title,$pdf_export_imagejustify,$pdf_export_barcode_field,$pdf_export_barcode_type,$pdf_export_barcode,$pdf_export_exclude_title,$pdf_export_logo_deets,$pdf_export_imgheight,$onetimenotes,$pdf_export_whereabouts_integration,$pdf_export_imagesizeid,$pdf_export_ttf_list_font_path,$pdf_export_ttf_header_font_path,$pdf_export_fields_include_hidden,$pdf_export_logo_url,$contact_sheet_preview_size,$pdf_output_only_annotated,$lang,$userfullname,$view_title_field,$baseurl,$imagemagick_path,$imagemagick_colorspace,$ghostscript_path,$previewpage,$storagedir,$storageurl,$pdf_export_font,$access,$k;
4545
$date= date("m-d-Y h:i a");
4646

4747
include_once(dirname(__FILE__) . '/../../../include/search_functions.php');
@@ -130,8 +130,11 @@ public function MultiRow($left, $right) {
130130
$ttflistfontvar = $configarray['pdf_export_ttf_list_font_path'];
131131
$logourlvar = $configarray['pdf_export_logo_url'];
132132
$logodeetsvar=$configarray['pdf_export_logo_deets'];
133+
$titleincludetypevar=$configarray['pdf_export_includetype_title'];
134+
$titlearrayvar=$configarray['pdf_export_title_array'];
133135
$imagesizeidvar = $configarray['pdf_export_imagesizeid'];
134136
$imageheightvar = $configarray['pdf_export_imgheight'];
137+
$imagejustifyvar = $configarray['pdf_export_imagejustify'];
135138
$exportfieldslistvar = $configarray['pdf_export_fields_include_hidden'];
136139
$excludetitlevar = $configarray['pdf_export_exclude_title'];
137140
$exportbarcodecvar = $configarray['pdf_export_barcode'];
@@ -142,8 +145,11 @@ public function MultiRow($left, $right) {
142145
$ttflistfontvar = $pdf_export_ttf_list_font_path;
143146
$logourlvar = $pdf_export_logo_url;
144147
$logodeetsvar=$pdf_export_logo_deets;
148+
$titleincludetypevar=$pdf_export_includetype_title;
149+
$titlearrayvar=$pdf_export_title_array;
145150
$imageheightvar=$pdf_export_imgheight;
146151
$imagesizeidvar = $pdf_export_imagesizeid;
152+
$imagejustifyvar = $pdf_export_imagejustify;
147153
$exportfieldslistvar = $pdf_export_fields_include_hidden;
148154
$excludetitlevar = $pdf_export_exclude_title;
149155
$exportbarcodecvar = $pdf_export_barcode;
@@ -191,7 +197,7 @@ public function MultiRow($left, $right) {
191197
$mylogoheight=0;
192198
}
193199
$includearr=explode(",",$exportfieldslistvar);
194-
200+
$titlearrayvararr=explode(",",$titlearrayvar);
195201
$page=1;
196202
$totalpages=1;
197203
$m=1;
@@ -268,9 +274,18 @@ public function MultiRow($left, $right) {
268274
$pdf->SetFont('helvetica', 'B', 15,'',false);
269275
}
270276
$ypos=$pdf->GetY();
271-
if ($excludetitlevar==0) {
272-
$righttitle=str_replace("\\r\\n","\n",strtoupper(i18n_get_translated($resourcedata['field'.$view_title_field])));
273-
$pdf->MultiCell(0,0, $righttitle, 0, 'L', 0, 1,.45,$ypos+$logofinalY, true, 0,false,false);
277+
if ($excludetitlevar==0) {
278+
if ($titleincludetypevar==0) {
279+
$toplinecomposite='';
280+
} else {
281+
$toplinecomposite= i18n_get_translated(get_resource_type_name($resourcedata['resource_type'])).' - ';
282+
}
283+
foreach ($titlearrayvararr as $toplineitem) {
284+
$toplinecomposite .= ltrim(i18n_get_translated(get_data_by_field($ref,$toplineitem)),',') . " - ";
285+
}
286+
$toplinestring = substr($toplinecomposite, 0, -3);
287+
$righttitle=str_replace("\\r\\n","\n",strtoupper($toplinestring));
288+
$pdf->MultiCell(0,0, $righttitle, 0, $pdf_export_imagejustify, 0, 1,.45,$ypos+$logofinalY, true, 0,false,false);
274289
// store current object
275290
$pdf->startTransaction();
276291
// get the number of lines for multicell
@@ -295,7 +310,7 @@ public function MultiRow($left, $right) {
295310
$titlelineratio = .2;
296311
$ypos=$logofinalY+$titleheight+.5;$pdf->SetY($ypos);
297312
}
298-
$pdf->Image($imgpath,.5,$ypos,$imagewidth,$imageheight,"jpg",$baseurl. '/?r=' . $ref);
313+
$pdf->Image($imgpath,.5,$ypos,$imagewidth,$imageheight,"jpg",$baseurl. '/?r=' . $ref,'','','',$pdf_export_imagejustify);
299314
// set color for background
300315
$pdf->SetFillColor(255, 255, 255);
301316
$pdf->setCellPaddings(0.01, 0.06, 0.01, 0.1);

languages/en.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
$lang["pdf_export_chooseconfig"]="Select a config to use: ";
1313
$lang["pdf_export_logo_url"]="PDF header image (URL)<br />Supports jpg, png, and svg<br /><br />";
1414
$lang["pdf_export_logo_deets"]="Header image: Left, Top, Width and Height in inches (numeric and comma separated, use 0 for auto calc of width/height)<br /><br />";
15-
$lang["pdf_export_exclude_title"]="Exclude file title from top of page.<br /><br />";
15+
$lang["pdf_export_exclude_title"]="Exclude title line from top of page.<br /><br />";
16+
$lang["pdf_export_includetype_title"]="Include file type in title line.<br /><br />";
17+
$lang["pdf_export_title_array"]="Field ids to include in title line.<br />(comma separated)<br /><br />";
1618
$lang["pdf_export_fields_include"]="Fields to include in the export, in order<br /><br />";
1719
$lang["pdf_export_fields_include_hidden"]="This field just shows the IDs (see <a href='/pages/admin/admin_resource_type_fields.php'>here</a>) from fields you chose above. You can type or rearrange them by hand here to change the order above.<br /><br />";
1820
$lang["pdf_export_ttf_header_font_path"]="Header font conversion from ttf (filepath)<br />(relative to webroot)<br /><br />";
1921
$lang["pdf_export_ttf_list_font_path"]="List font conversion from ttf (filepath)<br />(relative to webroot)<br /><br />";
2022
$lang["pdf_export_imagesizeid"]="Image size to use<br />(use ref ID of <a href='/pages/admin/admin_size_management.php'>preview size</a>)<br /><br />";
2123
$lang["pdf_export_imgheight"]="Image height on page (inches)<br />(if image width is wider than page it will be scaled down and this value will be ignored)<br /><br />";
24+
$lang["pdf_export_imagejustify"]="Title & Image position on page<br />(horizontal - Left, Center, or Right)<br /><br />";
25+
$lang["pdf_export_imagejustify_choices"]=array('L','C','R');
2226
$lang['pdf_export_whereabouts_integration']="whereabouts plugin integration?<br/>(includes current whereabouts in list, use 'w' as include field ID in list above)<br /><br />";
2327
$lang["pdf_export_configuration"]="PDF Export Options";
2428
$lang["extensions_to_exclude"]="Extensions to exclude<br />(comma separated):";

languages/fr.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
$lang["pdf_export_fields_include"]="Champs de la base de données à inclure<br />(utilisez ref IDs de <a href='/pages/admin/admin_resource_type_fields.php'>métadonnées</a>, séparées par des virgules et dans l'ordre que vous voulez qu'ils apparaissent)<br /><br />";
1515
$lang["pdf_export_ttf_header_font_path"]="Police en-tete - convertir un fichier ttf<br />(chemin relatif à webroot)<br /><br />";
1616
$lang["pdf_export_ttf_list_font_path"]="Police de liste - convertir un fichier ttf<br />(chemin relatif à webroot)<br /><br />";
17+
$lang["pdf_export_exclude_title"]="Exclure la ligne de titre du dessus de la page.<br /><br />";
18+
$lang["pdf_export_includetype_title"]="Inclure type dans la ligne titre.<br /><br />";
19+
$lang["pdf_export_title_array"]="Champs de la base de données à inclure dans la ligne titre (utilisez ref IDs de <a href='/pages/admin/admin_resource_type_fields.php'>métadonnées</a>, séparées par des virgules et dans l'ordre que vous voulez qu'ils apparaissent)<br /><br />";
1720
$lang["pdf_export_imagesizeid"]="Taille de l'image à utiliser<br />(utilisez ref IDs de <a href='/pages/admin/admin_size_management.php'>'Manage Sizes'</a>)<br /><br />";
1821
$lang['pdf_export_whereabouts_integration']="whereabouts plugin integration?<br/>(includes current whereabouts in list, use 'w' as include field ID in list above)<br /><br />";
19-
22+
$lang["pdf_export_imagejustify"]="Position de la ligne titre et d'image sur la page (horizontale - gauche (L), central (C), ou droit (R))<br /><br />";
23+
$lang["pdf_export_imagejustify_choices"]=array('L','C','R');
2024
$lang["pdf_export_configuration"]="PDF Export Options";
2125
$lang["extensions_to_exclude"]="Extensions to exclude<br />(séparées par des virgules):";
2226
$lang["resource_types_to_exclude"]="Resource Types à exclure<br />(case à cocher):";

pages/pdf_export_config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ function loadIt() {
163163
<?php } ?>
164164

165165
<div class="BasicsBox" >
166-
167166
<?php if (!$is_collection){?>
168167
<p><a href="<?php echo $baseurl_short?>pages/view.php?ref=<?php echo $ref?>&search=<?php echo urlencode($search)?>&offset=<?php echo $offset?>&order_by=<?php echo $order_by?>&sort=<?php echo $sort?>&archive=<?php echo $archive?>&pdf_export=true" onClick="return CentralSpaceLoad(this);">&lt;&nbsp;<?php echo $lang["backtoresourceview"]?></a></p>
169168
<?php } else {?>

pages/setup.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
$page_def[] = config_add_text_input('pdf_export_logo_url', $lang["pdf_export_logo_url"]);
2424
$page_def[] = config_add_text_input('pdf_export_logo_deets', $lang["pdf_export_logo_deets"]);
2525
$page_def[] = config_add_boolean_select('pdf_export_exclude_title', $lang['pdf_export_exclude_title']);
26+
$page_def[] = config_add_boolean_select('pdf_export_includetype_title', $lang['pdf_export_includetype_title']);
27+
$page_def[] = config_add_text_input('pdf_export_title_array', $lang["pdf_export_title_array"]);
2628
$page_def[] = config_add_text_input('pdf_export_imagesizeid', $lang["pdf_export_imagesizeid"]);
2729
$page_def[] = config_add_text_input('pdf_export_imgheight', $lang["pdf_export_imgheight"]);
30+
$page_def[] = config_add_single_select('pdf_export_imagejustify', $lang["pdf_export_imagejustify"],$lang["pdf_export_imagejustify_choices"],false);
2831

2932
$pdf_export_full_fields_options=array();
3033
$allfields = sql_query('SELECT ref, title FROM resource_type_field;');
@@ -41,10 +44,11 @@
4144
if (isset($whereabouts_rt_exclude)) {
4245
$page_def[] = config_add_boolean_select('pdf_export_whereabouts_integration', $lang['pdf_export_whereabouts_integration']);
4346
}
47+
if (isset($barcode_display_fields)) {
4448
$page_def[] = config_add_boolean_select('pdf_export_barcode', $lang['pdf_export_barcode']);
4549
$page_def[] = config_add_single_select('pdf_export_barcode_type', $lang['pdf_export_barcode_type'],$lang['pdf_export_barcode_type_choices'],false);
4650
$page_def[] = config_add_text_input('pdf_export_barcode_field', $lang["pdf_export_barcode_field"]);
47-
51+
}
4852
// Do the page generation ritual -- don't change this section.
4953
$upload_status = config_gen_setup_post($page_def, $plugin_name);
5054
include '../../../include/header.php';
@@ -113,6 +117,10 @@ function do_alert($msg)
113117
prejson.push({name:"pdf_export_exclude_title", value: titex});
114118
var bctrue = jQuery('#pdf_export_barcode').val();
115119
prejson.push({name:"pdf_export_barcode", value: bctrue});
120+
var titincludetype = jQuery('#pdf_export_includetype_title').val();
121+
prejson.push({name:"pdf_export_includetype_title", value: titincludetype});
122+
var imgposhoriz = jQuery('#pdf_export_imagejustify').val();
123+
prejson.push({name:"pdf_export_imagejustify", value: imgposhoriz});
116124
var bctype = jQuery('#pdf_export_barcode_type').val();
117125
prejson.push({name:"pdf_export_barcode_type", value: bctype});
118126
var confignamevalue = jQuery('#configname').val();
@@ -146,6 +154,12 @@ function do_alert($msg)
146154
toggleFields();
147155
});
148156

157+
toggleFieldstitle(); //call this first so we start out with the correct visibility depending on the selected form values
158+
//this will call our toggleFields function every time the selection value of our underAge field changes
159+
jQuery("#pdf_export_exclude_title").change(function () {
160+
toggleFieldstitle();
161+
});
162+
149163
});
150164
//this toggles the visibility of our parent permission fields depending on the current selected value of the underAge field
151165
function toggleFields() {
@@ -157,6 +171,17 @@ function toggleFields() {
157171
jQuery('#pdf_export_barcode_field').parent().hide();
158172
}
159173

174+
}
175+
176+
function toggleFieldstitle() {
177+
if (jQuery('#pdf_export_exclude_title').val()==0) {
178+
jQuery('#pdf_export_includetype_title').parent().show();
179+
jQuery('#pdf_export_title_array').parent().show();
180+
} else {
181+
jQuery('#pdf_export_includetype_title').parent().hide();
182+
jQuery('#pdf_export_title_array').parent().hide();
183+
}
184+
160185
}
161186
</script><div id="pdfconfigwrapper"><?php
162187
config_gen_setup_html($page_def, $plugin_name, $upload_status, $plugin_page_heading);

pdf_export.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name : pdf_export
22
author : Stephen Suess
3-
version : 1.9
3+
version : 2.0
44
desc : Enable export of detail view info to PDF
55
info_url: https://github.com/ssuess/resourcespace-plugin-pdf_export
66
config_url: /plugins/pdf_export/pages/setup.php

0 commit comments

Comments
 (0)