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

Office documents: add paper size #36

Open
piperTang opened this issue Jan 17, 2019 · 13 comments
Open

Office documents: add paper size #36

piperTang opened this issue Jan 17, 2019 · 13 comments
Labels
enhancement New feature or request libreoffice

Comments

@piperTang
Copy link

Expected Behavior
Convert Xlsx file to a PDF file

Current Behavior
If the table length is too long,PDF file Documents will change lines

Possible Solution
Steps to Reproduce (for bugs)
1.Convert Xlsx file to a PDF file

Context
Your Environment
Version used:3
Operating System and version:ubuntu 18.10
Link to your project:

@gulien
Copy link
Collaborator

gulien commented Jan 17, 2019

The root cause of your problem is because the generated PDF is not wide enough.

You should play with paper size: https://thecodingmachine.github.io/gotenberg/#office.paper_size_and_orientation.

Feel free to reopen this issue if needed 😄

@gulien gulien closed this as completed Jan 17, 2019
@piperTang
Copy link
Author

First of all, thank you very much for your reply.
I've read the document carefully.
I set the width of the paper to be ineffective.
But the size of the PDF file I output is A4.
The code is as follows

<?php
require "./vendor/autoload.php";
use TheCodingMachine\Gotenberg\Client;
use TheCodingMachine\Gotenberg\DocumentFactory;
use TheCodingMachine\Gotenberg\OfficeRequest;
use TheCodingMachine\Gotenberg\Request;

$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
$files = [
    DocumentFactory::makeFromPath('one.xlsx', 'one.xlsx'),
];
$request = new OfficeRequest($files);
$request->setLandscape(true);
$request->setPaperSize(Request::A3);
$dirPath = "./pdf";
$filename = $client->store($request, $dirPath);

@gulien gulien reopened this Jan 18, 2019
@gulien
Copy link
Collaborator

gulien commented Jan 21, 2019

Weird, your PDF should have a paper size = A3. I'll need to check that..

@gulien gulien changed the title If the table length is too long, PDF file Documents will change lines Office documents: paper size not working Jan 22, 2019
@gulien gulien added the bug Something isn't working label Jan 22, 2019
@gulien
Copy link
Collaborator

gulien commented Jan 22, 2019

Ok this is a bug, not sure if it is related to Gotenberg though.

Indeed, unoconv provide the flag --printer PaperSize=WIDTHxHEIGHT, but it does not seems to work currently (https://github.com/dagwieers/unoconv/blob/master/unoconv#L774).

@gulien
Copy link
Collaborator

gulien commented Jan 25, 2019

I've removed paper size option for Office conversions (as it does not work).
I'll try to find a way to reimplement it correctly 😄

@gulien gulien changed the title Office documents: paper size not working Office documents: add paper size Jan 25, 2019
@gulien gulien added enhancement New feature or request and removed bug Something isn't working labels Jan 25, 2019
@piperTang
Copy link
Author

Thank you for your kind reply.At the same time, we look forward to your good news.

@hanfengcan
Copy link

Hi, I found that LibreOffice can convert document to html.

eg: "d:\Program Files\LibreOffice\program\soffice" --convert-to html template.xlsx

Maybe we can solve the problem in other ways

@piperTang
Copy link
Author

This method is very good. You can try it. I now use onlyoffice to address my needs.

@gulien
Copy link
Collaborator

gulien commented Feb 18, 2019

For "simple" documents it seems to work, but I wonder if for more "complex" documents it will break some styling during the process.

@tobwen
Copy link

tobwen commented Feb 26, 2019

Have you checked if this got fixed in LibreOffice v6 available from stretch-backports or sid?

@PrathamSoni
Copy link

Hello, just wondering if there's an update on this. Have some wide excel files i want to specify page size for.

@gulien
Copy link
Collaborator

gulien commented Feb 13, 2024

@PrathamSoni you can open a PR to https://github.com/gotenberg/unoconverter.

@PrathamSoni
Copy link

Sure, would be happy to help you have pointers on how the new option would be propogated to the command/how that would be bubbled up to this package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request libreoffice
Projects
None yet
Development

No branches or pull requests

5 participants