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

Why is Serilog(.Extras.)Web's ApplicationLifecycleModule.Init() called twice?
OData query option $count in $expand not working
Adding External logins with Facebook and Google to ASP WEB API
ASP.NET Web API 2 Bearer Token Authentication and Resources Authorization
How do you enable cross-origin requests (CORS) in ASP.NET 5 & MVC 6?
Strange Configuration Error in web.config
Enterprise Architecture: MVC Identity via WebAPI
How do I implement an OAuth2 Authorization_Code Flow in Web Api using OWIN Middleware?
Can I have non Rest styled Methods in web api?
System.web.http.dll deleted accidently
how to pass the result model object out of System.Web.Http.ModelBinding.IModelBinder. BindModel?
Multiple implementations of IExceptionHandler
CORS method parameter does not seem to work?
Set a ASP.NET WEB.API model property to be read-only for consumers of the API?
OData Client Request Pipeline not working in Odata V4
Web API routing and a Web API Help Page: how to avoid repeated entries

Categories

HOME
google-app-engine
phpword
localization
eslint
redux-form
pda
datastore
angular-formly
3d
mysql-workbench
rendering
replace
pdfbox
nested-if
computer-science
github-enterprise
supervisor
frequency-distribution
pyramid
backpack-for-laravel
systemtime
jboss6.x
onload
shared
asymptotic-complexity
python-2.6
paragraph
android-gridview
carriage-return
kill
numberpicker
vmware-fusion
dcmtk
android-softkeyboard
dbnull
congestion-control
lampp
dotnet-httpclient
yii2-api
openblas
zenhub
aquamacs
qtranslate
context-sensitive-grammar
avx
reshape
mach-o
trigger.io
google-photos
jtree
structuremap4
renaming
builtins
jtwig
hadoop-partitioning
libav
decimalformat
themoviedb-api
jdi
forwarding
ess
opserver
jdk1.7
skspritenode
omnifaces
google-refine
boost-program-options
primitive-types
big-ip
punycode
insight.database
grails-plugin-rabbitmq
tinyxml
draw2d-js
conditionaltagsupport
gd-graph
ie8-compatibility-mode
hidapi
wp7test
bjyauthorize
device-width
xcode3.2
multiplexing
ilasm
virtualpathprovider
twitterizer
commerceserver2007
objective-j
ie-compatibility-mode
non-clustered-index
office-2007
folding
scrubyt
java1.4
change-management
online-storage

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