Printing Existing PDF file

wdheemwdheem Member Posts: 7
edited 2015-09-18 in NAV Three Tier
Hello Experts! :)

The below is the code to print an existing PDF...
shellProcess:=shellProcess.Process();
shellProcess.StartInfo.FileName:='D:\Test\Test.pdf';
shellProcess.StartInfo.CreateNoWindow:= TRUE;
shellProcess.StartInfo.WindowStyle:= windowStyles.Hidden;
shellProcess.StartInfo.Verb:= 'print';
shellProcess.Start();

An Below Variables are used
[b]shellProcess	[/b]DotNet	System.Diagnostics.Process.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	
[b]windowStyles	[/b]DotNet	System.Diagnostics.ProcessWindowStyle.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'	

I embedded this code in the page action (to print). However, this code does not work. Meaning, that PDF reader(adobe) does not open and the document does not print. I would appreciate if anyone could help on this issue.

Comments

  • geordiegeordie Member Posts: 655
    In RTC you can simply use:
    HYPERLINK ('C:\temp\test.pdf')
    
  • rocatisrocatis Member Posts: 163
    Your DotNet variables do not seem to be declared as Running On Client. This means your code will look for the file D:\Test\Test.pdf on the server.

    My guess is the file is located on the client.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • wdheemwdheem Member Posts: 7
    Thankyou!! rocatis! It works! :smile:
  • mdPartnerNLmdPartnerNL Member Posts: 802
    windowStyles.Hidden isn't available at my pc. any idea?
  • wdheemwdheem Member Posts: 7
    edited 2015-10-23
    Dear mdPartnerNL!

    To get widowsStyles.Hidden property first you have to declare a Dotnet variable that refers [System.Diagnostics.ProcessWindowStyle.... The following are the steps:-
    1. Create a DotNet Variable e.g. windowStyles
    2. Click the Assist Edit button in sub type
    3. Find System from the .net Assembely
    4. Select System.Diagnostics.ProcessWindowStyle

    If you mean System.Diagnostics.ProcessWindowStyle is not available in your PC, I guess it could be a problem in your .net Framework.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    wdheem wrote: »
    Dear mdPartnerNL!

    To get widowsStyles.Hidden property first you have to declare a Dotnet variable that refers [System.Diagnostics.ProcessWindowStyle.... The following are the steps:-
    1. Create a DotNet Variable e.g. windowStyles
    2. Click the Assist Edit button in sub type
    3. Find System from the .net Assembely
    4. Select System.Diagnostics.ProcessWindowStyle

    If you mean System.Diagnostics.ProcessWindowStyle is not available in your PC, I guess it could be a problem in your .net Framework.

    That's what I did, I don't have the .Hidden:
    'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.ProcessWindowStyle

    g1fn5ep1tvoq.png

    IM using 2009, maybe that is the clue?



  • JDVyskaJDVyska Member Posts: 179
    In the center column, click Properties and eyeball that list? You're only looking at Methods in the above screenshot.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
Sign In or Register to comment.