ASP.NET MVC Image Viewer
How to open, view, edit new PDF created from multiple images programmatically in web browser in C# ASP.NET web apps.
How to read, view a new PDF generated from list of images online using C# in ASP.NET MVC web application on Azure
Open, read, view and markup a new PDF file programmatically in ASP.NET using C# is very simple. EdgePDF provides a simple C# demo code to accomplish the job.
- Create a new PDF from list of image files
- Read, view PDF using EdgePDF in web browser
- Easy to enable conversion feature in ASP.NET Forms, MVC web applications using C#
How to view, create PDF from images programmatically in asp.net using C#
Preparation
To run the following tutorial successfully, we need the following setup ready.
- For ASP.NET Core web app: Setup EdgePDF
- For ASP.NET Core MVC web app: Setup EdgePDF
- For ASP.NET (.net framework): Setup EdgePDF on IIS
- Several demo PDF files in folder C:\temp\
How to read, view PDF from multiple image files in web browser in ASP.NET C#?
The following steps and C# source code will learn how to open, view a new PDF from list of existing image files in web browser using C# ASP.NET web application.
After you have completed the following guide, you can open, view, comment a PDF file created from 3 image files online through url (a sample url
http://localhost:56643/?yourtarget1=pdf-image-0.jpg&yourtarget2=pdf-image-1.jpg&yourtarget3=pdf-image-2.jpg)
- For ASP.NET Core web app, open file UserCommandProcessMiddleware.cs from /DemoProjects/EdgePDF for ASP.NET Core/
- For ASP.NET (.net framework) project, open file UserCommandProcessHandler.ashx from {EdgePDF demo project}/RasterEdge_Resource_Files/
- Go to method FileProcess()
- Get 3 images key from url parameters, "yourtarget1", "yourtarget2", "yourtarget3"
- Get 3 images' Bitmap objects, added to a Bitmap list.
- Create a new PDFDocument object with 3 Bitmap objects loaded
- Call method REProcessControl.PageLoadFile() to load, view new created PDF from 3 image files in web browser
public override PDFWebDocument FileProcess()
{
HttpRequest request = this.Context.Request;
if (!String.IsNullOrEmpty(request.QueryString["yourtarget1"]) && !String.IsNullOrEmpty(request.QueryString["yourtarget2"]) && !String.IsNullOrEmpty(request.QueryString["yourtarget3"]))
{
String filePath1 = @"C:\\temp\" + request.QueryString["yourtarget1"];
String filePath2 = @"C:\\temp\" + request.QueryString["yourtarget2"];
String filePath3 = @"C:\\temp\" + request.QueryString["yourtarget3"];
Bitmap image1 = new Bitmap(filePath1);
Bitmap image2 = new Bitmap(filePath2);
Bitmap image3 = new Bitmap(filePath3);
List<Bitmap> images = new List<Bitmap>();
images.Add(image1);
images.Add(image2);
images.Add(image3);
PDFDocument combinedImagesPdf = new PDFDocument(images.ToArray());
String fileName = "PDF from 3 images";
return REProcessControl.PageLoadFile(request, this.Manager, combinedImagesPdf, fileName);
}
else
{
Logger.Log(">>> Unknown load file mode. Load default file defined in Web.config.", LogType.DEBUG);
// load default file. defined in Web.config
return REProcessControl.PageLoadFile(request, this.Manager, "", LoadType.Server);
}
}
After complete the ASP.NET images viewer web application, you could easily publish and deploy the ASP.NET Core web app to Microsoft Azure web service.
View details at
How to deploy ASP.NET image viewer web application to Azure?