Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 05, 2013 12:10 PM by m.koopman
Jan 04, 2013 03:59 PM|LINK
When i am copying a pdf file from one path to another it is putting all html side webpage scrip also in the process., if i rught click open pdf file in notepad, at the bottom i see all webpage content aswell, due to that i am getting file corruoted error
message when ever i try to download the file via asp.net webforms.
How to prevent getting html side content copied to the pdf file in teh copy process?
File.Copy(oldFilePath & "\" & oldFileName, strNewFilePath & "\RM\" & newCopyFileName)
Thanks a lot for the helpful info.
Jan 04, 2013 06:37 PM|LINK
Well the System.IO.File.Copy() method will copy a file as is, without modifying it's content. So if I'm right the HTML would already be present in the original file.
Jan 04, 2013 08:38 PM|LINK
Thks Koopman, When you open pdf file in notepad u can see right after %%EOF all html script of that page from where i uploaded the pdf file.
pdf file has %%EOF in the beginning and %%EOF at the end. since this html script getting appended to the pdf file, for that reason i am getting an error message saying file corrupted. only when i try to download it via webform.
If i open the file manually it opens no error message.
Is there a way i can remove those junk html side script from the pdf files source?
Thank you very much for the helpful info.
Jan 05, 2013 01:17 AM|LINK
How are you uploading and saving the pdf file? Rather than try to fix the corrupted content, try to find out how it got there in the first place, and how to prevent it. A simple file upload shouldn't be adding webpage content to the file.
Jan 05, 2013 12:10 PM|LINK
You can read the text content of a file using System.IO.File.ReadAllText() end manually trim of the junk. Then save the file again, and copy it to the new location, or just save the file to the new location leaving the junk in the original