Convert xml into pdf using itext
Which we did. In , we released iText 7, a brand new version of iText that was no longer compatible with previous versions, but that was created with pdfHTML in mind.
A lot of work was spent on the new Renderer framework. When a document is created with iText 7, a tree of renderers and their child-renderers is built. If you wanted every cell to contain text in a font different from the default font, you needed to set that font for the content of every separate cell. In iText 7, you have a Table and Cell object, and when you set a different font for the complete table, this font is inherited as the default font for every cell.
See this and this for direct answers from the author. I know you said that you don't want to use HTML because it never comes out correctly but maybe you could post some samples of what you're trying and we could help. I can't speak for the iText team and their reasons but I can guess at things. PDF doesn't have "paragraphs", "words", "tables", etc.
Instead, PDF has text, drawings lines, patterns and images. If you want to do these things manually you can use the raw PdfContentByte objects. If any features get added it would need to then version the schema properly which can cause problems and confusions for consumers.
For the former, you have an abstraction talking to an abstraction which is just begging to break. For the latter, you now have two abstraction implementations that will run into feature parity issues eventually.
Further, what would the XML represent? Paragraphs, chunks of text, images and tables? Sounds like HTML already so there's no need to repeat that kind of schema. That's where the PdfContentByte comes in. True, there could be a native parser but I'm guessing there just isn't too many people asking for one. If that's the case, then iText would really have no idea of how to style that either.
You could, however, use leverage. How are we doing? Please help us improve Stack Overflow. Take our short survey. A structured storage system to bundle these elements and any associated content into a single file, with data compression where appropriate. Associated programs Microsoft Office, OpenOffice. Sample file sample. All rights reserved. When a document is created with iText 7, a tree of renderers and their child-renderers is built. If you wanted every cell to contain text in a font different from the default font, you needed to set that font for the content of every separate cell.
In iText 7, you have a Table and Cell object, and when you set a different font for the complete table, this font is inherited as the default font for every cell.
0コメント