Closed MustafaCali closed 9 years ago
I have this issue as well. When I render a web page instead of a pdf with the razor markup, the images show up.
Does anyone have any work-arounds?
I have also been trying to get this to work. If I include a static image (saved in the project), it will render in the PDF. However, when dynamically generating or requesting an image, it won't render in the PDF.
I'd appreciate any insights on how to achieve this or modify the code to achieve this.
I ended up not using MvcRazorToPdf and instead just using itextsharp directly to render the pdf
I am really sorry for not getting around to looking into this. I have been really busy with other commitments. I have only ever used a local path to the image as detailed in the docs. When I get a dev env setup I will try it.
No problem! Thanks a lot for your response, looking forward to the change :)
I think the only way around this that I know would be to generate the image on the server and supply the path in that format as in here:
@{
var imagePath = Server.MapPath("~/Content/Images");
}
<img src="@imagePath\avatar.jpg" alt="mug shot" />
https://github.com/andyhutch77/MvcRazorToPdf/blob/master/MvcRazorToPdfExample/Views/Pdf/Index.cshtml
That's what I did to work around it yesterday. I have no idea what kind of impact this will have on the server in a production environment though, so hopefully it'll hold through testing.
@iv00w Unfortunately as I am using a third party to render the pdf I am limited to their capabilities. However the functionality you have implemented sounds good, and could kind of glue together what is there. I will include it if you submit it. The only downside is that you will probably need to write some clean-up image code with a web worker or task.
Hey , I got webworker role just to invoke method of returning the PDF and providing it as byte[](or stream) to azure storage. That works flawlessy and really fast
Thanks. On Apr 2, 2015 2:27 PM, "RafPe" notifications@github.com wrote:
Hey , I got webworker role just to invoke method of returning the PDF and providing it as byte http://or%20stream to azure storage. That works flawlessy and really fast
— Reply to this email directly or view it on GitHub https://github.com/andyhutch77/MvcRazorToPdf/issues/27#issuecomment-89001337 .
This is link to my answer if this helps :) http://stackoverflow.com/questions/26121823/mvcrazortopdf-save-pdf-to-location-or-blob-and-then-download/29387409#29387409
@RafPe Nice one, up-voted.
Al tough it is closed already I dived into my code and found that you can do server side processing if you would use one of my Azure Upload methods mentioned in link before (stack.. link above) in conjunction with the following :
AzureStorage._uploadToAzureBlob( ControllerContext.GeneratePdf(objModel, "VIEW_NAME") ) ;
The GeneratePDF method just generates byte[] and this is already easy to be uploaded on Azure. And If I'm correct then using async Task on server would allow you to to this on server side without blocking client.
Hope this helps further :)
How can I write to the database byte [] image to pdf. I tried example:
var base64 = Convert.ToBase64String(item.Resim.ToArray()); var imgsrc = string.Format("data:image/jpeg;base64,{0}", base64);
Models from byte [] data on the type .cshtml img src = @imgsrc did not work assignment. How do I make.
But it did not work.