PDF Creation from a word template - pdf-generation

I have this requirement:
Generate a Word document from template using poi.jar. The generated doc will have dynamic values as well as the formatting needed.
Convert the generated doc as it is to PDF. I don't want to apply any formatting again while generating the PDF.
Is there any open source Java API available to do this?

OpenOffice.org offers an API that can do the job for you.
Please note that this question has been answered many times on StackOverflow (and over the web), see this answer for example.

Related

Java PDF Generation iText Alternative

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.

Is it possible using sphinx to link to a specific URL using the :class: role?

I'm using Sphinx to document a python package that wraps a proprietary API that wasn't documented using Sphinx as far as I can tell. The API documentation provides useful information, but the URL's are not in a format that sphinx can automatically generate links for. Is it possible to mark a string semantically as a class, while specifying the link target by hand?
I tried:
:class:`Class <https://api.documentation/some/path/to_class_constructor.htm>`_
but this raises a WARNING: Mismatch: both interpreted text role prefix and reference suffix.. Then I also tried
:class:`Class <https://api.documentation/some/path/to_class_constructor.htm>`
which doesn't raise a warning, but doesn't generate a hyperlink either.
As per Steve Piercy's comment below, the sphinx.ext.extlinks extension keeps the documentation a little cleaner, but it looses its semantic meaning, which I would prefer to keep.
Is it possible to somehow show the text references a class, and at the same time links to the external API documentation?

How to share SQL query results in Slack

I have a similar question to this one (for Pandas), in that I'd like to have the results of an SQL query appear nicely in a Slack message, as a table.
If for example I output the query results as Markdown and then paste this in Jira, a table appears exactly as I'd like it, regardless of whether column names are in snake_case. However, if I choose the Markdown (raw) code snippet in Slack, underscores are interpreted as beginning italics, which is completely wrong.
Does anyone have a better suggestion for displaying tabular results? Or forcing Markdown (raw) to ignore underscores? I tried code blocks as well but to no avail.
For info, the database IDE I'm using is DataGrip.
Slack does not have support for tables, like Jira. So your only option to to choose from workarounds. I see 3 available approaches:
1) Display in external browser
Store your data in an external web app and just post a link to Slack. That works very e.g. with Google Sheets if you use the Google Apps integrator in your Slack workspace.
2) Display as image
Another option is to generate an image (e.g. GIF) from your table and then post the image to Slack. That way the data can be displayed within Slack. To safe Slack storage space I would suggest storing the image file in an external image service (e.g. imgur) and then only post the link. Imgur has an API which would allow this process to be fully automated.
3) Display as plain text
Building upon one of the answers from the question you linked you can also convert your table into a plain text using a tool like Tabulate and then upload it as plain text snippet to Slack. That way the table could also be viewed within Slack. Note that the max size for snippet uploads is 1MB. Also, Slack will only show the first fews lines by default.
Doug here, creator of SQLBot.co. Tables are not supported in Slack, but you can get pretty close using ascii tables and code formating (three tick marks to begin and end)
Here's an example:
The only issue is that if your table gets too wide the text wraps.
Depending on how you're generating the output there may be good helpers. In the ruby world you can use the terminal-table gem or the text-table gem.
Since this comes up on a google search, and the site mentioned previously requires signup, thought I'd share what I found:
https://ozh.github.io/ascii-tables/
Just paste the output in Slack within a Code Block

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.

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.

Resources