asp.net-web-api


ASP.NET Web Api pdf with embedded images download


I'm using the below code to get the byte array that also contains images from a business class.
byte[] fileBytes = accountBusiness.DownloadInvoice(user.Id, invoiceId).ToArray();
Also, Please find below code that is used to generate pdf with embedded images
public HttpResponseMessage DownloadInvoice(string invoiceId)
{
try
{
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
ApplicationUser user = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(HttpContext.Current.User.Identity.GetUserId());
MyAccountBusiness accountBusiness = new MyAccountBusiness();
byte[] fileBytes = accountBusiness.Download(user.Id, invId).ToArray();
Stream stream = new MemoryStream(fileBytes);
response.Content = new StreamContent(stream, fileBytes.Length);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = accountBusiness.FileName + ".pdf";
return response;
}
catch (Exception ex)
{
logger.Error("Exception: " + ex.Message + "\n Inner Exception:" + ex.InnerException?.Message);
return null;
}
}
The underlying business class embeds an image like this:
sb.Append("<tr><td width='50%' align='left'><img src=" + Imgpath + ">
However, I'm getting the images are not being displayed in the pdf and also pdf is not being generated correctly. Please help

Related Links

Can default ASP.Net WebApi parameter binding work for query parameters containing dash(“-”)?
WebAPI Action Return :The requested resource does not support http method 'GET'
WebAPI request throws 404 error … on same request
Highly available Service Fabric WebApi hosted on Azure
ASP.Net MVC Web api - MapHttpRoute for multiple controllers won't take more than 1 parameter
Protecting webapi with IdentityServer and Autofac - can't get claims
WebAPI memory leak in BuildManager
ShouldSerialize* methods are not called in Web API documentation using SWAGGER
How to exclude table in Entity Framework. Or simply include table which I want to return
identity Server - Configuring CORS for bearer options
Web API with OWIN. 1 HttpConfiguration object vs 2 HttpConfiguration objects
Getting unexpected json result from a Web Api 2 call
Host Aurelia CLI app and WebApi service on same http server
Swagger page being redirected from https to http
Why is asp.net webAPI always returning text/html?
ASP.NET Web API: Array vs. List<T>

Categories

HOME
api
rdbms
twig
3d
zend-framework
mysql-workbench
components
owl-carousel
rendering
bitbucket-api
aws-cli
alsa
pearson-correlation
jquery-ui
fosrestbundle
syntaxnet
project
reactive-programming
mod-security
gkturnbasedmatch
atlassian-stash
powershell-v5.0
vuejs
shortest-path
delphi-xe5
oledb
selinux
drive
ksh
cgbitmapcontext
interpreter
shared
oculus
ceylon
openmdao
failover
volatile
dst
mustache
memory-address
contacts
jpad
loading
chef-solo
apriori
angular-http
show-hide
httrack
serde
spring-integration-sftp
mschart
facebook-pixel
tinymce-3
identification
check-mk
vibrate
async.js
myspace
uicolor
neon
jquery-jscrollpane
thread-sleep
aspen
doctype
ember-cli-rails
uncompress
ansi
public-html
grouping-sets
document-repository
delayed-execution
nodelist
iiop
imagefilter
raygun
insight.database
live555
functional-java
draw2d-js
vsx
koala
multitasking
ecslidingviewcontroller
http-patch
stacky
server-administration
cascadingdropdown
joomla3.1
fragmenttransaction
wcf-configuration
objectquery
appjs
socketserver
photolibrary
load-time
cruisecontrol.rb
application-verifier
duplex
cuda.net
alsb
int64
mathematical-typesetting

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App