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

Free Support Forum - aspose.com

ASP.NET and Aspose.PDF


I tried searching for ‘web’ or ‘post variables’ or ‘asp.net’ with ‘aspose.pdf’ and didn’t find any solutions.

Here is my question: Can i take input from a web-page in ASP.NET, in the form of post variables, and use those to build a PDF as a streamable object, and then send that back to the client (or on to wherever I want the stream to go)? How would I import image files to my completed PDF? I assume reading from a web-server’s file system would be no different than reading from a standard client file system.

Does anyone have any samples of this working? We are wanting to turn a web-based form-submission into a PDF-generating form-submission.



Thank you for considering Aspose.

I believe following link can help you out regarding your requirements. It provides detailed information on how to convert html or aspx page into pdf.


If you have any other queries, please do let us know.


Hi Shahzad,

That isn’t exactly what I meant.

I have a form, for example:

Enter your name:
Enter your favorite ice cream:
Enter your address:
Enter a funny story:

Now, when submitted, I would like to catch the post variables that the user enters and then build a completely different PDF, with images, formatting, and the like, but put their information into the PDF in the spaces where they belong. This would all be done on a web-server, not on a client machine. It will require input to a webform (see above) by a user, which is then used to create the PDF.

Does that make sense? It seems like this should be doable, but I want to make sure.


Please help me understand this in a little bit more detail.

As I have understood, there could be two possibilities:

1. PageA posts the values to PageB; whereas PageB is designed in a way it should be viewed by the end user, but you fill the spaces on PageB with the values from the post. Then, you read this PageB using Aspose.Pdf and generate a pdf document. Now, you can either render this pdf to the browser, or send it to the user in some other way i.e. email attachment or whatever way you like.

2. Second approach would be, you input values on PageA, post it to the PageB; where the code written on PageB reads the posted values and then formats the pdf using the code approach of Aspose.Pdf (API). Where you can add text, images, and values of the post variables as well i.e compose complete pdf using code.

Now, it’s upto you, which approach can suit you the best. Please do let us know, and we’ll be pleased to help you accordingly.



2. Second approach would be, you input values on PageA, post it to the PageB; where the code written on PageB reads the posted values and then formats the pdf using the code approach of Aspose.Pdf (API). Where you can add text, images, and values of the post variables as well i.e compose complete pdf using code.

The second approach is basically the one we are looking to implement.

We would be wanting to use the API through .NET to build a complete PDF from scratch, using input from the webform. In C#.

It is very similar to the example here:


However, we are not using a connection to a database, we’re using variables from a web form in ASP.NET.


From the mentioned link, it seems like you just want to display the values from the posted variables on the generated pdf as text; if so, then you can read the posted variables using Request.Form object and then display them as a Text object in the Paragraph of a section. It is shown below in the sample:

Pdf pdf1 = new Pdf();

Section sec1 = pdf1.Sections.Add();

Text text1 = new Text(sec1,“some text or the value from the post variable”);



Here is the detail:

However, if you want to show the values as a form fields filled with posted values then you’ll have to add fields first using FormField class.
Here is the sample:

I hope this helps; if you have any confusion or question, please feel free to ask.


Yes, we’re just looking for text -> text for user input. Thanks for the links, we will review them…

We’re also looking to add images to the PDFs. These need to exist on the file system of the server(s), correct?

	HeaderFooter headerFooter = pdf.Sections[0].OddHeader;
	Image logoImage = (Image)headerFooter.Paragraphs[0];
logoImage.ImageInfo.File = path + “\Images\logo1.jpg”;

There is no other way to get images into the PDF?


You can add images to the Pdf file, when they are being generated. This feature is supported in Aspose.Pdf. For more related information please visit Working with Images.

You can also add image to an existing Pdf file using Aspose.Pdf.Kit. For more related information please visit http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/adhere-image.html. Along with this, you can also add image as watermark to the pages of existing Pdf file. For related information please visit http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/add-watermark.html

In case of any further query, please feel free to contact.

We are curious about another approach. An ‘automatic’ one, rather than one requiring us to build a completely different PDF from scratch.

Can we use the Aspose.PDF API to take an .aspx form that has all of its fields filled out by a user and submitted back to the server, to build a pdf automatically based on the markup of the page?

Similar to the first suggestion above: http://www.aspose.com/documentation/file-format-components/aspose.pdf-for-.net-and-java/converting-html-or-aspx-to-pdf-beta-version.html

But not limited to static html. Does the ‘automatic PDF generation’ work for html forms that have been filled out and submitted by a user back to the server?

for example (and this will not work):
MemoryStream ms = new MemoryStream(Page);

and then do whatever we need to do with the pdf object once it has bound the memory stream that the page and all of its components and user-inputs have turned into.

Also, what is the best solution for deploying a web project with a license file? We don’t want the license file to be downloaded, but it does need to be on the web-server(s) where Aspose.PDF would be able to access it.


First of all, we're not quite sure, right now, whether your required functionality can be achieved via Aspose.Pdf i.e. processing page contents along with the form field inputs as it is. We'll have to investigate it at our end; you'll be updated soon.

Secondly, you can embed the licence file in your project as a resource as well; you can find the possible types, a licence file can be used, on the following link:


Should you have any further issues, please do let us know.