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

WebAPI2 - Cross Origin scripting issues
Can not get claims from bearer token in MVC front end app
401 response when using Xamarin and IdentityModel to WebAPI secured by IdentityServer 3
eve REST API and how to post a role list for role based authentication
Async Web API and Ajax
How to push content from server side to client side using SignalR?
OData function routing conventions
Timeout on multiple POSTs to web api hosted in mono xsp
Why Owin Not get fired while upgrade .Net 4 to .Net 4.5
WebApi Helppage Description Column
Deploying Azure WebApi on multi parameter not working as it was working fine locally
ASP.NET Web API Data Confusion
Create an ActionResult to serve request that can have the Id value come in either in body or query string
How to use Token and Identity Authorization on resource?
Having trouble accessing Web API hosted on IIS 6.0
Get bearer access token in api logging

Categories

HOME
adal
design-patterns
paraview
redux-form
sublimetext
square
x264
mapbox
nuget-package
google-admin-sdk
webix
joomla3.0
fosrestbundle
github-enterprise
activecollab
google-form
libc
code-generation
enterprise-architect
atlassian
libusb
scsi
atlassian-stash
chargify
xmonad
dpdk
roslyn
event-store
resourcebundle
xcode-ui-testing
motion-detection
twiml
postback
playstation-portable
hibernate-search
indy10
projects-and-solutions
demo
mongoose-schema
urlsession
c9.io
signals-slots
odoo-website
portforwarding
apollostack
apache-spark-dataset
textsum
robomongo
chai-as-promised
geotiff
tinymce-3
manova
aquamacs
colorbar
css-transforms
payload
gameplay-kit
pure-css
grails-plugin
ziparchive
vulcanize
i386
hclust
simevents
angular-ui-typeahead
tracker-enabled-dbcontext
boost-serialization
grass
opl
sciruby
sony-lifelog-api
mod-proxy
apache-commons-daemon
uvc
jquery-forms-plugin
zend-currency
rrule
cakephp-2.7
adehabitathr
execve
android-cookiemanager
sonarqube-5.0
structuremap3
entry-point
angular-carousel
ora-00904
xml-dsig
functional-java
authlogic
extjs2
cfcache
accesscontrolexception
mt4j
model-driven-development
server-administration
dopostback
panda3d
uimanageddocument
correlated-subquery
hibernateexception
google-maps-mobile
node-redis
http-daemon
globals
scrollbars
request-headers
lobo-cobra
fail-fast-fail-early
fault-tolerance

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