Closed mcassisa closed 1 year ago
I have tested this and cannot reproduce the portrait/landscape problem. On my system it does respect the landscape/portrait settings. Can you double-check that you actually have $pdf_default_orientation = 'landscape';
?
The clipping of the table is a long-standing problem with the DataTables library and in turn the pdfmake library that it uses. You could hide some of the columns or increase the paper size to get round it.
Thank you for your kind answer The option in config file is actually $pdf_default_orientation = 'landscape'; The unexpected behaviour happens both on production server and on the laptop. Both run Ubuntu 22.04, if it helps
Hiding columns can be a a reasonable solution Marco
Il giorno mar 19 set 2023 alle ore 13:47 campbell-m < @.***> ha scritto:
I have tested this and cannot reproduce the portrait/landscape problem. On my system it does respect the landscape/portrait settings. Can you double-check that you actually have $pdf_default_orientation = 'landscape';?
The clipping of the table is a long-standing problem with the DataTables library and in turn the pdfmake library that it uses. You could hide some of the columns or increase the paper size to get round it.
— Reply to this email directly, view it on GitHub https://github.com/meeting-room-booking-system/mrbs-code/issues/3512#issuecomment-1725345579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWYPSRGHUMCFLCXQZ3V3PLX3GA5FANCNFSM6AAAAAA45KGDL4 . You are receiving this because you authored the thread.Message ID: @.***>
Can you post the contents here please of js/datatables.js.php as seen by your browser? You can get this from your browser's development tools and going to the Sources tab.
Here is the content of js/datatables.js.php (actually it showed up without going to source)
'use strict';
var getTypes = function getTypes(table) {
var type,
types = {},
result = [];
table.find('thead tr:first th').each(function(i) {
var type = $(this).find('span').data('type');
if (type)
{
if (types[type] === undefined)
{
types[type] = [];
}
types[type].push(i);
}
});
for (type in types)
{
if (types.hasOwnProperty(type))
{
result.push({type: type,
targets: types[type]});
}
}
return result;
};
var customizeExcel = function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var pageSetup = sheet.createElement('pageSetup');
sheet.childNodes['0'].appendChild(pageSetup);
var settings = sheet.getElementsByTagName('pageSetup')[0];
settings.setAttribute("r:id", "rId1"); settings.setAttribute('orientation', 'portrait');
settings.setAttribute('paperSize', '9');
};
function makeDataTable(id, specificOptions, fixedColumnsOptions)
{
var i,
defaultOptions,
mergedOptions,
colVisIncludeCols,
nCols,
table,
dataTable,
fixedColumns;
var buttonCommon = {
exportOptions: {
columns: ':visible',
format: {
body: function ( data, row, column, node ) {
var result = $.fn.dataTable.Buttons.stripData(data);
if (result === '')
{
var value = $('<div>' + data + '</div>').find('input[type="submit"]').attr('value');
if (value !== undefined)
{
result = value;
}
}
return result;
}
}
}
};
table = $(id);
if (table.length === 0)
{
return false;
}
table.find('colgroup').remove();
table.attr('width', '100%');
defaultOptions = {
buttons: [{extend: 'colvis',
text: 'Mostra \/ nascondi colonne'}],
deferRender: true,
lengthMenu: [ [10, 25, 50, 100, -1], [10, 25, 50, 100, 'All'] ],
paging: true,
pageLength: 25,
pagingType: 'full_numbers',
processing: true,
scrollCollapse: true,
stateSave: true,
stateDuration: 0,
dom: 'B<"clear">lfrtip',
scrollX: '100%',
colReorder: {}
};
if (specificOptions && specificOptions.buttons)
{
for (i=0; i<specificOptions.buttons.length - 1; i++)
{
defaultOptions.buttons.push({});
}
}
if (args.page !== 'pending')
{
defaultOptions.buttons = defaultOptions.buttons.concat(
$.extend(true, {}, buttonCommon, {
extend: 'copy',
text: 'Copy'
}),
$.extend(true, {}, buttonCommon, {
extend: 'csv',
text: 'CSV'
}),
$.extend(true, {}, buttonCommon, {
extend: 'excel',
text: 'Excel',
customize: customizeExcel
}),
$.extend(true, {}, buttonCommon, {
extend: 'pdf',
text: 'PDF',
orientation: 'landscape',
pageSize: 'A4'
}),
$.extend(true, {}, buttonCommon, {
extend: 'print',
text: 'Print'
})
);
}
defaultOptions.language = /**
* Italian translation
* @name Italian
* @anchor Italian
* @author Nicola Zecchin & Giulio Quaresima
* @lcid it_it
*/
{
"sEmptyTable": "Nessun dato presente nella tabella",
"sInfo": "Vista da _START_ a _END_ di _TOTAL_ elementi",
"sInfoEmpty": "Vista da 0 a 0 di 0 elementi",
"sInfoFiltered": "(filtrati da _MAX_ elementi totali)",
"sInfoThousands": ".",
"sLengthMenu": "Visualizza _MENU_ elementi",
"sLoadingRecords": "Caricamento...",
"sProcessing": "Elaborazione...",
"sSearch": "Cerca:",
"sZeroRecords": "La ricerca non ha portato alcun risultato.",
"oPaginate": {
"sFirst": "Inizio",
"sPrevious": "Precedente",
"sNext": "Successivo",
"sLast": "Fine"
},
"oAria": {
"sSortAscending": ": attiva per ordinare la colonna in ordine crescente",
"sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
}
};
if (specificOptions &&
specificOptions.buttons &&
specificOptions.buttons[0] &&
specificOptions.buttons[0].columns)
{
defaultOptions.buttons[0].columns = specificOptions.buttons;
}
else
{
colVisIncludeCols = [];
nCols = table.find('tr:first-child th').length;
for (i=0; i<nCols; i++)
{
if (fixedColumnsOptions)
{
if (fixedColumnsOptions.leftColumns && (i < fixedColumnsOptions.leftColumns))
{
continue;
}
if (fixedColumnsOptions.rightColumns && (i >= nCols-fixedColumnsOptions.rightColumns))
{
continue;
}
}
colVisIncludeCols.push(i);
}
defaultOptions.buttons[0].columns = colVisIncludeCols;
}
mergedOptions = $.extend(true, {}, defaultOptions, specificOptions);
dataTable = table.DataTable(mergedOptions);
if (fixedColumnsOptions)
{
fixedColumns = new $.fn.dataTable.FixedColumns(dataTable, fixedColumnsOptions);
}
if (!specificOptions.ajax)
{
}
$('.datatable_container').css('visibility', 'visible');
dataTable.columns.adjust();
$(window).on('resize', function () {
dataTable.columns.adjust();
});
return dataTable;
}
Thanks. Could you try using the attached version of js/datatables.js.php and see if it makes a difference? You'll need to unzip the file first. datatables.js.zip
It works now this way! Thank you very much!
Mmmm. I'm not sure why it wouldn't work before. The only difference is that in the file that works I use
extend: 'pdfHtml5',
and in 1.11.3 it is
extend: 'pdf',
But according to the DataTables documentation I'd expect there to be either no button at all, or a button that is just the same as the pdfHtml5 button. I think I'll post on the DataTables forum. Which version of Chrome are you using and on what version of Linux?
I've now committed the fix in 02f6edf.
I have also raised a question on the DataTables forum.
Describe the bug The file PDF generated by report.php doesn't obey the portrait / landscape directive (defaults to landscape) and the content exceeds the right margin and goes off the page
To Reproduce Steps to reproduce the behavior:
$pdf_default_orientation = 'landscape';
in config.inc.php (optional)Expected behavior The PDF content should fit the page, at least in portrait mode.
Screenshots If applicable, add screenshots to help explain your problem.
Browser details (please complete the following information):
Server details (please complete the following information):
Additional context
$pdf_default_orientation = 'landscape';
$pdf_default_paper = 'A4';
output of
pdfinfo -box
Creator: pdfmake Producer: pdfmake CreationDate: Mon Sep 18 18:35:57 2023 CEST Custom Metadata: no Metadata Stream: no Tagged: no UserProperties: no Suspects: no Form: none JavaScript: no Pages: 1 Encrypted: no Page size: 595.28 x 841.89 pts (A4) Page rot: 0 MediaBox: 0.00 0.00 595.28 841.89 CropBox: 0.00 0.00 595.28 841.89 BleedBox: 0.00 0.00 595.28 841.89 TrimBox: 0.00 0.00 595.28 841.89 ArtBox: 0.00 0.00 595.28 841.89 File size: 16540 bytes Optimized: no Sistema di Prenotazione Sale (2).pdfPDF version: 1.3