Aspose.Pdf in ASP.NET C#

Hi,


I want to use Aspose for web site which is created in ASP.NET.
I found HTML5 example but it is too complicated. Bootstrap, Jquery, Javascript and so on…
Is not there any way to use directly API in ASP.NET C#?

I mean, I should load pdf file to webpage for viewing with many lines of code.
Is there any way for that purpose?

Thanks.

Hi Mehmet,

Thanks for your inquriy. If you want to send PDF to browser then please check following code snippet. It will help you to accomplish the task.

// Load PDF file
Document doc = new Document("input.pdf");

using (MemoryStream stream = new MemoryStream())
{
    // Save PDF file to Stream
    doc.Save(stream);

    Response.Clear();

    // Specify the document type
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "inline; filename=input.pdf");

    // Write the PDF content to the response
    byte[] bytes = stream.ToArray(); // Use ToArray() instead of GetBuffer() to avoid extra padding
    Response.BinaryWrite(bytes);

    // Flush and close the response
    Response.Flush();
    Response.Close();
    Response.End();
}

Please feel free to contact us for any further assistance.

Best Regards,