Code Monkey home page Code Monkey logo

Comments (3)

sbraconnier avatar sbraconnier commented on May 24, 2024

This seems to have been fixed in recent LibreOffice version. Which version are you using ??

from jodconverter.

sbraconnier avatar sbraconnier commented on May 24, 2024

Well, after some digging, you seem to be hitting this issue, which is not resolved.

So according to the suggestions, your best bet would be to remove programatically the header/footer.

Here's how you could do it, with this post as an inspiration. Please modify the function as you see fit.

private static void convertCsvToPdfRemovingHeaderFotter(final OfficeManager manager) throws OfficeException {

    final File inputFile = new File("C:\\tmp\\jodc\\test.csv");
    final File outputFile = new File("C:\\tmp\\jodc\\test.pdf");

    LocalConverter
            .builder()
            .officeManager(manager)
            .filterChain((context, document, chain) -> {

                if (Calc.isCalc(document)) {

                    // Remove header/footer from default page style.

                    // Access the 'PageStyles' Family
                    final XStyleFamiliesSupplier xSupplier =  Lo.qi(XStyleFamiliesSupplier.class, document);
                    final XNameContainer xFamily = Lo.qi(XNameContainer.class, xSupplier.getStyleFamilies().getByName("PageStyles"));

                    // Now acess the Default PageStyle
                    final XStyle xStyle = Lo.qi(XStyle.class, xFamily.getByName("Default"));

                    // Turn off header and footer
                    final XPropertySet xStyleProps = Lo.qi(XPropertySet.class, xStyle);
                    xStyleProps.setPropertyValue("HeaderIsOn", false);
                    xStyleProps.setPropertyValue("FooterIsOn", false);
                }

                // Invoke the next filter in the chain.
                chain.doFilter(context, document);
            })
            .build()
            .convert(inputFile)
            .to(outputFile)
            .execute();
}

from jodconverter.

lilylei013 avatar lilylei013 commented on May 24, 2024

Thank you for the answer, this works for me

from jodconverter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.