1

I am trying to modify an existing SP2010 custom workflow action that converts an existing document to PDF using Word Automation. There is a new requirement to only convert the last published version of a document to PDF. I have been able to iterate through the file versions and find the last published version without too much trouble, but the problem is that when I pass the _vti_history version of the URL to the Word Automation ConversionJob.AddFile() method it generates a "Microsoft.SharePoint.SPException: List does not exist" error.

The latest version url is "http://myvm/Draft Documents/Test test test.docx"

The latest published version url is "http://myvm/_vti_history/2048/Draft Documents/Test test test.docx"

I am able to enter the URL for the latest published version in the browser and it opens the correct version of the document just fine.

Seeing the AddFile() method is not overloaded and only accepts (string inputURL, string outputUrl), does anyone wnow how I can get a previous version converted to PDF without having to write to a temporary file?

7
  • Have u taken a look with reflector at the code inside AddFile? Probably it will look for a SPList based on the url. Since your published version url is no valid Library it wil throw a valid exception. Have you tried using a library for your temporary file (the version you want to convert?) Commented Sep 11, 2012 at 6:07
  • Thanks for the feedback. I was hoping to avoid the temporary file solution but it was the only one I could think of. I hadn't thought of using reflector so I'll check it out. Commented Sep 11, 2012 at 6:12
  • I think it is rather weird btw, exporting old versions to pdf. Maybe a functionally rework might make it even easier. I have no idea about what you are trying to do but that's just a feeling i have. Can you maybe work around this using the Binary File Data? And don't use the Word Automation Service to convert ? Since this will only work using the latest version and only if your file is in a SPDocumentLibrary Commented Sep 11, 2012 at 13:49
  • This is coming from inside AddFile method using reflector: pastie.org/4701804 So it queries sharepoint. Commented Sep 11, 2012 at 14:02
  • Thanks Frederik for following up on this. I can see from the code segment you posted the problem would be that it is trying to get the inputFile.ParentFolder.ParentListId which it probably can't determine from the starting point of myvm/_vti_history/2048/Draft Documents/Test test test.docx. Commented Sep 12, 2012 at 1:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.