Options

open pdf from web service

BeliasBelias Member Posts: 2,998
edited 2010-10-12 in NAV Three Tier
hi everyone, i'm moving my first steps in creating pages and codeunit web services, and i've done this little function, that creates the pdf of the purchase report.

fntprint(pTBPurchHead : Record "Purchase Header")
TXTFileName := 'C:\pdftest\';
TXTFileName += 'test.pdf';
REPORT.SAVEASPDF(402,TXTFileName,pTBPurchHead);

HYPERLINK(TXTFileName);
as you can see, it's really raw code, but it works like a charm in my little winform...the problem is that the hyperlink function does not work...why?
thanks in advance
P.S.: the HYPERLINK obviously work when called from an action in the page. it's just the webservice that doesn't work
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Answers

  • Options
    kinekine Member Posts: 12,562
    SAVEASPDF - saving on the service tier server
    HYPELINK - running on the client...

    If you have service tier on different server than client, you cannot do that... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    BeliasBelias Member Posts: 2,998
    kine wrote:
    SAVEASPDF - saving on the service tier server
    HYPELINK - running on the client...

    If you have service tier on different server than client, you cannot do that... ;-)
    you're right and i know it...i should have said that i'm testing on my own pc, which is service, server and client...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    SavatageSavatage Member Posts: 7,142
    Why do you have both listed as TXTFile Name?

    TXTFileName := 'C:\pdftest\';
    TXTFileName += 'test.pdf';

    Shouldn't the first one be TXTFilePath? Or is that where the += comes in?
  • Options
    BeliasBelias Member Posts: 2,998
    Savatage wrote:
    Why do you have both listed as TXTFile Name?

    TXTFileName := 'C:\pdftest\';
    TXTFileName += 'test.pdf';

    Shouldn't the first one be TXTFilePath? Or is that where the += comes in?
    don't care about it...it's just some copy/pasted code from a blog and then modified for my cruel intentions :mrgreen: ...well, reviewing the code...it has nothing to do with the original code, i copied just the method of extending the page webservice through codeunit...
    as i said, it's just raw code to work a bit with web services...do you like it more if i write this? :wink:
    TXTFileName := 'C:\pdftest\test.pdf';
    REPORT.SAVEASPDF(402,TXTFileName,pTBPurchHead);
    
    HYPERLINK(TXTFileName);
    
    here's the blog if you want to take a look to a nice trick, but it's Off Topic...
    http://blogs.msdn.com/b/freddyk/archive/2009/11/17/extending-page-web-services-and-creating-a-sales-order-again.aspx
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    BeliasBelias Member Posts: 2,998
    well...i solved it with these lines of C# code...
    String filename = String.Format("{0:d}",service.Fntprint(mypurchorder.Key));  
    System.Diagnostics.Process.Start(filename);
    
    fntprint is a nav function that runs the report as pdf and returns a text variable with the name of the created file
    "{0:d}" is..........i don't know, i just copied it from somewhere... :whistle: :whistle:
    P.S.: don't take this solution as a good example, because i don't know C#...there are probably better ways to solve this, but it works for my testing purposes
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.