Printing client side with Applet!!!

Hi,
Does anyone can help me with my applet. It must get the current page and print it in landscape out over at the user side (local printer).
Here some sample of my source to help....
// JavaScript part
function print(){
var myURL = document.location.href;
alert(myURL);
testApplet.print(myURL);
// Applet part
public class MyClass extends Applet implements Pageable, Printable {
// .... some source ...
public void print(String myURL) throws IOException, PrinterException {
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat landscape = job.defaultPage();
Paper sheet = new Paper();
sheet.setImageableArea(0,0,landscape.getImageableWidth()+ (landscape.getImageableX()*2),landscape.getImageableHeight()+(landscape.getImageableY()*2));
landscape.setPaper(sheet);
landscape.setOrientation(PageFormat.LANDSCAPE);
JTextPane txt = new JTextPane();
txt.setPage(myURL);
// this method initialise the parameters for the printing
initialise(txt.getText(), landscape);
job.setPageable(this);
job.print(); ///// THE PROBLEM IS HERE
java.awt.print.PrinterException: No print service found.
at sun.print.RasterPrinterJob.print(Unknown Source)
at sun.print.RasterPrinterJob.print(Unknown Source)
at PageableText.test1(PageableText.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
I have printers define and they worked well. Also, I have use the same code but without the Applet (calliing it from the main and with a static url) and it work perfectly. I'm pretty sure it's the Applet who's causing trouble.
Anyone has any idea or sample to help me?
Thanks

It has to do with the JS call to the print method. I got around it by calling my printData() method in a separate thread...
try something like this:
============================
public void jsPrintData()
if ( isPrinting )
return;
isPrinting = true;
Thread runner = new Thread()
public void run()
printData();
runner.start();

Similar Messages

  • Why cannot execute DB operation at client side with dynamic proxy?

    I want to execute a DB operation at client side with dynamic proxy. that is bypass EJBs to execute DB operation. And there is a data source in weblogic server, and I get an EJB instance using dynamic proxy, get connection using this instance, then invoke executeQuery method. But it is failed, and throw exception when execute "conn.setAutoCommit(false)" as below:
    <Caused by: weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
    [java.rmi.UnmarshalException: Could not unmarshal method ID; nested exception is:
    java.rmi.UnmarshalException: Method not found: 'newArrayDataResultSet(Loracle.sql.ARRAY;JILjava.util.Map;)']
    at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_OracleConnection_813_WLStub.setAutoCommit(Unknown Source)
    at weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_OracleConnection_813_WLStub.setAutoCommit(Unknown Source)>
    but it is no exception and run well using EJB, who can tell me why? if it is a weblogic limitation? and my version of WLS is 8.1 sp3

    Hi,
    Do you create the connection object on the server and pass it over to the client, we do not allow passing the connection object over the wire.

  • What kind of hardware is required on client side with OWB 10gR2?

    Hi,
    What kind of hardware are you using, on client side, with OWb 10gr2?
    Currently I'm using a PC having a Pentium 4 1.7Ghz with 1.5 GB Ram but it's extreamly slow.

    Hi
    For Windows, ensure that the machine has a minimum of 850 MB disk space, 768 MB available memory, and 1GB of page file size, TMP, or swap space.
    For Linux, ensure that the machine has a minimum of 1100 MB disk space, 768 MB available memory, and 1GB of page file size, TMP, or swap space.
    Are you running an anti-virus? If so, try stopping it and run OWB. This is due to the anti-virus action and OWB being a java based tool...
    Regards,
    Marcos

  • Merging randomly-named XML data file on client-side with pdf designed in Livecycle 7.0 (and addition

    Okay, as a heads up I work for a financial institution and we are converting our legacy "jetforms" to pdf format. I have in my staff for the project, 2 code developers and myself- a form designer. We have currently spent 2 months in trial and error attempting to resolve this problem, please let us know anything you can have. All client-side (internal) machines are running Windows XP and Adobe Reader 7.0.7
    The software we use as a financial institution allows our users to export a customer's data file onto their machine which is then renamed to include the member's account number and first and last name for our staff to determine which data file they need more accurately. In legacy jetforms, we have developed a program that pushes the data from the customers file that they select, into the jetform that they want to open and the matching fields in the data file fill in the fields of the jetform. Clean and simple.
    Now, i have hit nothing but frustration when attempting to perform the same process with pdfs using a form designed in livecycle designer 7. First, i see no obvious command for opening a pdf and importing a data file using a command line, like pdfmerge or something of the sort in which an xml data file can be specified and a pdf can be specified. I saw something like it using an fdf format and attempted to do this but apparently reader cannot import the data into the pdf that was designed adobe livecycle 7. All i have been seeing is database connections and using javascript inside the form to populate fields based on these database connections, etc. etc. or doing a manual file>import data>etc. which we don't want to have our staff do. We do not have reader extensions enabled, simply because i cannot get an adobe representative to call me and discuss pricing nor see any estimated pricing chart around. I don't know if reader extensions are necessary for this or not but i'm becoming very very frustrated with it.
    We don't want a complex server-side data connection binding with dynamic input. No, we just want it where our developers can say "if this data file is selected, and this pdf form is selected run this command" which would be a simple pdfmerge type solution. Is this possible or do i need to stay with jetforms until our software the billion dollar financial institution uses does form building inside its own application? I don't want to fight about who is better, what version to use, etc. I just want the straight up honest truth. If you need to know the pricing that the reader extensions would have to go by, assume there will be 500 client computers that will need to use it.

    From your post it sounds like you are Central Pro (a product for which I am by no means an expert), but you say you want to upgrade to a newer product from your "legacy" one. Is there a reason for this? Have your requirements change so that it no longer fits them? Central is still in the current Adobe roster and as far as I know there is no plans to get rid of it any time soon, so if it does everything you want I don't see why you would want to change.
    There is no product in the LiveCycle suite that merges xml data into a form from the command line. LiveCycle (with the exception of Designer) is a suite of server products, so the closest you would come is LiveCycle Forms (merge the xml and create a fillable PDF) or LiveCycle Print (merge the xml and print the form).
    Hope this helps somewhat.
    Chris
    Adobe Enterprise Developer Support

  • How to print two sides with one page?

    I have a PDF that is one page long and I'd like to print the same thing twice (front and back) on one page. Can I do that?
    I've tried printing two copies with the printer set to double-sided, but it just printed two sheets with one side on each sheet.

    Well sure; Go back to the authoring application that created the documents and do a 2-UP page. Make the existingg page large enough to accomodate the extra content. Is that what you're asking or do you really mean print to a printer with a back up ? In that case just flip the page over and print page 2 on the other side.
    Or are we missing something ?

  • Register dll on client side through applet

    hi
    can any on e tell how to register a dll on client side from a signed applet.
    thanx

    I am not very sure. But you can try this:
    public class Dialup {
    public static void main(String[] args) throws Exception {
    Process p = Runtime.getRuntime().exec("register_dll.bat");
    p.waitFor();
    System.out.println("Done.");
    where register_dll.bat is your dll registration (regsvr x.dll)
    Let me know if this works
    Adina

  • Limiting bandwidth on client side with Camera.setQuality() inconsistent?

    After successful bandwidthCheck() limiting bandwidth to setQuality(75000, 100)
    leads to the desired result of publishing the stream with max bitrate of 75000 byte/s.
    On other locations the same setting results in publishing the stream with max bitrate of 
    approx. 13107 byte/s. If I change bandwidth to setQuality(400000, 100) i am reaching the desired
    bandwidth limit of 75000 byte/s.
    Stream is published with h264Settings.setProfileLevel(H264Profile.MAIN, H264Level.LEVEL_5_1).
    Any clues?
    These behaviour only occurs with outStream.videoStreamSettings = h264Settings;
    If videoStreamSettings is not set to h264Settings all things are doing well as expected.

    Here's a link that explains what BBSM is all about:
    http://www.cisco.com/en/US/partner/products/sw/netmgtsw/ps533/index.html

  • Chart Control printing at the client side

    Hi,
    I have multiple chart controls (in VS2010) on an aspx page, which also show their relevant detaild data in a table on the same page. I could not found yet an appropriate solution for printing such a page with chart control and other data.
    In fact I was able to print the chart alone at the client side, but only by sending it directly to the printer, this method is unable to show print preview dialog to the client.
    Then i started thinking in another direction, and came with the idea to export my desired controls into a pdf file which then can be shown in the browser (which resolves browser independance), for that i used nReco (the dll which comes with dot net) pdf converter
    which can convert the whole html page into the pdf file (by passing the url of the page) and then opens/saves in the browser to print.
    But when i pass it (to one of the the funtion in nreco) a container means a div or a panel control which holds the chart control and other normal controls then it gives me the error that unable to convert to pdf.
    Tis may be due to the relative path of the chart control image.
    I am stuck in this situtation, My original requirement is to show the the print preview to the user at client side with all printing options. It would be very convenient if the desired control can be exprted to pdf.
    And I don't want to use any ohter third party control (for print preview at client side) which needs to be installed on the client machine.
    Thanks.
    Code Sample:
    using NReco.PdfGenerator;
    on Load
    Chart1.Series[0].Points.DataBind(datatbl.Rows, "ColHeading", "colName", string.Empty);
    On Print
    HtmlToPdfConverter nRecohtmltoPdfObj = new HtmlToPdfConverter();
    nRecohtmltoPdfObj.Orientation = PageOrientation.Portrait;
    StringBuilder sb = new StringBuilder();
    StringWriter tw = new StringWriter(sb);
    HtmlTextWriter hw = new HtmlTextWriter(tw);
    ChartPanel1.RenderControl(hw);
    string temp =
     "<html><head><style>td,th{line-height:20px;} tr { page-break-inside: avoid }</style><script>function subst() {var vars={};var x=document.location.search.substring(1).split('&');for(var i in x) {var z=x[i].split('=',2);vars[z[0]]
    = unescape(z[1]);}" +
                "var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];for(var i in x) {var y = document.getElementsByClassName(x[i]);" +
                "for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];}}</script></head><body onload=\"subst()\">"
     + sb.ToString() 
     + "</body></html>";
    nRecohtmltoPdfObj.GeneratePdf(temp);
    Please suggest a batter way out.

    Is this question hard to answer? or I am going to the wrong direction since I am new about Java EE/EJB.
    Can anyone give me some answer?

  • Cannot work with two client side applications at the same time!!

    Hi guys,
    I developed two client side applications(applets). Locate the on Apache/Tomcat. There is also a Index.html file with two links, so when user clicks on each link the associated application will downloaded on his PC and ready to work. (In index.html I used window.open(�) to load the applications)
    Now please see this scenario:
    1-I ran/loaded both application in two separate browsers(IE5.5). And tried to work with them(minimized one and work with another). Soon I faced unexpected frizzing/locking or very slow running on both applications.
    2-Then closed/killed one of them(killed IE). Then re-executed same application again. The application loaded with the last activated screen . Seems it never killed and it was still alive.
    3- The only way to successfully working is one by one.
    means execute & work with one, then kill that, and then execute and work with another.
    To Debug:
    When both applications were running(each on it�s own IE), I opened the Task Manager and saw there was only one IEXPLORER.EXE was running, also there was only one Java VM (a small bird icon) on right-bottom of the screen.
    I believe this causes the problem. seems they both running in the same session. Since I opened two applications in two IE I was expected to see two IEXPLORER.EXE with two JVM. Am I right? Do you think so?
    Any way, Now I am seeking to find the solution. My primary mind says probably I should not use window.open(..) in index.html to load the applications.
    Would appreciate any command on this.

    Cross post
    http://forum.java.sun.com/thread.jsp?thread=184829&forum=31&message=589933

  • Set printer from client side

    Hi All,
    I am browsing in this forum, how to set printer crystal report at runtime in web application. I find that way, but in server side. I have web application that deploy ini web server and I have end user/client that want to open report in my web application and print it. Could you give any snippet code to do it?
    Thanks.
    Sri

    To print client side you must install the Crystal Reports ActiveX control. The security warning is the same as any other ActiveX control you'd install. Simply click the yellow bar at the top of your browser screen, or follow the directions to install it.
    If you don't want to install the ActiveX control you can use the Pdf print mode instead.

  • Printing with applet

    hi
    i am trying to print some text with applet but it is not working here is my code
    sMsg="printing a applet is tough job";
    // Find the default service
    DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
    PrintService service[]= PrintServiceLookup.lookupPrintServices(flavor, null);
    // Create the print job
    byte[] b=sMsg.getBytes();
    DocPrintJob job = service[0].createPrintJob();
    Doc doc = new SimpleDoc(b, flavor, null);
    try{
    job.print(doc, null);
    }catch(Exception e){System.out.print(e.getLocalizedMessage());}
    it is not doing anything not even the error is displayed
    when i execute this code i get dialog box which ask me to allow this applet to print or not but after that ,nothing happens.
    plz help me.
    thanks in advance.

    Hans,
    I came across a similar problem a few months ago. I came up with a work-around, and although it's not great, it met the demands of my current project.
    A normal applet can't write files to a user's computer because that could create some big security problems. However, an applet can communicate with the server on which it's located. SO, I created a servlet that resides on the same server. When the user wants to print something from the applet, he clicks a Print button which opens a URLConnection and sends the data to the servlet. The servlet then creates an HTML document on the server and formats the data nicely. Then, back in the applet, I used this line to open a new browser window and show the HTML file:
    getAppletContext().showDocument(new URL(theUrl), "_blank")
    The user can then use the browser's print function to print the data.
    I know it's kind of a roundabout way, but I was pressed for time. Let us know if you come up with something better.
    -sheepy.

  • How to implement a persistent HTTP connection on client side...

    Sorry for the inconvenience everyone, but I could really use some help here since I am a total newbie to Java programming
    I am trying to implement a persistent HTTP connection on the client side with request pipelining. The way I understand it is that client requests will be sent to the server, which will reply to them back to back, and then the client will read them accordingly. But when I read the server responses, I get only the reply for the first request, and nothing further, when I actually expect it to give me as many responses as the number of requests I ussued. Here is a sample code illustrating what I am trying to do.
    ====================
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class HttpClient {
    public static String host = "www.somehost.com";
    public static int port = 80;
    public static String pathname = "/download.asp";
    public static String protocol = "http";
    public static ArrayList list;
    public static void main(String[] args) {
    Parser parser = new Parser();
    list = parser.getIDs();
    try {
    Socket socket = new Socket(host, port);
    InputStream from_server = socket.getInputStream();
    PrintWriter to_server = new PrintWriter(socket.getOutputStream());
    OutputStream to_file;
    to_file = new FileOutputStream("HTTP_response.txt", true);
    for(int i = 0; i < 3; i++)
    String s = (String)parser.getIDs().get(i);
    String filename = "/download.asp?id=" + s;
    to_server.print("GET " + filename + "\n\n");
    to_server.flush(); // Send it right now!
    //This response gives only  only the response to the first
    //request,....
    byte[] buffer = new byte[4096];
    int bytes_read;
    while((bytes_read = from_server.read(buffer)) != -1)
    to_file.write(buffer, 0, bytes_read);
    to_file.close();
    socket.close();
    catch (Exception e) {
    System.err.println(e);
    System.err.println("Usage: java HttpClient <URL> [<filename>]");
    }

    There are many things wrong with your code. Learn the HTTP protocol and you'll know what I mean.
    Here's a hint - you'r missing headers in your code.
    Some servers do not support keep-alive connections, nor do you request a keep-alive connection.
    Connection: keep-alive
    Use that header field and see what happends. Also, in your while-loop, you actually close the output file and the socket. Don't you think it may be hard for the server to respond to a client that closed the connection on it?
    1. You don't know HTTP
    2. You don't seem to know Java
    3. You don't seem to understand basic programming logic

  • Webservice without client side interface

    Is there a way to call a webservice from the client side with out having any jar or interface used in the client side?
    Can you recommend me some good links on this?
    Thanks

    The most flexible client invocation method is DII (Dynamic Invocation Interface). With this approach your client needs just the standard JAX-RPC JARs from the JWSDP, but it doesn't need any runtime classes generated by WSDL to Java mapping tools.
    The following link has some DII examples as well as comparisons with the other types of client invocations:
    http://www-128.ibm.com/developerworks/webservices/library/ws-javaclient/

  • Form2email - cgi2email question (client side only forms sent via email?)

    I am being asked to design a standard questionnaire form.
    They want
    the answers to the form be emailed.
    However, they host their own pages on a microsoft-based
    server that
    has no perl library, VB library, etc.
    Is there a way to do a form and generate an email totally on
    the
    client side with no server based application needed
    whatsoever?
    Thanks,
    -Dan

    You can create a simple mailto: link on the form that will
    invoke the client
    mail program but it is not that reliable. However if they are
    hosting using
    IIS it does have built in mail capability via CDO using an
    ASP page, or it
    can be set up to run ASP.Net with its mail handling scripts.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "Canned Heat" <[email protected]> wrote in message
    news:[email protected]..
    >I am being asked to design a standard questionnaire form.
    They want
    > the answers to the form be emailed.
    >
    > However, they host their own pages on a microsoft-based
    server that
    > has no perl library, VB library, etc.
    >
    > Is there a way to do a form and generate an email
    totally on the
    > client side with no server based application needed
    whatsoever?
    >
    > Thanks,
    > -Dan
    >

  • Printing multiple PDF with single event at client side

    Hello,
    I have a requirement where I must print multiple different pre-populated Adobe forms (e.g. populated with a name/address) from ABAP WD. These need to be printed at a client side printer, and they don't want to see them first (that would be easy). Just print multiple forms from a single button click.
    Has anyone had this requirement? My main question is not how to pre-populate the pdfSource, but how to have the user prompted for a printer 1x and then have the forms sent straight to the local printer without displaying.
    Thanks!

    Sorry to 'hijack' this thread but i was trying to do the same thing but failed EVERYTIME!!!
    When i tried to merge just 2 multiple-paged(abt 20+ pages each) pdfs into one, it simply crashed Preview at the end of the process! Tried 'Save', 'Save all' & 'Print as PDF' but all doesn't work!
    I tried Combine PDF.app & Automator.app and the same thing happened. The combining process CRASHED the app i used...
    Help needed!

Maybe you are looking for