Comments (6)
@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.
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.
@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.
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.
@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.
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)
- Arabic and hebrew texts not supporting HOT 6
- Left and right margin after :first page bug
- Left and right margin after :first page bug HOT 1
- Support for CSS Level 3 Modules HOT 1
- table-cell float:left fails PDF generation HOT 4
- FlyingSaucer can cleanup invalid html
- Support for HTML 5 HOT 3
- FlyingSaucer could validate generated PDFs HOT 1
- ITextRenderer class, but no dependency on IText HOT 1
- Remove various old packages and libraries HOT 2
- No way to set Document directly in renderer HOT 2
- Internal logging is enabled by default contrary to what doc says HOT 3
- Support PDF digital signature HOT 3
- default for xr.util-logging.loggingEnabled in resources/conf/xhmlrenderer.conf changed HOT 1
- Adding an image to the full size of a pdf page
- Underline text decoration with Liberation Sans too thick HOT 2
- Bold highlighting of a list item marker not being applied HOT 1
- Page break causing issues
- HTML to PDF - Blur the page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flyingsaucer.