Click here to Skip to main content
16,004,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear all,

I am building a windows forms application where people can view PDF (preview).
I am successfully able to locate a file on the local computer and preview this in the PDF viewer control.

What I want to do is:

My file is located on an internet location which you can point to as:
http://localhost:2323/Documents/Document.pdf

I am aware that I can download the file and then preview it to the viewer control. I do not want to do this due to random files and number of files to be downloaded on local computer and for privacy reasons.

Can anyone suggest an idea that if I can reference the document to the PDF viewer control as the above path?

Also my other other question is:

This PDF viewer control works only if I put x86 in the build options for this windows forms application. I want it for any CPU.

Please help.

Thanks.

Regards,
Nayan
Posted

Update AUG 2024:

pdfsharp.com has been shifted to pdfsharp.net.

And as per official FAQ, this is not possible:

Quote:
PDFsharp comes with a preview control designed to visualize drawing operations of the XGraphics object, but it cannot render PDF files.

Further the DrawImage function can be used to draw so called form XObjects in PDF pages. If you try to render such an object in the preview, only the bounding box is drawn to show that it cannot be rendered.

The PDFsharp Samples show how to invoke Adobe Reader or Acrobat to view or print PDF files and how to invoke GhostScript to create images from PDF pages.


So, if your primary goal is to show an existing PDF document inside your WinForm application, this is not your path to go.

Regards,
BH





I found that this is possible with PdfSharp. Please see:
http://www.pdfsharp.com/PDFsharp/[^],
http://pdfsharp.codeplex.com/[^].

Some code sample demonstrating a PDF viewer using this library and System.Windows.Forms can be found in Google Code:
http://reactivity.googlecode.com/svn/trunk/1.0/tools/PDF-2-JPEG/PDFsharp/PdfViewer/PdfViewer.Demo/PdfViewer.cs[^].

—SA
 
Share this answer
 
v2
Comments
Nayan Ambaliya 3-May-13 2:01am    
Thanks you very much...
Sergey Alexandrovich Kryukov 3-May-13 10:40am    
Sure. Will you accept the answer formally (green button)?
—SA
Well, one way or another it has to be downloaded to be viewed. A program can't work with data it doesn't have. Every file you view in your web browser (e.g. images, video, documents) has to be downloaded to your machine first, the only difference is it goes somewhere temporary where it will be deleted when it's no longer needed.

That said, what you could do is have the user install a PDF viewer with an IE compatible plug-in (in the off chance they don't already have one), and display it via a Web Browser control instead, which should forward it to the PDF viewer plug-in. It doesn't seem very elegant to me, but it does work. The other option is to download it to a temporary file, use it as you normally would, then delete it when you're done.
 
Share this answer
 
Comments
Nayan Ambaliya 3-May-13 2:02am    
Thank you very much...
But the web browser control has the limitation of 32 bit and 64 bit machines by its own...
I think I will have to download and delete it as done..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900