Giter Site home page Giter Site logo

Comments (6)

asolntsev avatar asolntsev commented on May 29, 2024

@gerpres it seems I made too much refactoring:)
I thought nobody uses this method anymore :)

I can make it public again in next version.

from flyingsaucer.

gerpres avatar gerpres commented on May 29, 2024

thx. I don't insist on the same method. just a way to specify the baseUrl.
to get rid of having to convert it to w3c.dom manually would be nice.

from flyingsaucer.

asolntsev avatar asolntsev commented on May 29, 2024

@gerpres In FS 9.6.1, I added factory method ITextRenderer.fromString.

Instead of calling constrctor+setDocumentFromString sequentially:

        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocumentFromString(content);

now you can call a single method fromString:

  ITextRenderer renderer  = fromString(content);

Now (in FS 9.7.0) I also added factory method fromString with the second parameter baseUrl. Hope it helps to shorten your code.

from flyingsaucer.

gerpres avatar gerpres commented on May 29, 2024

thx for your quick resonses/fixes.

additionally, before calling setDocument() we also use
renderer.getSharedContext().setUserAgentCallback() to add a custom UserAgentImplementation that overrides
openConnection, getImageResource, getCSSResource for some purposes.

and also renderer.getSharedContext.setReplacedElementFactory() to support inlined base64 images.

since the callbacks need to be set before calling setDocument(), i'm afraid the factory approach will not work

from flyingsaucer.

asolntsev avatar asolntsev commented on May 29, 2024

@gerpres Thank you for sharing how you are using FS.
Yes, the simple factory approach doesn't work for you, but method setDocumentFromString(String content, @Nullable String baseUrl) was also made public again.

P.S. But I am still thinking about some advanced factory approach where you can set all these "user agent", "replaced element factory" etc.

NB! What exactly are you customizing in openConnection, getImageResource, getCSSResource - isn't this logic useful for others too? Shouldn't we include this functionality in FS? The same question for base64 images - don't we want to support them in FS out-of-the-box?

from flyingsaucer.

gerpres avatar gerpres commented on May 29, 2024

getImageResource: in case of SVG images, we redirect to the PNG representation, that we also host.
getCSSResource: the CSS is provided via a servlet. add some control-parameters to the URL (UI theme,...)
openResource: https-handling. trust any certificates. share current session/cookies only with 'local' URL
base64-images: we do something like this: https://www.tothenew.com/blog/using-data-urls-for-embedding-images-in-flying-saucer-generated-pdfs/

from flyingsaucer.

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.