Send pdf report from nav to api

MortenSteengaard
Member Posts: 144
Hi experts,
The task is to create a web service that creates a report as a pdf file and returns the file.
This must be done in NAV 2015.
I have made a web service that saves the wanted report as pdf in a blob field in the table "Temp Blob".
How do I return the blob field to the api?
Best regards,
Morten
The task is to create a web service that creates a report as a pdf file and returns the file.
This must be done in NAV 2015.
I have made a web service that saves the wanted report as pdf in a blob field in the table "Temp Blob".
How do I return the blob field to the api?
Best regards,
Morten
0
Answers
-
You could convert the blob to Base64-encoded string and send that back. In NAV 2015 there are no standard codeunit for it, so you'd need to use the "System.Convert" class from mscorlib.
In newer versions, the "Base64 Convert" codeunit implements "ToBase64" from InStream as such:procedure ToBase64(InStream: InStream; InsertLineBreaks: Boolean): Text var Convert: DotNet Convert; MemoryStream: DotNet MemoryStream; InputArray: DotNet Array; Base64FormattingOptions: DotNet Base64FormattingOptions; Base64String: Text; begin MemoryStream := MemoryStream.MemoryStream(); CopyStream(MemoryStream, InStream); InputArray := MemoryStream.ToArray(); if InsertLineBreaks then Base64String := Convert.ToBase64String(InputArray, Base64FormattingOptions.InsertLineBreaks) else Base64String := Convert.ToBase64String(InputArray); MemoryStream.Close(); exit(Base64String); end;
I have a feeling with small adjustments, this could work for NAV 2015 as well0 -
Hi ShaiHulud.
Thank you very much for your reply.
I have implemented something like this, but before it worked, we decided to have NAV createing the pdf file in Windows and then return the filename to the C# program. Then the C# program can get the pdf file directly from Windows.
Thank you for your time.
Best regards,
Morten0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions