I want to give print options in our web application..We are using technologies like spring 3.0,hibernate3.0 and mysql database..What i want is single file ,multiple file print options..When i select check box perticular file after click print button it should go to the printer...Please give some example related to this print options using technologies like Spring,hibernate and mysql database..
Thanks in advance
There are many ways you can go with this, so I'll give you some options to consider:
If you don't care too much about the pixel-perfect formatting, the easiest way is to display a new html document with all the files combined and specify #media print in your CSS for that document. Launch the printer dialog for that document using window.print().
If formatting is very important you may consider rendering a PDF document. iText is a good choice since you're using a Java stack.
If you are in an enterprise environment and know which printers a user can access then you can send Postscript or PDF commands directly to the printer. This is probably the most work but also the most transparent to the user since it can be automated completely.
Related
Is there a way to go to open a specific PDF-page with Java?
It can either open the page in Adobe Reader or a built in reader in Java.
I have the file path and the file saved locally.
It looks like you have a couple of options here.
The easiest way to do this on Windows would be using the command line. Both Acrobat and Reader take command line arguments such as zoom level and starting page. The command to open a document on a specific page on Windows looks like this:
Acrobat.exe /A "page=1000" "C:\example.pdf"
And here is a reference of all the parameters Acrobat and Reader take on Windows - Parameters for Opening PDF Files.
On Mac, things get a bit tricky. Neither Acrobat nor Reader take command line parameters there. However, you still have some options on the Mac. Your best option would be to use AppleScript. Acrobat has extensive support for it, it's fairly easy to get started, and you can even import the AcrobatLibrary and see a list of available API. Here is a good article to get you started on this. As with Windows, it looks like this is both available for Acrobat and Reader.
I've put together a small script that should open a document and then go to a specific page.
tell application "Adobe Acrobat Pro"
tell PDF Window 1
goto page 3
end tell
end tell
Here is a good way to open the newly created AppleScript from Java.
You can add a "go-to" PDF action to the document's "open" viewer application event. Here is how you do it with our company product PDFOne (for Java). You might be able to do the same with other PDF libraries.
http://www.gnostice.com/nl_article.asp?id=217&t=Trouble_free_Linking_To_PDF_Pages_Online
Sample PDF: http://www.gnostice.com/newsletters/downloads/2011_03/PDF_that_skips_to_page_3_by_default.pdf
I think this is what you are asking for...
Say you have a document that has several pages of minutia at the beginning (perhaps a bunch of legalese that you’re not going to read the first time, much less every time). Rather than scrolling past all that minutia every time, you want it to go straight to the table of contents so you can find what you’re looking for more quickly.
If that sounds similar to what you are wanting, then here you go…
(By the way, I’m using Adobe Acrobat Pro. I don’t know if this will work for Reader.)
Open the document in Adobe.
Click Enable All Features.
Click File.
Click Properties.
Click on the tab called Initial View.
Find where it says “Open to page” and enter the page number you want it to open to.
Click OK.
Save the file.
Close the file.
Reopen the file. (It should open to the page you set.)
I want to make an functionality in which user can share the url of uploaded PDF. Now when the another user open the same pdf with given url, first person will scroll down and on another user can see the scrolled content directly or the pdf will be automatically scrolled.
Is it possible using Java, JavaScript or another technology?
Ex. Person 1 has shared exaple.pdf with person 2 by giving link of it.
Person 2 had clicked on link and the pdf is opened at his side.
Now person 1 is scrolling the pdf to page no. 3 and at the same time on the Person 2's screen the pdf will be auto scrolled to page no. 3.
Please let me know if my issue is still not clear.
If I were you I wouldn't definitely use PDF format because it's really hard to manipulate with. Instead of that, you could make your a document a HTML file and then listen to page events with JQuery (like scroll event). So far so good, this is the easy part.
Now you need to make clients communicate with each other so I think WebSocket is the best way for it. If you insist on Java, you can use brand new WebSocket API but it can be also implemented in pure JavaScript like Socket IO so you don't even have to use Java for it.
But if you have to work with PDFs, then good luck, it's going to be really tough task.
As Petr Mensik said it would be probably pretty hard to do it with PDF file with Java, JavaScript.
But if you really want I guess it would be appropriate to check some Adobe SDK. I'm not sure but maybe Adobe AIR or Flex or other Flash application.
I have an existing swing desktop application that I wish to convert to a web application. The first thing that is stopping from doing so is that the desktop application deals with writing and reading from PDF files. Also the user fills up the PDF forms which needs to be read by the application.
Now a typical use case in the desktop application is like, the user logs in opens a PDF form and fills it up. The swing application manages where the file is stored so it goes to the file and reads the form, extracts the data and stores the data in the db. The user might not fill up the form all in one go. He might save it come back to it later and continue.
All of this needs to be done by the web app now. My problem is I don't want the user to download and upload the form multiple times to the server. That would eat the bandwidth and also asking the use to save the file locally and upload it back once he completes filling the form doesn't appeal to me since the desktop application nicely used to manage the location of these files as well.
Would I need to implement something like a dropbox kind of thing? A small deamon running continuously to check what file has been updated and upload it to the server? That would be difficult since at the server I wouldn't know if the file was latest or not. Is there anything like this that someone might have done before?
I have anther suggestion: why don't you show the user a form with the same fields and transfer them to the PDF after the user submits. This way the Pdf does not leave the server and you transmit just the minimal amount of data.
Switching to a web-version of the application may force you to re-think some of the way you are doing things. Certainly browsers are intentionally limited in their access to the local file system which introduces a major hurdle for your current mode of operation.
Even if you could display the PDF within a browser, detect the completion of edits and send this back to the server from within browser code (which is probably possible), you'll be subject to different browsers doing different (strange) things with whatever pdf plugin is installed.
As Vitaliy mentioned already, switching being able to populate a (web) form in the browser means that whole download upload problem goes away. But then you have to take what the user has done in a web page and pump that into a PDF somehow. If you don't HAVE to start with a PDF, but could collect the data and produce a PDF at the end then you might have more options. For example you could use iText to create a PDF directly if you don't have too many styles of document to work with. You could use something like Docmosis which you can give templates to and get it to populate and render PDFs later. With the Docmosis option you can also ask Docmosis for the list of fields in the template so could build a web form based on the selected template, let the user fill it in, then push that data to Docmosis to produce the file.
Hopefully there's some options there that are useful to you.
Adobe documents how to do this here. Never underestimate the power of design-by-google. I know this can be made to work because I've used PDF forms on line.
I worked on a similar issue a few years ago, although I wasn't dealing with signed forms. The signature definitely makes it a little more difficult. However, I was able to use iText to create a PDF form with fields, and only submit the field data back to the server. Offhand, I unfortunately do not remember exactly what/how we did it, but can confirm it is doable (with limitations/caveats). Ex: User had to have PDF reader plugin installed & User was forced to d/l the pdf every time.
Basically what I did was use iText to create an FDF from a PDF (with form existing form fields). The submit button in the FDF actually submits the form data to a URL of your choosing (not unlike an HTML form). Once you have that data, I believe I merged the form fields (from the FDF) with the PDF on the server side using iText.
Once you use the server to maintain all the form data, the synchronization/locking process you use to ensure that a single user is updating the latest and greatest form data is up to you.
Your comment under jowierun indicates that you want to deal with word/excel/etc docs as well, so I am not entirely sure I am understanding your needs. Your initial post discussed the needs to fill out PDF forms locally, but afterwards it sounds like you are looking for a file-sharing system instead.
Can you please clarify exactly what you are trying to accomplish?
I am working on a web application developed in Java with struts running on Tomcat. I have a requirement in the web application as follows:
One JSP page having a list of PDF files each associated with a checkbox. The JSP page has one Button. Once the user selects the PDF documents he wants to print by selecting the associated checkboxes, user clicks on the button.
Then all the selected PDF docs should be sent to a specific local Printer( i.e. printer connected to the client machine where from user is accessing the web application). The selected PDF files should not be opened either in acrobat reader or in browser. The PDF docs should not be visible to the user while being sent to printer.
Could anyone please help me in implementing this requirement?
It is possible with Internet Explorer and ActiveX. Search about "auto print" and "silent printing" with Google. You may have to lower security settings in Internet Explorer for that.
We're using it here for some Intranets from our Customers.
For Firefox you may be able to trigger the print dialog via javascript. (http://stackoverflow.com/questions/975652/silent-print-a-embedded-pdf)
If this is the case you can disable print dialog in FF with setting print.always_print_silent=true in about:config.
Never did it on my own, so I cannot say for sure if it works like the ActiveX thing does.
For Chrome there is an issue requesting same feature like FF has. See https://code.google.com/p/chromium/issues/detail?id=31395.
You will most likely have to use a Java Applet for this. The browser have no inherent capability to print a pdf document. You may be able to access the "standard" adobe plugin, but to my knowledge it is not exposed to the standard scripting environment.
You can look here: Can a Java Applet use the printer?
Note: it is recommended to have the applet signed to prevent security restrictions and/or annoying questions to the user to allow access to printer.
You'll also need some form of PDF renderer in your applet (to render to printer). Something like http://java.net/projects/pdf-renderer/, read more here: http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/
That is not possible with JavaScript. It is possible with either Flash or a Java applet. In either case, you will need to be able to use both the Printer drivers and a custom PDF reading toolkit. There are adequate plugins for both for PDF reading, and both come with a printing API.
If I may say so, this is a bad requirement -- it is not good to force a user to print a document without reading it -- and should be re-negotiated, especially since it is trivially simple to have those documents print to PDF anyway.
I'm wondering if there is a way to create images out of text in a Java web app.
I'm using GWT to design a web app, and would like to allow some administration so that a small number of things could be edited by someone without a ton of savvy and not require a migration. This would be, say, menu headings, which I would otherwise create out of text in (e.g.) Photoshop, and include in my ear. Instead I want to allow an administrator to add some text, and I'd have some code to convert this to an image, using some specified formatting, for "nice" presentation.
As an example, the administrator might want to add a "news" page. So he will enter News and it will come out looking like:
Am I making sense? Is this something that is done? Are there libraries available for this?
This explains the concept pretty well.
Are you wanted to create Vector graphic then yes. You could also convert image into base64 string to store the image and reverse back loading at client.