Op 14/03/2012 12:46, Lee Theobald schreef:
Thanks for the info. That clears that part up. One more quick
question on this subject, the code your supplied will work when
specifying the CSS files myself but what if I want to use the ones
included in the original HTML (e.g. via <link> elements).
Is this something XMLWorker handles itself and if so, do you have
any more guidance on this subject?
If there's a CSS mentioned in the file, then it will get preference
over the default CSS.
That makes things simpler:
CSSResolver cssResolver =
XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
Note that the true means that default.css (shipped with XML Worker)
will be used as basis.
If you don't want this, you can set the parameter to false.
I
had a look through the mailing list archives and a few questions
said I should use flying saucer with iText but I'm assuming this
solution is a pre-XMLWorker one.
Flying Saucer is a third party library that uses an old version of
iText.
It predates XML Worker.
We aren't responsible for Flying Saucer, so we can't comment on its
use.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Thanks for the info. That
clears that part up. One more quick question on this subject, the code
your supplied will work when specifying the CSS files myself but what
if I want to use the ones included in the original HTML (e.g. via
<link> elements). Is this something XMLWorker handles itself and
if so, do you have any more guidance on this subject? I had a look
through the mailing list archives and a few questions said I should use
flying saucer with iText but I'm assuming this solution is a
pre-XMLWorker one.
Thanks again,
Lee
------------------------------------------------------------------------------
Virtualization
& Cloud Management Using Capacity Planning
Cloud computing makes
use of virtualization - but cloud computing
also focuses on
allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
We're currently working on examples.
For instance:
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(file));
writer.setInitialLeading(12.5f);
// step 3
document.open();
// step 4
XMLWorkerHelper helper = XMLWorkerHelper.getInstance();
// CSS
CSSResolver cssResolver = new StyleAttrCSSResolver();
CssFile cssFile = helper.getCSS(new
FileInputStream("resources/demo2/walden.css"));
cssResolver.addCss(cssFile);
// HTML
XMLWorkerFontProvider fontProvider = new
XMLWorkerFontProvider();
fontProvider.register("C:/windows/fonts/GARA.TTF");
fontProvider.register("C:/windows/fonts/GARAIT.TTF");
fontProvider.register("C:/windows/fonts/GARABD.TTF");
fontProvider.addFontSubstitute("lowagie", "garamond");
CssAppliers cssAppliers = new CssAppliersImpl(fontProvider);
HtmlPipelineContext htmlContext = new
HtmlPipelineContext(cssAppliers);
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
// Pipelines
PdfWriterPipeline pdf = new PdfWriterPipeline(document,
writer);
HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
CssResolverPipeline css = new
CssResolverPipeline(cssResolver, html);
XMLWorker worker = new XMLWorker(css, true);
XMLParser p = new XMLParser(worker);
p.parse(new FileInputStream("results/demo2/walden.html"));
// step 5
document.close();
------------------------------------------------------------------------------
Virtualization
& Cloud Management Using Capacity Planning
Cloud computing makes
use of virtualization - but cloud computing
also focuses on
allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
Hi all,
I'm having trying to use iText (v5.2) & the XMLWorker (v1.1.2) tool
to generate a PDF. Trouble is that the resulting PDF doesn't appear to
be using any of the CSS styles defined on the page. Images are there
but no CSS. I've followed the XMLWorker documentation from
http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html
but it's
looking out of date with the current version. The main problem at the
moment at the moment is this line in the documentation:
HtmlPipelineContext htmlContext =
new HtmlPipelineContext();
With the versions I am using, the constructor of
HtmlPipelineContext
requires a CssAppliers class. I'm supplying a null object for now as I
have no idea how to get my hands on a CssAppliers
class but could this be what is causing my PDF to come out
with no CSS styles applied? Does anyone have any idea how I get my
hands on a CssAppliers instance? The API docs didn't shed much light on
the situation.
Can anyone help me get past this step? I've attempted to attach my test
class so you can see what I'm trying to do. No idea how attachments
work with this mailing list though...
Regards,
Lee