CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    115

    Question How to write in PDF File ?

    Dear Sir,

    I do not know how to write data in PDF file. I want generate report in PDF Format but I do not
    know so How to possible help me.. I am using VS 2010.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to write in PDF File ?

    I don't know if there is a tool in VS to do this or not. I use an export filter to create pdf from my reports but I am not using the report tools from VS.

    Another option could be a pdf print driver, basically you would just send your report to the printer but choose the pdf driver and pass it a filename.

    Try a google search and see what you find.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: How to write in PDF File ?

    Google itextsharp.

    Here is a helper class for it.

    http://www.codeproject.com/KB/graphi...lperClass.aspx

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to write in PDF File ?

    Adobe will license the format to you, but you won't be able to sell it or tell anyone else about it.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Re: How to write in PDF File ?

    Hi,

    If you have MS Word installed you can create a report in Word using the Office Interop and save the report as a pdf file.

    Code:
    Imports Microsoft.Office.Interop
    Imports Microsoft.Office.Interop.Word.WdExportFormat
    
    
    Public Class Form1
    
        Dim myWord As Microsoft.Office.Interop.Word.Application
      
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Try
    
                myWord = New Word.Application
                myWord.Visible = True
                myWord.Documents.Add()
                myWord.Selection.TypeText(Text:=Trim("This is a pdf file"))
                myWord.Documents(1).Activate()
                myWord.ActiveDocument.ExportAsFixedFormat(OutputFileName:="C:\temp\pdffile.pdf", _
                                ExportFormat:=wdExportFormatPDF)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
    
            End Try
        End Sub
    End Class
    Curt

  6. #6
    Join Date
    Oct 2011
    Posts
    25

    Re: How to write in PDF File ?

    Your best bet is to use some kind of pdf print driver such as CutePDF... The down side of this is that the free ones often won't let you print silently/programmatically but require user's inputs. The paid ones cost a lot but will comes with sdk that allows you to print to pdf with just a few lines of codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured