Create or Write a pdf file ... RRS feed

  • Question

  • Is there any way to create and write a pdf file in without third party tools or dlls ???
    Monday, July 22, 2013 9:21 AM


All replies

  • Hi ,

    .net has no native support for PDF

    You have to use 3rd party libraries



    • Marked as answer by Wall.E Wednesday, July 24, 2013 6:18 AM
    Monday, July 22, 2013 2:04 PM
    • Edited by QianQ Monday, August 19, 2013 8:40 AM
    Monday, August 19, 2013 8:39 AM
  • Hi Wall.E,

    If you have MS Office then you can use its PIA assembly to achieve your task. You can find a list of included components here. What you need to include is a Word Interop that will work in .NET.

    Here is a sample code:

    Imports Microsoft.Office.Interop.Word
    ' ...
    ' Create new document
    Dim application = New Application()
    Dim document = application.Documents.Add()
    ' Add some content
    Dim paragraph As Paragraph = document.Content.Paragraphs.Add()
    Dim paragraphRange As Range = paragraph.Range
    paragraphRange.Text = "Hello World!"
    ' Export document as PDF.
    document.ExportAsFixedFormat(OutputFileName:="C:\Sample.pdf", ExportFormat:=WdExportFormat.wdExportFormatPDF)
    ' Cleanup
    If you do not have MS Office on your machine, or if the machine that is intendent to run your application does not have it then you will have to use some 3rd party. I can recommend you this Word processing component for .NET, it has a really easy interface.

    Here is how you can create and write PDF files in .NET:

    Imports GemBox.Document
    ' ...
    ' Create new document
    Dim document = New DocumentModel()
    ' Add some content
        New Section(document,
            New Paragraph(document, "Hello world!")))
    ' Export document as PDF.

    Wednesday, October 15, 2014 7:46 AM