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.)
Related
I would like to ask the community if there is any way to create a GUI menu where the options will populate itself based on number of files that are saved in a folder directory. The user will then have two options whereby he can choose to generate a status or a dashboard option. After he chooses the report that he wish to generate, another menu will appear to ask him which document he want to select. This is where the menu would check the folder and generate the options based on number of files in the folder. For example, there could be doc1 and doc2 in the folder. Then the menu will generate 2 options. 1. Select doc1. 2. Select doc2. Then after the user inserted another doc3 into the folder. The menu will add another 3. Select doc3 without having the user to change the code. Is there a way to do this? Thanks.
This makes no sense. A .bat file is by definition something that does not have a GUI.
Also you really have provided the vaguest information for something seemingly large, and there appears to be no reason why you've also tagged this as excel and exe.
Since your .bat file could launch a particular Excel file, you could go that way, putting all the dashboard info in the spreadsheet. Would require some VBA code to make it as interactive as it sounds like you want, but that's entirely possible.
I'm not aware of any way that a .bat file can create a GUI on its own, although I may be missing something. Since the .bat file can run almost anything, it can be a starting point, but the heavy lifting would be done in something else.
Another approach would be to look at AutoHotkey, which can give you a GUI and a fair bit of processing power & interactivity all within the one script. The URL is http://www.autohotkey.com/ and that site has a tremendous amount of examples and help available. Also some AHK questions here on Stack Overflow from time to time.
Either way you go, it's a fairly large project. Good luck!
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.
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.
You may all have seen online content management systems or publishing platforms, where one can edit a page, but for convenience, the editing is not done in the browser, but instead in Microsoft Word. So whenever you open the page to edit it, the current page is send to MS Word and after completing the editing, Word sends back the page to the server.
A good example is Confluence. Instead of using the built-in WYSIWYG editor, you can also edit a page in MS Word.
How does this work technically? I want to program something similar on a Java servlet based web app. The first part is easy. I convert my page into the format of the external application and send it to the browser setting the correct mimetype. The external application will open the document. But I have no idea how the second part works. How does this application sends the file back?
Please send me any pointers you might have. My main problem is probably that I really don't know what I should search for. Also, if you know any opensource Java based projects doing something similar, I would like to study them to get started.
PS: Please feel free to change the title of this question!
One way this works is if you start Microsoft Word not wih a file as an argument, but witha n http/https URL that points to a WebDAV-supporting location. In this case Word will send the file bach witha PUT method when saving.
I am trying to link some user docs to my Java Swing application. The user docs are pdf and I would like to be able to click on a button in my application which opens up some sort of pdf renderer to display my userdoc.pdf.
I do not want to use the runtime exec command
I have tried the following with not much success --
pdfRenderer -- this seems to not work for the current version of pdfs (seems to want older pdfs)
acrobat viewer -- I keep getting font errors (the document is displayed but everytime I go to a new page, I get an error)
JPedal pdfHelp - This sounds cool and if it will work, it would be the best for me. But for some reason, I am unable to open any file here. No pdf file that I have loads in the window (The pdfHelp panel comes up with a list of pdfs as promised, but when I right click one of them and say "OpenPDF", I just get a progress bar and the file does not load, I have tried a few files on this and checked file permissions)
JPedal SimpleViewer -- So far this one seems to be the most promising. I would like to remove some of the functionality of this viewer though and am not able to edit the xml to do this. When I edit the xml, then I seem to get xml parsing errors.
Has anybody done anything similar that worked? Help please
PS. I need this to work on Linux machines (IcePDF seems to works only for Windows). I would very much prefer something that is free!
Would Java's Desktop API meet your requirements? It does launch another process, but it's not through you calling Runtime.exec().
The Desktop API uses your host operating system's file associations to launch applications associated with specific file types.
Update: pdfHelp from IDR solutions (creators of JPedal) works now. The latest version (4.0) has fixed the bug and it reads my pdf files (and I am sure more of the latest pdf files). Just playing around with the product today and it is great! There are few minor bugs but I really appreciate how quickly Mark Stephens(?) responded to the first bug. Good work guys!
I chose pdfbox for a similar use case - it's not perfect with every PDF, but works pretty well and is under active development. From the PDDocument you can get a list of PDPage objects, which have a convertToImage() method that gives you a BufferedImage you can draw on screen. I switched to this from pdf-renderer because I felt it gave better results in general.
PdfHelp has moved to its own domain at http://www.pdfhelp.org and have been updated to fix your issues and add some other improvements...