JumpyNET Posted December 16, 2010 Posted December 16, 2010 How can I open a pdf file for viewing in VS? I'm guessing I need a third party dll so any recommendations are welcome. I tried searching the forum for "pdf" but the word is too short :( Quote
joe_pool_is Posted January 4, 2011 Posted January 4, 2011 Are you looking for a PDF viewer for your application or a PDF viewer for the VS IDE? Google is often a better place to start a search like this. A basic Google search is HERE. Quote Avoid Sears Home Improvement
JumpyNET Posted January 4, 2011 Author Posted January 4, 2011 Are you looking for a PDF viewer for your application or a PDF viewer for the VS IDE? For my own application. Google is often a better place to start a search like this. I know there's tons of alternatives on the Internet, but I was hoping someone here would know which is the best. Quote
joe_pool_is Posted January 4, 2011 Posted January 4, 2011 Here's a nice, free one: http://sourceforge.net/projects/pdfsharp/ Quote Avoid Sears Home Improvement
joe_pool_is Posted January 4, 2011 Posted January 4, 2011 Alternately, you could use something from Adobe that you'd likely need to pay for. Microsoft details what to do about that: http://support.microsoft.com/kb/823241 Sorry for the round-about answer, but I did not understand what you wanted. It sounded like you wanted a way to view PDFs from within the VS IDE. Quote Avoid Sears Home Improvement
Gruff Posted May 11, 2011 Posted May 11, 2011 (edited) Hi Joe, Jumpy, Good news. The Free Adobe Reader Version 10x has reinstated the AcroPDF.dll ActiveX Use ChooseItems and under COM select the above. If it does not show path to: C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll Tons of good stuff in the control. LoadFile, Viewing, Printing, Etc... The only thing it does not do is create or edit PDF's directly. If you choose to show the toolbar it has a button that links to the web site that can create PDFs for you. (See Attached Picture) Edited May 11, 2011 by Gruff Quote
joe_pool_is Posted May 11, 2011 Posted May 11, 2011 Wow! Finally a thread that isn't SPAM. ...and helpful, too! :) Thanks. Quote Avoid Sears Home Improvement
JumpyNET Posted May 27, 2011 Author Posted May 27, 2011 Sample: Merging images and pdfs to a single pdf. Here's a nice, free one: http://sourceforge.net/projects/pdfsharp/ Thank you for the tip. This library works really well. I scrathed up a small sample code that merges any image files or existing pdf files to a single pdf. I hope it helps someone to get started with the PDF#-library. Public Sub CreatePDF(ByVal DesnationFilePath As String, _ ByVal SourceFiles As List(Of String), _ ByVal CropArea As Rectangle) 'Create a new PDF document Dim OutputDoc As PdfSharp.Pdf.PdfDocument = New PdfSharp.Pdf.PdfDocument OutputDoc.Info.Title = "Created with PDFsharp" 'Add one image or PDF at a time For PageNumber As Integer = 0 To SourceFiles.Count - 1 Dim SourceFilePath As String = SourceFiles(PageNumber) If LCase(IO.Path.GetExtension(SourceFilePath)) = ".pdf" Then AddPdf(OutputDoc, SourceFilePath, CropArea) Else 'Must be a picture AddPicture(OutputDoc, SourceFilePath, CropArea) End If Next 'Save OutputDoc.Save(DesnationFilePath) End Sub Private Sub AddPicture(ByRef OutputDoc As PdfSharp.Pdf.PdfDocument, ByVal ImgPath As String, ByVal CropArea As Rectangle) 'Create an empty page Dim page As PdfSharp.Pdf.PdfPage = OutputDoc.AddPage() 'Draw image Dim gfx As PdfSharp.Drawing.XGraphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page) Dim image As PdfSharp.Drawing.XImage If CropArea = Nothing Then Dim SourceImg As System.Drawing.Bitmap = Bitmap.FromFile(ImgPath) image = PdfSharp.Drawing.XImage.FromGdiPlusImage(SourceImg) Else Dim OriginalImage As Bitmap = Bitmap.FromFile(ImgPath) Dim CroppedImage As Image = OriginalImage.Clone(CropArea, OriginalImage.PixelFormat) image = PdfSharp.Drawing.XImage.FromGdiPlusImage(CroppedImage) End If page.Height = (image.PixelHeight * 0.0025) * 72.0 * 400.0 / image.VerticalResolution page.Width = (image.PixelWidth * 0.0025) * 72.0 * 400.0 / image.HorizontalResolution gfx.DrawImage(image, 0, 0) End Sub Private Sub AddPdf(ByRef OutputDoc As PdfSharp.Pdf.PdfDocument, ByVal PdfPath As String, ByVal CropArea As Rectangle) 'Add one page at a time Dim InputDoc As PdfSharp.Pdf.PdfDocument = PdfSharp.Pdf.IO.PdfReader.Open(PdfPath, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import) For i As Integer = 0 To InputDoc.PageCount - 1 OutputDoc.AddPage(InputDoc.Pages(i)) Next End Sub Quote
joe_pool_is Posted May 27, 2011 Posted May 27, 2011 JumpyNET, Looks like you did a great job. Thanks for sharing your findings. Quote Avoid Sears Home Improvement
lrvar Posted July 29, 2011 Posted July 29, 2011 Also the way I did it was adding a webbrowser and in the navigate option yust enter the path and filename.. webbrowser1.navigate = "C:\Users\Luis\Desktop\1.pdf" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.