I have an application that I put some drop box images like (https://www.dropbox.com/sh/u3xjkrah9fzm7ju/AAB_TLn83FQH456O79od0_moa/3286Z.png?dl=1)
and then I convert the page to a PDF using EVOPDF, but these images aren't rendered.
Problem solved.
I just set to download all resources before the render
Dim converter As New EvoPdf.HtmlToPdfConverter()
converter.DownloadAllResources = True
Related
I have a classic ASP question.
I need to show images on my webpage.
But because of the security reasons, I cannot simply put all of my images in the images folder in my website folder and I need to put them outside of my website folder.
For example, my website folder is located at:
C:\Inetpub\wwwroot\mysite\
But I need to put images (which I want to show on my web pages) at:
C:\images\
I am trying to use ADODB.stream object to pull the images using ASP vb codes as shown below:
<%
Response.ContentType = "image/png"
Set adoStream = Server.CreateObject("ADODB.Stream")
adoStream.Open
adoStream.Type = 1
FPath = "C:\images\1.png"
adoStream.LoadFromFile FPath
Response.BinaryWrite adoStream.Read
adoStream.Close
Set adoStream = Nothing
Response.End
%>
When I launch this webpage in internet explorer, the page shows a File Download window/message for downloading the image file "1.png" rather than displaying the image on the web page.
How can I fix the code to show the image on the web page rather than downloading the image file?
That code generates an image as the return type, so there is no HTML to display the image in, if you call this code directly say it's called image.asp then you would do something like this in another page that displays HTML.
<img src="image.asp" />
This will call your code and output the raw image binary as this is what <img> expects.
If you want to produce multiple images from the file system or database pass a querystring parameter such as ?id=yourimage and change the code to select different images.
I currently have a pdf that contains imagefields.
The issue however is that we want to be able to copy the images users input into the pdf.
Is there a way to alter the imagefield or add a button to the form that will copy the image so it will be available for pasting?
I see that I can put a button on the page and via script access the value for ImageField1.value so I can set it. But how can I read it?
you can access the image data by ".rawValue" attribute.
For example with a button and "click" event.
FormCalc: $.parent.sPic.rawValue = $.parent.dPic.rawValue
JavScript: xfa.resolveNode("sPic").rawValue = xfa.resolveNode("dPic").rawValue
with dPic being imagefield and sPic being image. This script will copy the image from imagefield into the image.
I have uploaded some images to Azure blob storage (sample) which need to be referenced from a ReportViewer.
Right now, i have an image control bound to the results of a stured procedure that lists a couple images based on some criteria. The SP is outputting the list of images correctly (the sample link being one of them) but all i get from the image control is an empty block wrapping an img with an empty src.
The behaviour is still present even if i hardwire the sample image link into the image control instead of binding it to the query results (Only difference being that i now get a proper image in the Visual Studio preview).
I have tried disabling all proxies, whitelisting my azure blob domain from the default proxy but have met no success.
Right now my app is running on my development machine.
Update:
Hardwiring the sample link into the image control somehow works now, but i am still facing the main issue: databinding the image control to a sp-produced value results in an empty src. Setting the image source to external and the image to [RValues] is still not working. (Setting a text control to [RValues] will output a valid absolute url pointing to the correct image so i doubt that's the problem)
Update 2: The image is showing as a red x on the PDF export
Your question has nothing to do with Windows Azure.
In order to reference external images into your reports you need to do a couple of things. First of all you have to enable external images in your report viewer control:
ReportViewer1.LocalReport.EnableExternalImages = True
Also you need to set the source as external. And last but not least make sure the reportviewer httpHandler is properly registered with the web.config.
For more information check the relevant question here and documentation here.
If you're using Azure Storage SDK to upload the blobs, you're probably not specifying content type. By default Azure Storage assigns application/octet-stream to them and serves them using this content type when you access the files via url. ReportViewer doesn't work well with external images served like that.
So when uploading the image, make sure to specify ContentType property of the blob.
var blockBlob = container.GetBlockBlobReference("your-image.jpg");
blockBlob.Properties.ContentType = "image/jpeg";
await blockBlob.UploadFromStreamAsync(stream);
public async Task SaveFile(byte[] bytes, string feature, string fileName, string tenant)
{
CloudBlobDirectory blobDirectory = GetImageStorage(tenant, feature);
CloudBlockBlob blockBlob = blobDirectory.GetBlockBlobReference(fileName);
blockBlob.Properties.ContentType = "image/jpeg";
using (var ms = new MemoryStream(bytes))
{
await blockBlob.UploadFromStreamAsync(ms);
}
}
I have a large pdf with 50-60 pages. I converted the pdf into web page using ConvertApi web2pdf online api and then added some input controls on the pages wherever required.
When user filled all the required input and submit I rendered the entire page and show the preview to the user to check whether user has filled the inputs correctly. After that when User click submit then it stores into database and generate the pdf of the same.
I used convertApi.dll and wrote the following code to generate pdf.
MemoryStream outStream = new MemoryStream();
Web2Pdf convertApi;
convertApi = new Web2Pdf();
convertApi.SetPageSize("A4");
convertApi.SetPageWidth("100%");
convertApi.ConvertHtml(HtmlText, outStream);
My problem is when we generate the pdf it does not take all the styles used in the page. And pdf look different. I need to provide the very similar pdf which client provided. Can any one suggest me to do it in better way.
Thanks.
I have an ASP.NET web app. What I am attempting should be simple: after an image is displayed, I have a Rotate button which should allow the user to rotate the image 90 degrees. Here is the button click code...
Dim i As Image
i = Image.FromFile("C:\Inetpub\wwwroot\myWebApp\MyImage.jpg")
'rotate the picture by 90 degrees
i.RotateFlip(RotateFlipType.Rotate90FlipNone)
're-save the picture as a Jpeg
i.Save("C:\Inetpub\wwwroot\myWebApp\MyImage.jpg",System.Drawing.Imaging.ImageFormat.Jpeg)
'tidy up after we've finished
i.Dispose()
The image and button used here are non-remarkable. When I created a sample app with just 1 page this works perfectly. However, when I put in into my main app, even if its in a new page, all by itself with nothing else, not even a masterpage, it does, in fact rotate the image and write it back to the file system, but it doesn't show the rotated file. It shows the image as it was. UNTIL I hit F5, then, no matter how many times I hit the button, it works perfectly. I have tried eveything i can think of to clear the cashe to no avail.
Are you re-requesting the image using an update panel or some other mechanism? You will be able to force a refresh by putting something like a timestamp or similar GET parameter on the IMG src, or in the ASP:Image source.
Instead of saving the image back to the web root you can keep the original image as is and just stream the rotated image to the client.
<img src="RotateImage.aspx?Image=MyImage.jpg&Rotate=90" />
and then in your RoateImage.aspx do the same load/rotate work and:
i.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.ContentType = "image/jpeg"
The image is served from the cache, that is why it is not shown updated. To show the newer version of the same image. You may attach a query string to the path of the image. For example,
<img src='/images/image.jpg?<%= DateTime.Now.Ticks %>' />