ASP.NET without using Visual Studio
Contents
[
Hide
]
Aspose.PDF for .NET can be used to develop ASP.NET pages or applications without using Visual Studio. In this example, we’ll write HTML and the C# or VB.NET code in a single .aspx file; this is commonly known as Instant ASP.NET.
Implementation details
Create a sample web application and copy Aspose.PDF.dll into a directory named “Bin” in your website directory ( if bin folder does not exist, create one ). Then create your .aspx page and copy the following code into it.
This example shows how to use Aspose.PDF for .NET with inline code in an ASP.NET page in order to create a simple PDF document with some sample text inside it.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
<%@ Page Language ="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Aspose.PDF" %>
<html>
<head>
<title> using Aspose.PDF for .NET with Inline ASP.NET</title>
</head>
<body>
<h3>creation of simple PDF document while using Aspose.PDF for .NET with Inline ASP.NET</h3>
<%
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Set license
Aspose.Pdf.License lic = new Aspose.Pdf.License();
lic.SetLicense("Aspose.Total.lic");
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Add page
Aspose.Pdf.Page page = document.Pages.Add();
// Add text to new page
page.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World!"));
// Save PDF document
document.Save(dataDir + "HelloWorld_out.pdf");
}
%>
</body>
</html>