Notifications
Clear all

[Closed] Loading a PDF from Max with .NET

Hi guys,

I am trying to load a PDF from Max using .NET (since I am trying to learn to implement .NET into my work). So with bit of help and looking around I used this code:



--Load Adobe AcroReader
process = dotNetObject "System.Diagnostics.Process"
process.EnableRaisingEvents = false
process.StartInfo.FileName = "AcroRd32"
process.StartInfo.Arguments = "N:\RESOURCES\Reference Images\Skies\Example.pdf"
process.Start()


I tested this on my computer with Adobe Reader 8.0 and it works fine, but most of my colleagues are using 8.1 which gets the following error:

“There was an error opening the Document. The file could not be found”

After some tests, it appears that it is the space in the “Reference Images” part of that path that causes the error of not being able to find the file. If I try and open (for example) “N:\RESOURCES\Example.pdf” the code works absolutely fine, cause there are no spaces.

Is there a special way that I can convey this path, using extra parentheses etc so that the space in the path is registered properly? Unfortunately I cannot change the folder name, since way too many projects reference it.

Any ideas would be greatly appreciated Thanks for your time everyone!

Rich

2 Replies

In windows you should use quotation marks (“) around a path that contain spaces when passing it as argument. I’m not sure it will help in this case though, but try this:


process.StartInfo.Arguments = "\"N:\\RESOURCES\\Reference Images\\Skies\\Example.pdf\""

hOpe this helps,
o

Cheers Ofer_z,

Just tested that out and you are spot on. It has competely resolved the issue by using the additional quotation marks!

Nice one,

Rich