Cannot view PDF successfully after file transfer via PowerShell script

Advertisement

rbylnz
Joined:
Posts:
4

Cannot view PDF successfully after file transfer via PowerShell script

I have a PowerShell script that is used for transferring XML and PDF files. For both types of files, it performs the following operations separately:
  1. Copies files (\*.pdf) from remote folder A to local folder X via session.GetFiles
  2. Copies files (\*.pdf) from remote folder A to local folder TEMP via session.GetFiles. After copying, files in folder A are deleted (because the parameter remove is set to true)
  3. Copies files (\*.pdf) from local folder TEMP to remote folder B via session.PutFiles. After copying, files in folder TEMP are deleted (because the parameter remove is set to true)
Same operation is performed for XML files, too. For both file types, I use the same TEMP folder.
Basically steps 2 and 3 combined perform a move operation (There is probably a better solution for this, I know, but it works for me for now.)
When I run the script, the files are transferred successfully without a problem. There is no problem with the XML's, but when I try to view the PDF files that are transferred, I get a blank page saying "There was an error processing a page. Invalid colorspace". I tried viewing on different browsers and in my local disk, but that did not help.
One of the things I am suspecting is, that the file format might be messed up during the transfer, possibly because of some parameter in GetFiles/PutFiles. I looked but could not find an answer. I would appreciate any suggestion as to why this might have happened.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,285
Location:
Prague, Czechia

Re: Cannot view PDF successfully after file transfer via Powershell script

Can you isolate the problem better? There are so many steps in your description. And I guess that most of them are actually irrelevant to the problem.
Do you get the same problem by simply downloading and re-uploading a single PDF file? Can you post a log file for that? Do you get the same problem, if you download and re-upload a single PDF file in WinSCP GUI?

Reply with quote

rbylnz

Re: Cannot view PDF successfully after file transfer via Powershell script

I figured out the problem. The file format was indeed being messed up during transfer. I solved to problem by changing the TransferMode (in the TransferOptions parameter) from Ascii" to Automatic. The script works perfectly now.

Reply with quote

Advertisement

You can post new topics in this forum