Git Product home page Git Product logo

Comments (6)

hhrutter avatar hhrutter commented on May 25, 2024

Don't do this.
Just leave the config nil unless you have a meaningful one - just follow along the tests in the codebase.

from pdfcpu.

quetz avatar quetz commented on May 25, 2024

This does not always work: for example ReadValidateAndOptimize() function panics on nil configuration.

And anyways, what's the idea behid conf.Cmd? Is this a leftover from command-line tool and as user of API I should not touch it at all?

from pdfcpu.

quetz avatar quetz commented on May 25, 2024

Another example: ReadValidateAndOptimize calls OptimizeContext only if conf.Cmd == model.OPTIMIZE or conf.Optimize == true. Which is strange - if I call this function I expect it to Validate and Optimize (as name says) without extra steps.
Futher down the call stack OptimizeXRefTable calls optimizeResourceDicts only if conf.Cmd == model.OPTIMIZE (setting conf.Optimize == true would do nothing).

Could you please explain why configuration is structured in this way?
Is there a historical or technical reason for this separation?

I am aiming to ensure that I'm using the library correctly and that I understand the design decisions that could affect the way I implement PDF processing capabilities in my application.

Thank you for your time and assistance.

from pdfcpu.

hhrutter avatar hhrutter commented on May 25, 2024

Optimization has turned into an optional feature in one of the latest commits as requested, with the exception of the optimize command.

These latest configuration changes are yet to be officially released and will be documented properly.

Always make sure you use the latest commit.

from pdfcpu.

hhrutter avatar hhrutter commented on May 25, 2024

If you are using the api you have a choice of commands for processing your PDF.

All commands will provide a corresponding default configuration internally based on config.yml in your pdfcpu config.
This means in general all you have to do is pass nil for the config parameter.

Of course you are free to pass your own configuration.
The recommended way for doing so is smth like:

conf := model.NewDefaultConfiguration()
conf.Eol = types.EolCRLF

You will never ever have to do something like conf := &model.Configuration{}

from pdfcpu.

hhrutter avatar hhrutter commented on May 25, 2024

I added some inline documentation for ReadValidateAndOptimize.
Please check back for the next release, which will include updated docs for the pdfcpu configuration.

from pdfcpu.

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.