I'm trying to figure out a way to programmatically determine a printers inputslot tray to number definitions for use in generating postscript.
I have gathered a collection of PPD files and collated information that way but it seems stupid to be limited to only the printers i have the PPD's for - would be better to interrogate the printers installed in windows, cant see it being a problem for unix installs. Would this be possible in Java or .NET?
edit:
I've since found out that postscript level 2 uses the actual tray names instead of the numbers. Since i know its possible to query the printers (or it could just be retrieving the information in windows) in .NET for the tray names i figure when the decision to change this in postscript 3 was made, they must of had a way to get the id's...
Anyone that can point me in the right direction? Google cant seem to help. Or at least i cant find the right search terms
Try with DeviceCapabilities and DC_BINNAMES.
Tje java print system allows interrogating the printers ón the current system and determne such functionality.
Related
I have really low knowledge on Java and JasperReports, barely used those to play around, nothing too serious. A friend of mine has been trying to get someone to develop him an application that will generate PDFs with information from an access database for each of his clients, however, after 6 months and 7 developers who ditched him, he has found none, so he asked me if I could help him to which I said I'd give it a try.
What I have been able to do so far:
So far I've managed to successfully (Everything has been done separately, I have like 8 projects in total so far):
Use Jaspersoft Studio/iReport to create a single PDF with the required client information on each sheet.
Create a separate JasperReports project with a input field to get a pdf with a single client information.
Create a Java App with a JFrame to launch the report generation.
Create a Java App to connect to the access database through ucanaccess and validate the search criteria
Questions:
Now, after a few days on Google up and down I havnt managed to successfully achieve everything that I'd like to achieve, and I'd love if someone could either point me into good noob-proof guides or (if willing) provide a noob-proof answer so I can continue to move on.
Create a Java App where you can choose to generate all client's report or a single report for a specified client (I am assuming this isn't too complicated since it'd just be a matter to embed both Jasper reports into the java app), however I'd need to pass the input value into jasper report field to generate a single report (Not sure if this one was clear enough), and run the query for the data-set based on that field's value.
Ideally though not highly needed, pass yet another variable as a field to set a date range.
Since this is being done on a MS Access Database -*.accdb- (Don't blame me, I've been telling him to move to MySQL/SQL for quite a while now), I'd love to know if its possible to make JasperReports do a query based on a UCanAccess JDBC connection (Tried a few options, none worked).
Finally, I need to generate in the report a date range (Something like: "Between 1/Jan/2014 and 1/Feb/2014")
I feel like I've made a decent amount of progress so far, but since I am no pro on either JasperReports nor Java, I am getting stuck in a point where more knowledge is required to create a more decent and practical piece of software and I'd love if someone could point me into a better direction (Either if something is impossible or just a few links to help me get thru)
-Remeber to add ucanaccess jar and all dependencies jars in the Driver Classpath, while creating the Data Adapter
-You have to set Showschema=true:
e.g.
jdbc:ucanaccess://c:/db/database.accdb;Showschema=true
In this way Jasper Studio will be able to navigate the metadata of your database, and you'll find your tables under the PUBLIC schema.
Then you'll be able to create your reports as usual.
I'm trying to print some PDFs using Java and I've found a few examples on how to do it. Seems pretty straight forward, but I've been running into problems the whole way.
I first tried PDFBox and it prints, but it doesn't print the document how it should look. A lot of the text gets garbled for some reason. So then I tried using the included Java packages this way and with an example from Oracle but nothing happens. I run the program, I check the print queue in the OS and the job is there, but the printer does nothing. My program exits gracefully with no errors and the print job goes away after a little while but there's still no action from the printer itself.
As an alternative, I've also tried running Adobe Acrobat from within my program but there are no command line arguments to enable duplexing which I need.
If anyone can either help me fix this, suggest another package or command line tool, it would be much appreciated. Thanks!
I found this link helpful ...Your mileage may vary...
The basic idea is to use the java.awt.print package and Apache PDFBox (org.apache.pdfbox.pdmodel.PDDocument)
PDFBox also has command line options to print, encrypt, decrypt, etc.
This is the best solution I found for this matter: ICEPDF.
Printing is 99% loyal to PDF seen on screen, allows silent printng and paper size changing. Only drawback, so far, is that I'm unable to show the print dialog, in same cases I need the user to be able to select printer, page size, number of copies, to name a few, this options are now selected prior by the user in an interface of my app.
Anyway, hope it helps!
I need to implement a custom printer driver which does the following in the backgroud:
Create a PDF document of the document to print
Send the created PDF document to a predefined email address OR
call a web service and transmit the document there
The pinterdriver should be available for windows and mac osx. My prefered implementation language is Java.
Is this possible with Java?
Are there frameworks available which reduce the coding effort to a minimum?
Are you sure "driver" is really the word you are looking for here? Usually when one says a print driver they actually mean something that translates document data into commands for a printer. I think you are really looking for something of a pre-processor.
In any case, if you want it to look like a printer to the OS, it will be almost impossible to do purely in Java. Your best bet would be to create drivers for each of the platforms that use JNI(or just invoke a JVM), do your processing, then forward it on to the printer.
Although I do not know if a similar approach will work on Windows, what you want to do is almost trivial to do on OS X. Apple already provides a cups-pdf service that converts any printable document into a pdf, all you have to do is take that output, forward it to where it needs to go, then forward it to a printer, no need to do anything in Java.
For an example of how to do this, check out the following project:
https://bitbucket.org/codepoet/cups-pdf-for-mac-os-x/downloads
Windows can be configured to send printer output to a file. You can create a printer in Windows that uses a PostScript driver, and writes it to c:\myfile.txt
In Windows: Add a Printer, Select Local printer, Select Create a new port, and type the file name (Full path) you want to use. Then pick the driver you want, which your Java program will have to parse. Generic text could be useful in some cases, or Postscript if you need all that formatting, and can handle parsing it.
Unlike the "File:" option under existing ports, it will not ask the user for a filename. It will just automatically save to the specified file every time.
Your Java program can monitor this file for changes, and then process the data it receives.
I need to understand the directions in need to look into to Writing a program that figures out what all websites have been hit by a user using his browser. I want to write a standalone program. Can anybody direct me to some API which may help me figure this out.
Well, first of all that depends on which browser do you need to check. I'm guessing that you need to check the currently set default system browser. Anyway, that will require a lot of browser research and few JNI calls.
To find a default browser you would need to check HKEY_CLASSES_ROOT\http\shell\open\command (for Windows) and various configuration files under different linux for different window managers.
Then you would need to read the history of the specific browser from the format of that browser. For example, Firefox stores it's history in sqlite format in the profile directory in places.sqlite file. Chrome on other hand stores it in %home%/User Data/Default/history. So you would need a separate parser for each browser.
Basically, if you need a universal browser history reader - it's a load of work and research.
As it was clarified by the author in his comments - he needs to check what is user currently browsing.
The only truly browser and OS independent way is through proxy. You need to create a HTTP(S) proxy with Java (there are some implementations out there already) and then reconfigure the desired browser to use the proxy running at localhost. When your proxy is used - it will be able to track every bit of traffic the user tries to load.
This information is stored in a SQLite database in firefox:
The file "places.sqlite" stores the annotations, bookmarks, favorite
icons, input history, keywords, and browsing history (a record of
visited pages).
http://kb.mozillazine.org/Places.sqlite
Other browsers probably have similar approaches.
Any language with drivers for SQLite, and that includes Java, C, C#, C++, ruby, and, yes, even javascript, should be equally capable of accessing this database.
Speaking for myself, I would be interested collaborating on such a stand-alone program in Java should the OP put his code on github.
Have done some research into this topic, but found no relevant answers. What I need is to print a number of PDF files on one of three forms, which are loaded into different trays of a particular printer. I need to specify which printer to use and it's not the default printer. Additionally, I need to specify which tray to use based upon an attribute of each PDF file and be able to switch between them at run time. Java PrintService seems to only be interested in the local default printer. I'd appreciate any suggestions on how to accomplish this task. Thanks.
The Printer API does allow for talking to different printers other than the default. That being said it is limited. What we did in our shop is to write a JNI layer that talks directly to the Print Queue of Windows and we use that. If you want finer control than the PrintService API provides you will need to write a JNI layer and access that from Java.
You could configure a different printer for each tray in your OS, Then print to that printer depending on the properties of your file.
Thanks for all the suggestions, but I think I have worked this out now. I'm using LPR for the printing and org.apache.commons.net.ftp.FTPClient for the tray switching commands. The actual tray commands are in text files. My tests (so far) have been successful and I did not have to install the printer on my workstation.