1

i am building a button that allows a user to browse to a file. i want to get the location of the file and send it to printdialog. can this be done and if so how?

i know how to create the browse funcitonality and how to get the location...

my question is how to send the location of the file to the printdialog for printing...without opening the file

my goal is to print to pdf...

so if i can convert the .doc to pdf without printdialog that would be the best a user will browse to a file and convert it to pdf to a static destination

user311166
  • 43
  • 1
  • 1
  • 8
  • 1
    Is it the same type of file every time or are you wanting to print any format of file? – Nate Zaugg Apr 07 '10 at 16:18
  • its the same file type... .doc – user311166 Apr 07 '10 at 16:21
  • And you want to print it or PDF it? – Nate Zaugg Apr 07 '10 at 16:23
  • the closest thing i could come up with is having a user open the printdialog allowing them to select print to pdf. i would like the save location assigned within the code and also the file destination from the browse button (i can build) sent to the printdialog. – user311166 Apr 07 '10 at 16:24
  • the ultimate goal is to have a user browse to a file location and then have that file (.doc) file saved to a static location (that i define) as a pdf document. – user311166 Apr 07 '10 at 16:25
  • PrintDialog pDialog = new PrintDialog(); DialogResult result = pDialog.ShowDialog(); if (result == DialogResult.OK) { //get the file location //save it to 'myLocation' //the user will have to choose pdf in printdialog } – user311166 Apr 07 '10 at 16:28
  • sry i thought the textbox would retain my indents and line breaks hope you can still read my code. – user311166 Apr 07 '10 at 16:28

1 Answers1

1

The good news is that you don't have to open the file. The bad news is that if you're wanting to convert .doc files to PDF then you'll either need a component to do the work for you or you will need to do COM automation with Microsoft Word (with the Save as PDF Plug-in)

DOC to PDF library (not necessarily free)

It could also be possible to use a web browser in your application and tell it to print to a default printer (PDF printer -- lots of free ones) but if you're going to do a lot of these then finding a component to do this directly is your best bet; although quality may or may not be what you're looking for in the resulting PDF document.

Community
  • 1
  • 1
Nate Zaugg
  • 4,202
  • 2
  • 36
  • 53