top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to create PDF document using ASP.Net?

+2 votes
884 views

How do I properly align pdf...?? I have different tables for different run..

posted Apr 21, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes
 
Best answer

The .NET framework does not contain any native way to work with PDF files. So, if you want to generate or work with PDF files as part of your ASP.NET web application, you will have to rely on one of the many third party components that are available. One of the free components is iTextSharp, which is a port of a well known Java utility, iText.

Check the following tutorial for more detail http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp

For your second query i.e. Properly align pdf, can you put more details.

answer Apr 22, 2014 by Salil Agrawal
0 votes
 Private Sub prn_PrintPage(ByVal sender As System.Object, _
                              ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        e.Graphics.DrawString("Hello from VB.NET", New Font("Arial", 60, FontStyle.Regular), _
                              Brushes.Blue, 100, 100)

    End Sub

    Private Sub PrintTest()
        Dim DC As Object = CreateObject("Neevia.docCreator")

        DC.setParameter("DocumentOutputFormat", "PDF")
        DC.setParameter("DocumentOutputName", "testVBNET")
        DC.setParameter("DocumentOutputFolder", "d:\")

        Dim prn As New System.Drawing.Printing.PrintDocument
        AddHandler prn.PrintPage, AddressOf prn_PrintPage
        prn.PrinterSettings.PrinterName = "Neevia docCreator"

        Dim tempFile As String = DC.getParameter("TempDir") + DC.GUID + ".ps"

        prn.PrinterSettings.PrintFileName = tempFile
        prn.PrinterSettings.PrintToFile = True

        prn.Print()

        DC.setInputDocument(tempFile)

        Dim RVal As Integer = DC.create()
        DC.fileDelete(tempFile)

        prn = Nothing
        DC = Nothing

        If (RVal <> 0) Then
            MsgBox("Error while creating document!!!")
        Else
            MsgBox("Done !!!")
        End If
    End Sub
answer Nov 28, 2014 by Manikandan J
Similar Questions
0 votes

How to get all values along with control Id using Jquery in ASP.NET?

+2 votes

If somke error occurs i want the system to redirect to some other page and not show he error message.

<customErrors
   mode="RemoteOnly" 
   defaultRedirect="~/Error.aspx" />

This is not working.

+3 votes

I want to save specific html portion into pdf using asp.net into MS SQL SERVER 2008. I know it will done will itextsharp.dll library file from .NET conversion but tell me through example.

...