5 Replies Latest reply: Oct 13, 2011 3:30 AM by 751880 RSS

    Multipage word document cannot be printed using webutil

    751880
      We have the following problem. We are using Oracle Webforms 11g (11.1.1.4). On the server a Word 2010 docx document has been created and needs to be printed locally. We use webutil for this with the following code:

      -----
      -- create a new document
      app := client_ole2.create_obj('word.application');
      client_ole2.set_property(app, 'visible', 0);

      docs := client_ole2.get_obj_property(app, 'documents');

      args := client_ole2.create_arglist;
      client_ole2.add_arg(args, p_filename);
      client_ole2.add_arg(args, 0); -- confirmconverion (false)
      client_ole2.add_arg(args, 1); -- readonly (true)

      client_ole2.invoke(docs, 'open', args);
      client_ole2.destroy_arglist(args);

      client_ole2.invoke(app,'printout');
      client_ole2.release_obj(docs);

      args := client_ole2.create_arglist;
      client_ole2.add_arg(args, 0);
      client_ole2.invoke(app,'quit', args);
      client_ole2.destroy_arglist(args);

      client_ole2.release_obj(app);
      -----

      When the document to be printed consists of only one page the document is printed. When there is more than one page (hard/soft page end) the resulting document is empty. We also tried Word 2003, RTF format but nothing worked.

      Extra Info:

      Clients: Windows XP SP3, Office/Word 2010
      Server: Forms 11.1.1.4, Windows Server 2008R2
      Webutil/jacob: 1.10.1 as recommended.

      What can we do to solve this?
        • 1. Re: Multipage word document cannot be printed using webutil
          InoL
          We had a similar issue. I don't think you can solve this (except for splitting the document in multiple docs). It has actually nothing to do with webutil or Forms. It is a limitation of OLE2.

          Why not transfer the file to the client and print it with a client_host command?
          • 2. Re: Multipage word document cannot be printed using webutil
            Michael Ferrante-Oracle
            You may want to look at this. It would appear that you need to define "Range".

            http://support.microsoft.com/kb/176069

            I have not personally tried this, but it might be helpful.
            • 3. Re: Multipage word document cannot be printed using webutil
              Michael Ferrante-Oracle
              Ok... I went back and tested your code and by adding a "0" for the Range param, all pages of my 3 page doc printed.
              -- create a new document
              app := client_ole2.create_obj('word.application');
              client_ole2.set_property(app, 'visible', 0);
              
              docs := client_ole2.get_obj_property(app, 'documents');
              
              args := client_ole2.create_arglist;
              client_ole2.add_arg(args, p_filename); 
              client_ole2.add_arg(args, 0); -- confirm converion (false)
              client_ole2.add_arg(args, 1); -- readonly (true)
              client_ole2.invoke(docs, 'open', args);
              client_ole2.destroy_arglist(args);
              
              -- CHANGES BEGIN HERE
              args := client_ole2.create_arglist;
              client_ole2.add_arg(args, 0); -- 0 means background printing
              client_ole2.add_arg(args, 0); -- 0 means no append
              client_ole2.add_arg(args, 0); -- 0 means print all pages
              client_ole2.invoke(app,'printout',args);
              client_ole2.release_obj(docs);
              client_ole2.destroy_arglist(args);
              -- CHANGES END HERE
              
              args := client_ole2.create_arglist;
              client_ole2.add_arg(args, 0); 
              client_ole2.invoke(app,'quit', args);
              client_ole2.destroy_arglist(args);
              
              client_ole2.release_obj(app);
              This appears to be the syntax according to the MS docs:

              PrintOut([Background], [Append], [Range], [OutputFileName], [From], [To], [Item], [Copies], [Pages], [PageType], [PrintToFile], [Collate], [FileName], [ActivePrinterMacGX], [ManualDuplexPrint], [PrintZoomColumn], [PrintZoomRow], [PrintZoomPaperWidth], [PrintZoomPaperHeight])

              .

              Edited by: Michael Ferrante on Oct 12, 2011 3:48 PM
              • 4. Re: Multipage word document cannot be printed using webutil
                751880
                We could do that but run the risk, as a lot of people are printing documents, the documents are also split up when printed. So every user has to gather his parts of the document afterwards.
                • 5. Re: Multipage word document cannot be printed using webutil
                  751880
                  I tried something else. I removed the quiting part for a moment. Then it printed ok. So it is a timing problem. The document was quited before the printing ended. Together with the suggestions for addional parameter settings for the printout I was able to fix it. In my case the printing was done in the background. I changed this so the printing is not in the background anymore. The quiting is processed after the printing is done. The downside is a printing popup appears on the screen but this is a word feature. Perhaps I can swith this off also?