VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,416 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,576 people online right now. Registration is fast and FREE... Join Now!




Use Pdf file from My.Resources

 

Use Pdf file from My.Resources

mishipal

1 Jul, 2009 - 11:37 PM
Post #1

D.I.C Head
**

Joined: 4 May, 2009
Posts: 77



Thanked: 1 times
My Contributions
I have a PDF which i want to open when user clicks a button

I know how to open a file from drive location but how to open PDF from my.resources so that it can be deployed with the application

User is offlineProfile CardPM
+Quote Post


firebolt

RE: Use Pdf File From My.Resources

2 Jul, 2009 - 03:18 AM
Post #2

D.I.C Lover
Group Icon

Joined: 20 Feb, 2009
Posts: 5,463



Thanked: 75 times
Dream Kudos: 1675
My Contributions
Can we see the code that you are working on please? smile.gif
User is offlineProfile CardPM
+Quote Post

mishipal

RE: Use Pdf File From My.Resources

2 Jul, 2009 - 03:25 AM
Post #3

D.I.C Head
**

Joined: 4 May, 2009
Posts: 77



Thanked: 1 times
My Contributions
pdfviewer.src = my.resources.MyPdfFile

I know this does not work as PDF file is not added as resource


User is offlineProfile CardPM
+Quote Post

Luc001

RE: Use Pdf File From My.Resources

2 Jul, 2009 - 05:26 AM
Post #4

D.I.C Head
**

Joined: 4 May, 2009
Posts: 147



Thanked: 12 times
My Contributions
Hi,

If you use Acrobat, you'll have to save the resource to a temporary file.

CODE
Imports System.IO
Imports System.Diagnostics

Public Class Form1
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim pdf As Byte() = My.Resources.SamplePdf
    Using tmp As New FileStream("test.pdf", FileMode.Create)
      tmp.Write(pdf, 0, pdf.Length)
    End Using
    Process.Start("test.pdf")
  End Sub
End Class

User is offlineProfile CardPM
+Quote Post

mishipal

RE: Use Pdf File From My.Resources

2 Jul, 2009 - 11:27 PM
Post #5

D.I.C Head
**

Joined: 4 May, 2009
Posts: 77



Thanked: 1 times
My Contributions
Thanks everyone for your replies and all help....

I also figured out how to do it....

Add the PDF to solution and change its Build Action Property to Content, then we can use simple code
PdfViewer.src = Application.StartupPath.ToString + "\OctroiLetter.pdf"

In this way the PDF is deployed along with the application.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:30PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month