Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XLSX content on one page PDF #2785

Closed
2 of 8 tasks
ivangy opened this issue Apr 28, 2022 · 3 comments
Closed
2 of 8 tasks

XLSX content on one page PDF #2785

ivangy opened this issue Apr 28, 2022 · 3 comments

Comments

@ivangy
Copy link

ivangy commented Apr 28, 2022

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

XLSX content on one page PDF

What is the current behavior?

three pages

What are the steps to reproduce?

//PDF
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class);
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
$inputFileType = 'Xlsx';
$inputFileNames = DIR . '/ajustes_pag/05featuredemo.xlsx';
$inputFileNames = glob($inputFileNames);
foreach ($inputFileNames as $inputFileName) {
$reader = IOFactory::createReader($inputFileType);
$reader->setIncludeCharts(true);
$spreadsheet = $reader->load($inputFileName);
// Save
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf::class);
$writer = IOFactory::createWriter($spreadsheet, 'Pdf');
////HORIZONTAL SE AJUSTA AL ANCHO DE LA PAGINA, PERO NO AL LARGO(VARIAS PAGINAS)
$writer->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
$spreadsheet->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$spreadsheet->getActiveSheet()->getPageSetup()->setFitToHeight(1);
header('Content-Type: application/pdf');
header('Content-Disposition: inline;filename="prueba.pdf"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
$spreadsheet->disconnectWorksheets();
unset($spreadsheet);
exit;
}

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calulations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

PHP8.0 and PhpSpreadsheet 1.23

@oleibman
Copy link
Collaborator

While investigating, I found several different problems (PR #2788). Unfortunately, none of these match yours.

It looks like you might be trying to copy the xlsx result of samples/Basic/05_Feature_demo to a Pdf via load/save. If that is so, I ran your script with minimal modifications, and got the expected result - a single landscape page with all the data fitted to it. So I am unable to duplicate your symptom. Perhaps you can upload your input and output files.

@oleibman
Copy link
Collaborator

oleibman commented Sep 2, 2022

Four months, no update, unable to duplicate problem. Closing.

@oleibman oleibman closed this as completed Sep 2, 2022
@Brandin
Copy link

Brandin commented Dec 30, 2022

Hi there, I'm experiencing this issue @oleibman. I've been trying all I can to try and resolve this, including using the other PDF writers, and setting paper size and orientation on both the spreadsheet and the writer, but having no success. I cannot share my document publicly due to sensitive content, what's the best approach to share so we can try to debug this issue?

I'm focusing most of my energy on this problem with Dompdf as its so far produced the best PDF result, just cutting off the right of a sheet, and also pushing rows down into the 2nd sheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants