0

I have c# dynamic aspx page after new property add I create for record brochure

http://veneristurkey.com/admin/Brochure.aspx?Admin=PropertiesBrochureA4&id=36

but I want to this convert image file I am searching on internet but all with webbrowser and windows forms. I need on page load show not css type also image file. jpg, png or tiff how i can do this. i need to see sample code..

saving aspx page into an image 2

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • 2
    An aspx does what it needs to do on the server to return html. The rendered html is what you can see on that link. I'd recommend you search for "html to image" as opposed to "aspx to image". There are many results on google alone. –  Oct 09 '13 at 12:59
  • maybe my bad english :) i want only convert page to image file yes about 1 week i am looking for that on google many sample there but all with webbrowser windows forms. – Mahir Erbakan Oct 09 '13 at 13:04
  • http://veneristurkey.com/admin/Brochure.aspx?Admin=PropertiesBrochureA4&id=36 – Mahir Erbakan Oct 09 '13 at 13:06
  • @DeeMac's suggestion still stands, the easiest route would be to let the page render to Html and then convert it an image file. I don't know of any built in tools to render to an image directly. You may be able to create a page that calls the page you wish to be an image, get's the html and then converts it to an image and returns the image to a user or whatever you want to do with it. – ramsey_tm Oct 09 '13 at 13:07

4 Answers4

1

As I mentioned in my comment, your best bet is to opt for attempting to render HTML to an image.

Here is the link for a library that will allow your to render html to an image:

http://htmlrenderer.codeplex.com/

Here is code that does exactly what you're asking:

http://amoghnatu.wordpress.com/2013/05/13/converting-html-text-to-image-using-c/

Now all you have left is to get the html, since I'm assuming you don't want this to render to the browser prior to generating this image - you should look into grabbing the rendered html from the aspx page on the server prior to returning it, and then just return the image. To render a page:

https://stackoverflow.com/a/647866/1017882

Sorted.

Community
  • 1
  • 1
0

If you do not mind using a commandline tool you can have a look at wkhtmltopdf. The package include a wkhtmltoimage component that can be used to convert HTML to image, using

wkhtmltoimage [URL] [Image Path]

Codaxy also wrote a wkhtmltopdf c# wrapper available through the NuGet package manager. I'm not sure if the wkhtmltoimage component was included, but it should be easy enough to figure out how they wrap the wkhtml components.

Andre Lombaard
  • 6,985
  • 13
  • 55
  • 96
0

i fixed my problem with screenshot machine API they are my code..

public void resimyap() {

        var procad = WS.Satiliklars.Where(v => v.ForSaleID == int.Parse(Request.QueryString["id"])).FirstOrDefault();

        var imageBytes = GetBytesFromUrl("http://api.screenshotmachine.com/?key=xxxxxx&size=F&url=http://xxxxxxx.com/a4.aspx?id=" + procad.ForSaleID);
         string root = Server.MapPath("~/");

            // clean up the path
            if (!root.EndsWith(@"\"))
                root += @"\";

            // make a folder to store the images in
            string fileDirectory = root + @"\images\a4en\";

            // create the folder if it does not exist
            if (!System.IO.Directory.Exists(fileDirectory))
                System.IO.Directory.CreateDirectory(fileDirectory);

        WriteBytesToFile( fileDirectory + + procad.ForSaleID + ".png", imageBytes);
0

Yes i also try wkhtmltopdf c# wrapper but in pdf or image converting time my computer fan goin crayz. also i must upload server exe file and my hosting firm didnt support them