Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

VS 2010 iTextSharp Open PDF from Desktop

$
0
0
Hello to all again,

I use this code for creating PDF (I use iTextSharp)

Code:

          Dim WorkingFolder = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "NameOfFile")
            If Not System.IO.Directory.Exists(WorkingFolder) Then
                System.IO.Directory.CreateDirectory(WorkingFolder)
            End If
            Dim WorkingFile = Path.Combine(WorkingFolder, "NameOfFile.pdf")
            Dim fs As New FileStream(WorkingFile, FileMode.Create, FileAccess.Write, FileShare.None)
            Dim document As New Document(PageSize.A4, 27, 27, 30, 30)
            Dim writer As PdfWriter = PdfWriter.GetInstance(document, fs)

            'Meta data
            document.AddAuthor("")
            document.AddCreator("")
            document.AddKeywords("")
            document.AddSubject("NameOfFile")
            document.AddTitle("")

            document.Open()

            ... some text and their position (X,Y)


            ' Close document
            document.Close()
            ' Close weirwe
            writer.Close()
            ' Always close handled document
            fs.Close()

            'Open PDF from location that is saved
            System.Diagnostics.Process.Start("C:\Users\NAME-of-PC\Desktop\NameOfFile\NameOfFile.pdf")

Now this will work only in my computer, because only my computer is named "NAME-of-PC", ... what shoud I do, that will open PDF in all computers, in the beginning I have create, that PDF is always created in Desktop (My.Computer.FileSystem.SpecialDirectories.Desktop), now how to open it, other computer, will not find path C:/Users/Name-of-PC....

Thanks for help...

Viewing all articles
Browse latest Browse all 27353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>