-2

How to write byte[](Source file is word) value to pdf.

Here is the code which i am using.

FtpWebRequest reqFTP;

strPath="ftp://1.1.1.1/Docs/word.doc";
strFileName="output.doc";
FileStream outputStream = new FileStream("C:/folder/" + Session.SessionID + "/" + strFileName, FileMode.Create);


reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(strPath));
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;

               
reqFTP.Credentials = new NetworkCredential(strUname, strPassword);
reqFTP.Proxy = null;

FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

Stream ftpStream = response.GetResponseStream();


strExt = strFileName.Split('.');

               

long cl = response.ContentLength;
readCount = ftpStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
    outputStream.Write(buffer, 0, readCount);
    readCount = ftpStream.Read(buffer, 0, bufferSize);
}

ftpStream.Close();
outputStream.Close();
response.Close();

byte[] source comes from the FtpWebRequest.GetResponseStream() source is word file..How to write the byte[] to pdf file.

I have tried the way which mentioned in this linkByte[] to Pdf, but when i try to open pdf it showing (Adobe reader could not open. because it is either not a supported file type or because the file has been damanged(for example, it was sent as an email attachment and wasn't correctly decoded)).

Thank You

3
  • 1
    What you're actually asking is how to convert a .doc (contained in a byte[]) to a .pdf. Do you have Microsoft Word installed on the computer this will be running on?
    – Dan Field
    Apr 16, 2015 at 3:04
  • @Dan Field Yes you are correct but Microsoft Word is not installed. Can we able to convert a word (contained in a byte[]) to pdf document. without Microsoft Office.?
    – Bilal
    Apr 16, 2015 at 3:12
  • Rewrite your question to clarify, but you'll probably find that the only easy ways to do this involve expensive third party libraries, office to be installed, or using a web service to convert it for you. The hard ways (doing more of it yourself) will require way more than a SO answer could supply.
    – Dan Field
    Apr 16, 2015 at 3:18

1 Answer 1

0

you can use third-party component for your perpose. like Aspose.Words. it can simplely do this work for you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.