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?
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.
Matthijs Koopman
Please mark my reply as answer if you found it help full
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?
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.
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
file.
cplusplus1
Member
138 Points
413 Posts
File.copy copying all webpages html side script also when i copy pdf file from one path to other
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.
m.koopman
Participant
1372 Points
294 Posts
Re: File.copy copying all webpages html side script also when i copy pdf file from one path to ot...
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.
Please mark my reply as answer if you found it help full
cplusplus1
Member
138 Points
413 Posts
Re: File.copy copying all webpages html side script also when i copy pdf file from one path to ot...
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.
KathyW
Participant
1636 Points
298 Posts
Re: File.copy copying all webpages html side script also when i copy pdf file from one path to ot...
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.
m.koopman
Participant
1372 Points
294 Posts
Re: File.copy copying all webpages html side script also when i copy pdf file from one path to ot...
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 file.
http://msdn.microsoft.com/en-us/library/ms143368.aspx
Please mark my reply as answer if you found it help full