SAVEASPDF and DOWNLOAD Function
bmccarthy
Member Posts: 48
Can I use Report.SAVEASPDF to save the pdf file from the RTC client side??? If I say call
SAVEASPDF(C:\temp\test.pdf) from a menu item in a page then it is saved server side.
If I use DOWNLOAD to copy the file from the server to the client then I am forced to ask the user where to save it. The DOWNLOAD function wants me to specify a dialog caption etc to ask the user where you save it.
Is there a way to save a report to pdf client side from the RTC???
Also, as a side line can I force the SAVEASPDF running of the report to display the request form?
Cheers
SAVEASPDF(C:\temp\test.pdf) from a menu item in a page then it is saved server side.
If I use DOWNLOAD to copy the file from the server to the client then I am forced to ask the user where to save it. The DOWNLOAD function wants me to specify a dialog caption etc to ask the user where you save it.
Is there a way to save a report to pdf client side from the RTC???
Also, as a side line can I force the SAVEASPDF running of the report to display the request form?
Cheers
0
Comments
-
Saveaspdf stores it on service tier. To send something client, you can save using '\\computername\C$\temp', or you save it to a shared drive. Or use an automation and instantiate it at the client stream the file across.0
-
Is there a way to save a report to pdf client side from the RTC???
You can export a report to a pdf or Excel file when you preview the report in the RoleTailored Client.
This does not require any C/AL code as an end-user can now export a report to either format from the toolbar in the report preview window.“This posting is provided "AS IS" with no warranties, and confers no rights.”0 -
Unfortunately you cannot create streams across the servicetier boundry.Saveaspdf stores it on service tier. To send something client, you can save using '\\computername\C$\temp', or you save it to a shared drive. Or use an automation and instantiate it at the client stream the file across.
You have three options (which I can think of) for copying a file from the service tier to the client tier:
1. Save to a share as suggested (either on the client computer or on a common file share) - but this might cause problems of various kinds and is really not suggested
2. If you just need to show the file at the Client Tier, you can use FILE.DOWNLOAD and the user can select what to do - save/open etc.
3. If you need to attach the file to something and you don't want user interaction you again have two options (that I know of)
3.a. Read my blog post http://blogs.msdn.com/freddyk/archive/2008/11/04/transferring-data-to-from-com-automation-objects-and-webservices.aspx and make some code that works for you
3.b. Use FILE.DOWNLOAD with the "magic" folder name <TEMP> - which suppresses user interaction and saves the file to a temporary folder with a temporary name.
The following code:toFile := 'test.txt'; if FILE.DOWNLOAD('c:\test.txt', '', '<TEMP>', '', toFile) THEN begin Message(toFile); end;Saved my test.txt in the following local file:
C:\Users\freddyk\AppData\Local\Temp\Microsoft Dynamics NAV\9216\__TEMP__400f0b09d731435aad67af8c25e83378.txt
Which as you can see contains a GUID - so it will change.
You get this name (including full path) back in toFile (var parameter) - and you can use that to send to a Client Side COM component (maybe Outlook) to attach this file.
Only "small" problem is that the name is rather stupid (and I guess the name is used if you attach a file to outlook) - so if you need test.txt, you will have to create a small Client side COM object if you want to rename this on the Client tier before attaching to a mail.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
BTW. a function to do that could look like this:
/// <summary> /// Renames a temp file, created by FILE.DOWNLOAD in order to have a filename, that can be used for attaching to outlook etc. /// After this call filename.EndsWith(newfilename) is true. /// </summary> /// <param name="filename">Full path and filename of the temp file. This will contain the new file name (incl. path) after the call</param> /// <param name="newfilename">file name only of the new file</param> public void RenameTempFile(ref string filename, string newfilename) { // Just to ensure that newfilename doesn't contain ..\..\xxx if (newfilename.Contains(@"\")) return; string path = System.IO.Path.GetDirectoryName(filename) + @"\" + Guid.NewGuid().ToString() + @"\"; System.IO.Directory.CreateDirectory(path); System.IO.File.Move(filename, path + newfilename); filename = path + newfilename; }The client will remove temporary files and directories when you shut down.
If you want to remove the file on the client after usage you would need to create a function to do that - but unless the Client is running 24/7 or your temp files are large, that shouldn't be necessary.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Thanks you for such a detailed response. That should do the trick for us. =D>0
-
nabritta wrote:What is the fastest way to convert a book into a PDF file? I recently purchased a Sony Portable Reader System (PRS-505 RED). I have TONS of books I would like to scan to PDF and to OCR. Would it be quicker to scan these books one page at a time? Or would it be better to use a camera and take snapshots of each page (if so, what camera would you recommend)? In short: What's the quickest way to change a book into a PDF file?
where is the connection with Navision?
MatteoReno Sistemi Navision Developer0 -
Eto wrote:nabritta wrote:What is the fastest way to convert a book into a PDF file? I recently purchased a Sony Portable Reader System (PRS-505 RED). I have TONS of books I would like to scan to PDF and to OCR. Would it be quicker to scan these books one page at a time? Or would it be better to use a camera and take snapshots of each page (if so, what camera would you recommend)? In short: What's the quickest way to change a book into a PDF file?
where is the connection with Navision?
Matteo
HA HA! Way too funny...
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
