We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems converting aspx to pdf and sending to browser


I cannot seem to find any documentation which instructs how to do the above operation!

I tried the below code but it just sends the raw byte code to the browser.

Dim _url As String = "http://www.testing.com"
_pdf As Pdf = New Pdf()
Dim _wb As WebClient = New WebClient
Dim myBuffer() As Byte = _wb.DownloadData(_url)
Dim _str As MemoryStream = New MemoryStream(myBuffer)
_pdf.Save("test1.pdf", SaveType.OpenInBrowser, Response)

I'd appreciate any help.



Hello Saleek,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I have tested the issue using the code snippet that you have shared and in my case the Pdf is being generated. In fact the resultant Pdf is not as exact as input Aspx page, as currently this feature is in Beta version. Our development team is working hard over this issue, but I am afraid we cannot fully support this feature in short time. Sorry for your inconvenience.

For related information on how to convert Aspx file into Pdf please visit Converting Html or Aspx to PDF (Beta version)

Make sure you are using the latest version of Aspose.Pdf. I have generated the Pdf from http://www.msn.com and is in attachment, please take a look.

Ahhh, i did not realise that its not fully supported as yet.

In that case, can you provide me with some sample code showing how to create a table and insert an image into the cell?

Then output to the browser.

BTW the version I have is: 3.7.00

Many thanks.

Also, is it possible to insert an image from a url into a table cell?


Hello Saleek,

Please try the following code snippet. We would recommend you to use the latest version of Aspose.Pdf


Dim pdf As Pdf = New Pdf()

'Create a section in the Pdf instance
Dim sec1 As Aspose.Pdf.Section = pdf.Sections.Add()

'Create a Table object
Dim pdfCurrentTable As Aspose.Pdf.Table = New Aspose.Pdf.Table(sec1)

Dim row0 As Aspose.Pdf.Row
row0 = pdfCurrentTable.Rows.Add()

Dim cell0, cell1 As Aspose.Pdf.Cell
cell0 = row0.Cells.Add()

'Create an image object
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
'Set the path of image file
image1.ImageInfo.File = "c:\Temp\warning.png"
'Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = ImageFileType.Png


'Set the Default Border style
pdfCurrentTable.DefaultCellBorder = New BorderInfo(BorderSide.All, 0.1F)

cell1 = row0.Cells.Add()

Dim s2 As String = "Second Cell"
Dim t2 As Text = New Text(s2)

pdf.Save("Test.pdf", Aspose.Pdf.SaveType.OpenInBrowser, Response)

That works great!

Thank you.


I have one more question.....

Is it possible to manipulate the size of the image container (not the image itself).

The problem i am facing is this...

I have high resolution images that I want to display in pdfs.

Currently, I resize them using GDI+ in asp.net.

This however reduces the quality substantially, which is not acceptable in my case.

So, I was wondering if i could avoid resizing the image and instead change the size of the container?? Or if there is another way to do this I would love to hear.

Please advise.



Deat Saleek,

We recommend you use floating box as the image container. Here is the sample code. Please try it. Thanks.

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
//Create a floating box to contain the image
Aspose.Pdf.FloatingBox imagebox = new FloatingBox();
//Set the width/height of the floating box(container)
//The same as the image’s width and height
imagebox.BoxWidth = 200;
imagebox.BoxHeight = 300;
//Positioning the box
imagebox.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page;
imagebox.Left = 100;
imagebox.BoxVerticalPositioning = BoxVerticalPositioningType.Page;
imagebox.Top = 250;
//Add the image into the box
Aspose.Pdf.Image img = new Image();
img.ImageInfo.File = “C:/images/1.jpg”;
img.ImageInfo.ImageFileType = ImageFileType.Jpeg;
Aspose.Pdf.Section sec = pdf.Sections.Add();

Best regards.


Thanks for your response, but I'm afraid this did not work, the BoxHeight value had no affect on the image height even though the BoxWidth did.

Even If I change the BoxHeight to 10 it does not take effect.


Hello Saleek,

I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFNET-6134. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.