Hello,

I can not really figure out if XmlWorker does support absolute positioning. 


When I try to run a similar sample this does not work. The code looks as follows:

public class TestAbsolutePositioning extends Setup {

@Test
public void setupDefaultProcessingYourself() throws IOException, DocumentException {
Document doc = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(new File("/tmp/xmlworker.pdf")));
doc.open();
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(doc, writer)));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser p = new XMLParser(worker);
InputStream is = getClass().getClassLoader().getResourceAsStream("test1.html");
p.parse(is);
doc.close();
}
}


public class Setup {

static {
LoggerFactory.getInstance().setLogger(new SysoLogger());
FontFactory.registerDirectories();
}
}

test1.html looks as follows:

<html>
<head>
<style>
h2 {
text-decoration: underline;
position: absolute;
left: 50mm;
top: 50mm;
}
</style>
</head>

<body>
<h2>This is a heading with an absolute position</h2>
<p>This is the text after the header.</p>
</body>

</html>

The output looks as follows (see attachment):

Attachment: xmlworker.pdf
Description: Adobe PDF document




I use the following libraries:

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.4</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.4</version>
<scope>compile</scope>
</dependency>


Regards,
Georg




------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Reply via email to