Printing a webpage (url) directly from Navision

eromeineromein Member Posts: 589
Hi!

I need to print a url from Navision without loading the actual page in a browser. I prefer printing a webpage directly using the shell command.

Do you know how I should do this or what program (tool) I need to get to be able to do this?

Hope you can help!

What I’ve done so far:
    Searched half the web, so still the other half to check.
    Created a script that downloads the webpage to a (temp) file and then sends this file to the printer. But when saving the page the link to the images (2 pictures) gets lost. The url is referring to a local path instead of the internet path. Pictures aren’t printed.
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."

Comments

  • eromeineromein Member Posts: 589
    Anybody have experience with Microsoft HTML Object Library?

    Can I use this to load and print HTML? Maybe stream is to a Print Object?

    Enyone?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • ajhvdbajhvdb Member Posts: 672
    1.
    In the Addon Matriks there is a print button that auto print external files. Maybe urls work too.?

    2.
    An other option would be to use a main page with an iframe to your url. With javascript you can request the printerselection page.

    Maybe an example explains: Click in this page http://www.dvision.nl/home/iteminfo.asp?ID=905 on the small print icon and wait for the printer selection.

    3.
    And the vbscript sendkeys 'ctrl-p' in the ie browser does work.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    eromein wrote:
    Created a script that downloads the webpage to a (temp) file and then sends this file to the printer. But when saving the page the link to the images (2 pictures) gets lost. The url is referring to a local path instead of the internet path. Pictures aren’t printed.
    Maybe you can create a pdf-file from your script and print this pdf-file to the printer? This way, pictures are embedded in the file.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • eromeineromein Member Posts: 589
    Thanks Luc, I thought about that.

    The problem is that I need to print about 300 web pages every time I print a Navision invoice.

    Yes, I know… I know!! But still, this needs to be done… even if we all think this is insane.

    Loading the page, converting is to PDF, saving it and printing this PDF could be a bit of a slow process. I’m searching for that simple and quick solution. Something like, just printing web pages without having them to load, save to disk and convert them first.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    eromein wrote:
    [...] just printing web pages without having them to load, [...]
    Seems impossible to me ;-)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • eromeineromein Member Posts: 589
    What about “Everything is possible with Navision”?

    You know it’s true! Ask any salesperson!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • modricmodric Member Posts: 42
    Just a silly idea...

    Can your script save the page in .mht (Web page archive) format? Then everything is included in one single file, pics too...
    Modris Ivans
    MCP, Dynamics NAV - Application
  • ajhvdbajhvdb Member Posts: 672
    This works but you need to convert it to NAV
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate("http://www.google.com")
    
    While objIE.Busy 
    Wend 
    
    objIE.ExecWB 6,2 
    
    WScript.Sleep(3000)
    
    objIE.Quit
    Set objIEA = Nothing
    

    the sleep is important...
  • eromeineromein Member Posts: 589
    @ modric
    Can't save in .mht. But this could still be helpfull. I'll do some Googling.

    @ ajhvdb
    Without having tried myself or searched the net... How do you convert this: "objIE = CreateObject("InternetExplorer.Application")" to Navison? What automation control you need to do this?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • ajhvdbajhvdb Member Posts: 672
    'Microsoft Internet Controls'.InternetExplorer

    but you don't need to script it in NAV

    see: http://www.mibuso.com/forum/viewtopic.p ... estatement

    look for the post from "azwierzchowski" where he uses the .executestatement
  • FishermanFisherman Member Posts: 456
    If you know VB.Net or C#.Net, you can use the .Net framework, v2.0, to do this.

    You'd have to write a component (dll) that is exposed to COM. There are discussions on these boards on how to do this.

    Then, you'd have to call that dll from NAV, pass in the URL, and tell it what printer to print to.

    Here's a link to an example of how you could make this work on MSDN.

    http://msdn2.microsoft.com/en-us/librar ... eted(vs.80).aspx
  • eromeineromein Member Posts: 589
    Thank you all!

    The thing is that it’s actually not my problem to solve. The problem is in another application and it’s really not my job to fix this problem in Navision.

    Although this is a nice challenge, I decided to stop spending my time and my customer’s money on it.

    I fixed the problem by installing the Opera browser. Opera hasn’t any trouble opening 200 tabs. This way the customer only has to push the print button 200 times. :shock:

    The customer is fine with this solution. This seems to be cheaper then developing a solution. :lol:

    Again, thanks for the help!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
Sign In or Register to comment.