I've generated a PDF using iText with form fields and a submit button that POSTS the data as FDF. I dedcided to use POST instead of GET because of the size of data that needs to be submitted. I would like the client to open this PDF in the standalone Acrobat Reader application. In the servlet, I can read in the streamed data. My problem now is, how would I display the streamed data on a webpage?
I searched SO and it looks like a similar question was asked here:
Sending 'success' response back to Acrobat Reader from java servlet
Reading Bruno's answer, it looks like my only option is #2 but unsure of how I would stream the form's data to the server, and then back a webpage to display.
Thanks for the any help, input or suggestions!
Thanks to the comments, we were able to establish that you are asking two simple things.
You are trying to merge an FDF file with its original form. This is done using the FdfReader class in combination with "traditional" form filling: Write FDF to PDF using iTextsharp
You want to return the result to the end-user and have him open it in Adobe Reader: Read PDF file and offer it as download with iText
I realize that this answer doesn't conform with the rules on StackOverflow, as it is a "link-only" answer. My other options would have been: marking the question as duplicate (but then I'd only be able to pick one of the two answers that need to be combined), or adding my answer as a comment, but then it would look as if the question isn't answered.
Related
I'm working in a team as a developer. We have developed a product where we generate letters by populating some XML file. This XML file ONLY contains some texts that need to show up in a pdf document. We then send this XML across to a different area via a web service (say WS-A) call.
This WS-A returns a generated PDF document as a byte stream. Please note that beside generating a pdf document, the backend of WS-A is responsible for the pdf template and how and where these XML texts are displayed in the document. Everything up to this point is fine.
I also do understand that our team needs to write test cases to make sure the correct XML contents are populated before sending it through WS-A.
My question is, is writing a test case which verifies this pdf has the right "texts" (only text verification) our team's responsibility?
Or is this something the other team (in charge of WS-A backend) has to test to make sure they don't miss anything in their PDF from the XML they have been provided (before sending it back to us as a byte stream)?
Yes and no as, it sounds to me like it is a shared responsibility.
As the developer, it is you and your teams job to make sure that you are sending the correct XML template and data. Where your responsibility ends, is once the data has been sent to the backend and the PDF has been generated. It sounds to me that the text being sent can vary so, I would just let the other team handle that since the variance is likely from their side of things.
I've a need to update an existing FDF file, progamatically from server side. For this I'm looking for a Java library which we can manupuate an existing FDF file. I've tried out libraries from iText and Adobe so far. It seems like iText's FDFWriter will allow you just to create a new FDF file and will not help you to update an existing one.
With Adobe's FDFDoc class I somehow managed to update a FDF file, but this API seems to be very old and looks ugly (Method names and field names are not very much elegant and does not follow the camel notation.). My questions is whether there is a known better library?
P.S. : FDF is a data format to collect input data from editable PDF forms
FDF is a simple structured text file, which means that you should be able to do simple text manipulation to modify it. You may actually even be able to create an XSLT (even if FDF it is not XML).
Adobe has the FDFToolkit, which is quite old, but there have been no changes in the FDF format for a long time. Although the FDFToolkit reads and writes FDF, it brings advantages only for reading; writing is sol basic that you don't really need a specific library…
The webpage I'm working on with JSP and a Java Servlet needs to enable the user to write comments and articles which contain text but also Code of various languages (including html and javascript).
The data is stored in a mysql database and displayed later on the page.
For input, I thought to use one of the many WYSIWYG Editors out there.
Those usually produce (x)Html code for the database.
This means I need a type of sanitizing on serverside before inserting into the database since the editor could be easily circumvented and malicious code displayed onto the site (the database itself is secured by prepared statements).
What would be the best and most simple way to approach this topic?
And would it make more sense to switch to BBCode Input instead of html?
I've found several threads here around, but most don't take into account that code actually needs to be displayed on the site and most threads are several years old already.
Huge thanks in advance!
You can use KefirBB to use BBCodes or for HTML filtration.
https://github.com/kefirfromperm/kefirbb
I have plans for a small application, to gather some data from a website.
The website have a few textboxes, in which you can write different numerical values, then click a button and an output value will be written on the page.
What i want the application to do, is to fill the textboxes, then "click" the button and gather the output data.
Now i'm only really familiar with java, but my guess is that it's better to write such an application in javascript?
Also if it's doable in java, should i then be looking at some custom libaries, apart from jsoup which i've already used?
I already sort of figured out how to download the html and extract the data i need using jsoup, it's writing the values back into the textboxes that troubles me.
Thank you
There is an implementation of the DOM(Document Object Model, a data structure representing webpages as object trees) in jsoup that can help you to change the textboxes' values. If you're going to code your project in Java, then JSoup is the better choice to do the job.
I am working on a project here that ingests internal resumes from people at my company, strips out the skills and relevant content from them and stores it in a database. This was all done using docx4j and Grails. This required the resumes to first be submitted via a template that formatted everything just right so that the ingest tool knew what to look for to strip the data.
The 2nd portion of this, is what if we want to get out a "reduced" resume from the database. In other words, I want to search the uploaded content I now have, and only print out new resumes for people who have Java programming experience lets say. So I can go into my database, find the people who originally had java as a skill, and output a new set of resumes that are also still in a nice templated format, and only have the relevant info in them, instead of ALL the content.
I have been writing some software to do this in Java that will basically use a docx template, overwriting the items in customXML which are bound to the content controls in the doc, so the new data shows up and can eb saved as a new docx with that custom data.
This seems really cumbersome to me, and has some limitations. For one, lets say my template has a place for 3 Skills, and the particular person has 8 skills. There seems to be no good way to add those 5 additional skills to the docx other than painstakingly inserting the data with all of the formatting XML tags and such. This is a real pain, because if the template changes, I dont want to have to go back into my software and edit source code to change that additional data input XML tag to bold instead of italic.
I was doing some reading up on using Infopath to create a form that I could use to get the input, connecting to some sharepoint data source or something to store the stripped out data. However, I can't seem to find out if it is possible using sharepoint to get the data back out, in a nice formatted way. What would the general steps for this be? It seems like I couldnt find very much about this topic with any quick googling.
Thanks
You could set up the skills:
<skills>
<skill>..</skill>
<skill>..</skill>
and use a "repeat" content control pointing to the container. This would handle any number of <skill> entries.