Menu

#468 New release of libpaper (paperconf) does not work with rst2odt

pending-remind
nobody
ODT Writer (19)
5
2024-11-10
2023-03-08
fouinix
No

Hello,
It seems a new release of libpaper has broken rst2odt. paperconf -s no longer exists:

paperconf -s 
(null): unknown option ‘-s’

Discussion

  • fouinix

    fouinix - 2023-03-08
     
  • fouinix

    fouinix - 2023-03-08

    The author reported we can use this command instead:

    $ paper --unit pt
    A4: 595.276x841.89 pt
    
     
  • fouinix

    fouinix - 2023-03-13

    I replaced setup_paper in docutils/writers/odf_odt/__init__.py by:

    def setup_paper(self, root_el):
        try:
            dimensions = subprocess.check_output(('paper','--unit pt'),
                                                 stderr=subprocess.STDOUT)
            """
            Example output of paper --unit pt:
            A4: 595.276x841.89 pt
            Letter: 612x792 pt
            """
            x = re.split("\w.*: (\d*(\.\d*)*)x(\d*(\.\d*)*) .*", txt)
            w = float(x[1])
            h = float(x[3])
        except (subprocess.CalledProcessError, FileNotFoundError, ValueError):
            self.document.reporter.info(
                'Cannot use `paper`, defaulting to Letter.')
            w, h = 612, 792     # default to Letter
    
     
  • Günter Milde

    Günter Milde - 2023-04-06

    Thank you for the report and suggestion.
    One problem is, that the "old" paperconf command does not recognize the --unit option.
    Maybe we can try the old syntax and processing if the new command fails before falling back to
    "letter" or "A4".

     
  • fouinix

    fouinix - 2023-04-19

    Indeed, I forgot to handle the case when we have an "old" paperconf ^^

     
  • Günter Milde

    Günter Milde - 2023-04-20

    The attached patch combines the "old" code with your change suggestion.
    "flake8" shows a number of complaints (e.g. variable "txt" never used).
    Also, the regexp looks overly complicated and I'd rather use re.search() than re.split().
    Did you test the proposed change?

     
  • Günter Milde

    Günter Milde - 2023-04-20

    And a test stub. (A proper test would need an independent method to find out if the user has a configured page size and check it is properly retrieved.)
    It works for me (i.e. with the "old" libpaper).

     

    Last edit: Günter Milde 2023-04-20
  • Günter Milde

    Günter Milde - 2023-04-20
    • summary: New release of libpaper (paperconf) breark rst2odt --> New release of libpaper (paperconf) breaks rst2odt
     
  • Günter Milde

    Günter Milde - 2023-05-12
    • summary: New release of libpaper (paperconf) breaks rst2odt --> New release of libpaper (paperconf) does not work with rst2odt
     
  • Günter Milde

    Günter Milde - 2023-05-12

    Mind, that the behaviour of rst2odt with the new "libpaper" version is similar to the current behaviour on systems without "libpaper/paperconf": the page size defaults to US-Letter and an "info" level message is printed. So it is no complete breakdown.

    Also mind, that you must use a custom stylesheet without page size settings to get the page size determined by "paperconf". https://docutils.sourceforge.io/docs/user/odt.html#page-size
    The default style sheet (docutils/writers/odf_odt/styles.odt) sets the page size to US Letter. Hence, by default, documents are generated with "US Letter" page size also on systems with a properly working "paperconf" set to A4.

     

    Last edit: Günter Milde 2023-05-12
  • Günter Milde

    Günter Milde - 2023-05-12
    • status: open --> pending-remind
     
  • Günter Milde

    Günter Milde - 2023-05-12

    Before the proposed patch can be applied to the repo, it needs to be tested on a system with the new paperconf. Waiting for volunteers.

     
  • Günter Milde

    Günter Milde - 2024-11-10
    • labels: --> ODT Writer
     

Log in to post a comment.

MongoDB Logo MongoDB