Posts

Creating Lists with PDFBox-Layout

Image
The last article gave you a brief introduction on what you can do with PDFBox-Layout. The new release 0.6.0 added support for indentation and lists, and that’s what this article is about. Indentation Indentation is often used to structure content, and it is also the base for creating lists. Let’s start with some simple example using the Indent element. paragraph.addMarkup( "This is an example for the new indent feature. Let's do some empty space indentation:\n", 11, BaseFont.Times); paragraph.add(new Indent(50, SpaceUnit.pt)); paragraph.addMarkup("Here we go indented.\n", 11, BaseFont.Times); paragraph.addMarkup( "The Indentation holds for the rest of the paragraph, or... \n", 11, BaseFont.Times); paragraph.add(new Indent(70, SpaceUnit.pt)); paragraph.addMarkup("any new indent comes.\n", 11, BaseFont.Times); So what do we do here: we add an indent of 50pt width. This indent will be automatically inserted after ea...

PDF text layout made easy with PDFBox-Layout

Image
More than a decade ago I was using iText to create PDF documents from scratch. It was quite easy to use, and did all the stuff I needed like organizing text in paragraphs, performing word wrapping and marking up text with bold and italic. But once upon a time Bruno Lowagie - the developer of iText - switched from open source to a proprietary license for reasons I do understand . So when I now had to do some PDF processing for a new project, I was looking for an alternative. PDFBox is definitely the best open source choice, since it is quite mature.But when I was searching on how to do layout, I found a lot of people looking for exactly those features, and the common answer was: you have to do it on your own! Say what? Ouch. There must be someone out there, who already wrote that stuff... Sure there is, but google did not find him. So I started to write some simple word wrapping. And some simple pagination. And some simple markup for easy highlighting with bold an italic. Don't...

Avoid Vertical Limits in Microservice Architectures

Image
The microservice architecture allows us to partition an application into tiny sub-applications, which are easy to maintain and to deploy. This pattern is already widely adopted to implement backend systems. But the frontend is usually still one large application, at least when it comes to deployment. This article describes some thoughts on how to address this problem. The microservice architecture is en vogue, everybody seems to know all about it, and feels like having to spread the truth. Including me ;-) But honestly, we are just about to learn how to cope with this kind of architecture. I guess we are like a kid that just managed to make some first steps, when we suddenly try to start running… that’s usually the moment when you fall over your own feet. Microservices are no free lunch, it definitely has its price (that’s the part we have already learned). For developers it feels uncomfortable, since instead of developing one application, they have to deal with dozens or hundreds. U...

Java and JSON ain't friends

Image
Most application frameworks provide some REST support, which is – depending on the language you are using – either dirt cheap, or quite complex. In the Java world part of these frameworks is some kind of mapping from JSON to Java and vice versa, most of them using the Jackson mapping framework. It feels quite natural: you model your domain objects directly in Java. If you don’t have any constraints, the JSON might even follow your model. If the JSON is predefined (as part of the API), you can either design your Java classes so they fit the generated JSON, or provide Jackson with some mapping hints to do so. But you know all that, right? So what am I talking about here? The point is: domain models may vary in size from a few properties to x-nested sky high giants… and so are the resulting Java model classes. What makes things even worse, is that domain models change over time. Often you don’t know all the requirements front of, also requirements change over time. So domain models ar...

Use MTOM to Efficiently Transmit Binary Content in SOAP

Currently JSON-based REST services are en vogue, but when it comes to integrating enterprise services, SOAP is still widely used. In a recent project I had to deal with binary content sent to a third party SOAP-Service. Thanks to great tooling, calling a SOAP service is not a big deal. But the binary data varied in size from a few kB to many MB, and this brought up some issues in transmission size and memory usage. That's where MTOM comes to the rescue, a standard for efficiently tranmitting binary data in a SOAP request. This article published on DZone describes, what MTOM can do for you by converting a tiny spring client-server project from default SOAP to MTOM.

Spring Integration Tests with MongoDB rulez

While unit testing is always preferable, integration tests are a good and necessary supplement to either perform end to end tests, or tests involving (third party) backends. Databases are such a candidate where integrations might make sense: usually we encapsulate persistence with some kind of repository service layer, which we can mock in tests running against the repository. But when it comes to testing the repository itself, integration tests are quite useful. Spring integration tests allow you to test functionality against a running Spring application, and thereby allows to test against a running database instance. But as you do in unit tests, you have to perform a proper set up of test data, and clean up the database afterwards. That's what this article published on DZone is about: proper database set- and clean-up in Spring integration tests with MongoDB.

Job DSL Part III

Image
The previous part of this little series on the Job DSL gave you some examples on maintenance, automating the job creation itself and creating views. This last installment will complete the little round trip through the Job DSL with some hints on documentation, tooling and pitfalls. Documentation If you search the internet for the Job DSL one of the first hits will be the corresponding wiki . This is the most valuable source of information. It is well structured and maintained, so new features and missing pieces are filled in regularly. If you are looking for any details on jobs, the job reference is your target. If you like to generate a view, there is a corresponding view reference . Job DSL Source The documentation on the Job DSL is quite extensive, but so is the Job DSL itself. They are steadily closing the gaps, but sometimes a piece of information is missing. A prominent example: enumeration values. There are some attributes, that only accept a...