Java PDF Generation iText Alternative - pdf-generation

I am brand new to pdf generation or rendering. I am working on a application to replace iText and create kind of a RESTful endpoints using any Java related PDF APIs.
The library should be able to convert images and.., others to PDF.
Read/fill the data from PDF programmatically and also merge.
Also, if we can host it ourselves that would be the best choice.
Could you please provide some insight into this?

Not exactly a "Java related PDF API" but since you want to go REST anyway:
We use a headless Chrome in a docker container for generating PDFs. A good starting point is hc-pdf-server. We use it as an internal service using REST.
Note that this way, documents need to be designed using HTML and CSS. Also, you need to use a template engine in order to insert contents into your documents. We use Mustache. It is simple and does the job.

Related

Docx generation - reuse

I'm looking to generate docx and pdf documents in my java application. The best, most cost effective solution seems to be xdocreport - I've started using it and it's good.
However, xdocreport doesn't seem to allow reuse of common sections across documents.
Eg.
I want to create two documents - order and invoice. Both have a customer section which should be identical. It would be nice if I could maintain a single customer template that can be applied to both documents.
Are there any libraries (free or paid) that have this functionality.
The commercial product Docmosis can create DocX and Pdf and has an inert/merge capability meaning you can put common content into a template and merge/reference/insert with other templates. It has a Java API and you can try the cloud service without having to install anything to see if it suits your purposes.
Please note I work for Docmosis.
I hope that helps.

Apache FOP using CQ5

How can we handle pages with different designs when there is a pdf rewriter that is inbuild with Adobe Experience manager.
I know that there is a file page2fo.xsl which automatically generates pdf and we need to specify the rules in page2fo.xsl. But the website im working on is not just one design it is in different countries and different languages with their own designs.
In this situation how can we convert the html to pdf by just giving url as .pdf.
Do we need to write xsl for every design>?
Do we have any mechanism that will handle this situation in Adobe Experience Manager that comes with Apache FOP?
If there is any mechanism can you please give the sample of it to handle different designs?
I had a look into PDF generation with the page2fo.xsl and was even in contact with Adobe support regarding this. There can be only one file for all your designs as it is hardcoded in the final XSLTTransformer service running in OSGi. You can only overlay the configuration "/libs/cq/config/rewriter/pdf" with your custom one below apps, e.g.
"/apps/cq/config/rewriter/pdf" where you can reference a different page2fo.xsl thatn the foundation one. To support multiple designs in your XSL I would suggest a template matching the cq:designPath of your page. The only problem here you would need this property on every page and not rely on the inheritance like in the Edit UI.
Something along the line of:
<xsl:template match="*[contains(#cq:designPath,'/etc/designs/yourdesign')]">
<xsl:apply-templates select="yourdesign"/>
</xsl:template>
But I can guarantee you, it will be a mess and hard to maintain as you really only have this single file for all your custom XSLTTransformation.
I think in your case I would consider using another PDF Framework:
PDFBox from Apache. I made a PoC with it and it is painful for PDF creation as you need to know PDF Syntax
DynamicPDF: I was able to rewrite my PDFBox PoC within 2 days and even add features. So I would recommend it. You can download an evaluation copy and there are many examples around.

play framework 1.x to render rich text

I am using Play framework 1.x and in one case, we are saving rich text data (I am currently using using ckeditor-JS on client side but am open to other suggestions e.g. markdown etc). The data gets saved in the DB correctly i.e. with the HTML tags (unless I am misinterpreting how it ought to be saved). I need to be able to render this content as HTML in my view - should I be looking to use the same library for handling the conversion or is there something in play framework (1.x) itself that I could possibly use. Hope I explained the question properly and thanks in advance to any useful suggestions.

ExtJs: best practices to handle images saving/retrieval

We are developing a web application with ExtJs 4 and Microsoft RIA services + MS SQL Server on the back end. Currently some of the records we store in the DB have attached images to them. Images are stored in binary format in the DB.
What would be the best approach to:
Display them within ExtJs framework
Allow users to upload images via same ExtJs front end
I looked through ExtJs docs and looks like we would need to provide images as basically individual files and use simple img tag for that. Is that correct assumption? Are there other approaches to render images from binary data (which we currently serve via JSON endpoints)?
Is there samples handy for image upload logic?
ExtJS will give you a framework for getting the images via forms to your back end, but what you do with the images from there is completely ExtJS independent. Displaying them within ExtJS is completely independent of the back end logic as well. It's just a matter of finding a way to pipe the data up to the browser just as you would if you were writing a normal HTML page.
I'll take the answer one step further and mention: Storing images in the database is generally a bad idea. At least, storing them in a relational database is generally not a great plan. If I couldn't use a database like Riak (or Amazon's S3) for storing the images, I would probably follow Diodeus' comment and put them directly in the filesystem.

How do I bulkupload image BLOBs in Google App Engine?

I have a model which *I want* to contain an image blob. I have the images on my local filesystem, but due to the nature of my application, I need to get them in the datastore. Here's my model:
class JeanImage(db.Model):
type = db.StringProperty(required=True, choices=set(["main","front","back","detail"]))
image = db.BlobProperty(required=True)
I haven't tried anything yet because I'm not great when dealing with images.
How can/should I convert my images to blobs so that I can get them in my bulkupload csv file?
Mark
You can do it, just not with the bulk uploader. You need to access the remote api directly.
This site has a basic example of how to use it:
http://www.billkatz.com/2009/2/Remote-API-Hello-World
Its pretty slow and a good idea to have a retry mechanism.
A more detailed description can be found here:
http://code.google.com/appengine/articles/remote_api.html
I believe that what you are trying to achieve is not possible using the app engine bulkloader.
Instead try to create some kind of uploader yourself. For example you could upload the images as a zip file and then extract it an store it in the datastore. The code for that should be fairly straightforward if you can map your images to the datastore entity (e.g. by using a naming convention).

Resources