Skip to content

Commit

Permalink
Core: Select font family and size for PDF templates
Browse files Browse the repository at this point in the history
Core: Improved rendering quality of PDF
  • Loading branch information
mschering committed Jan 14, 2025
1 parent 0592efe commit 55f00cc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions www/go/core/install/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,8 @@ create table core_pdf_template
footer text null,
footerX decimal(19, 4) default 0.0000 null,
footerY decimal(19, 4) default -20.0000 null,
fontFamily varchar(100) default 'dejavusans' not null,
fontSize tinyint default 10 null,
constraint core_pdf_template_core_blob_id_fk
foreign key (logoBlobId) references core_blob (id),
constraint core_pdf_template_ibfk_1
Expand Down
9 changes: 9 additions & 0 deletions www/go/core/install/updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1654,3 +1654,12 @@

$updates['202412090921'][] = "drop index accessToken on core_auth_token;";



$updates['202501141553'][] = "alter table core_pdf_template
add fontFamily varchar(100) default 'dejavusans' not null;";

$updates['202501141553'][] = "alter table core_pdf_template
add fontSize tinyint default 10 null;";


4 changes: 4 additions & 0 deletions www/go/core/model/PdfTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class PdfTemplate extends Entity {
*/
public $measureUnit = 'mm';

public string $fontFamily = "dejavusans";

public int $fontSize = 10;

/**
* @var PdfBlock[]
*/
Expand Down
3 changes: 3 additions & 0 deletions www/go/core/util/PdfTemplateRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public function __construct(PdfTemplate $template, $templateModels = []) {
$this->parser->addModel($name, $model);
}

$this->defaultFont = $this->template->fontFamily;
$this->defaultFontSize = $this->template->fontSize;

parent::__construct($orientation, $this->template->measureUnit, $this->template->pageSize);

$this->SetTopMargin($this->template->marginTop);
Expand Down
24 changes: 24 additions & 0 deletions www/go/core/views/extjs3/pdftemplate/TemplateDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ go.pdftemplate.TemplateDialog = Ext.extend(go.form.Dialog, {
}),
valueField: 'value',
displayField: 'display'
},{
xtype: 'combo',
name: 'fontFamily',
fieldLabel: t('Font'),
mode: 'local',
editable: false,
triggerAction: 'all',
value: "dejavusans",
store: new Ext.data.ArrayStore({
fields: [
'value',
'display'
],
data: [['dejavusans', 'DejaVu Sans'], ['freesans', 'Freesans'],['freemono', 'Free mono'],['freeserif', 'Free serif'], ['helvetica', 'Helvetica'], ['times', 'Times New Roman', 'aefurat', "Arabic Furat"]]
}),
valueField: 'value',
displayField: 'display'
},

{
xtype: 'gonumberfield',
fieldLabel: t('Font size'),
name: 'fontSize',
value: 10
},

new go.form.FileButtonField({
Expand Down

0 comments on commit 55f00cc

Please sign in to comment.