Hello:
Hello
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. Could you please provide the code which you use to get the document across the network?
Best regards,
Here is my code:
protected void MergePDFandDisplay(string[] vwjobs)
{
int index = vwjobs.Length;
string reportsfolder = ConfigurationManager.AppSettings["ReportsFolder"].ToString();
SqlConnection objConn = new SqlConnection();
SqlCommand objCmd = new SqlCommand();
objConn.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
objConn.Open();
objCmd.Connection = objConn;
objCmd.CommandText = "select ......"
SqlDataReader rdr = objCmd.ExecuteReader();
//open the reader, get the info and close as soon as possible. We do not want to leave the db connections open.
ArrayList filePaths = new ArrayList();
while(rdr.Read()){
filePaths.Add(reportsfolder + rdr["CustomerID"] + "\\" + rdr["Date"] + "\\" + rdr["DocumentID"]);
};
rdr.Close();
objConn.Close();
string[] paths = new string[index];
filePaths.CopyTo(paths,0);
//declare an array list to hold our memory streams. For ASPOSE methods.
ArrayList myList = new ArrayList();
MemoryStream[] streams = new MemoryStream[index]; //size of our num of jobs
MemoryStream inStream; //for each individual job
//for each job go out and convert it to PDF. Do not write to disk. Save this into a MemoryStream
foreach (string p in paths)
{
//write our converted stream into our inStream variable then add it to our ArrayList
inStream = new MemoryStream(CreatePDFStream(p).GetBuffer());
myList.Add(inStream);
}
//copy the array list to the MemoryStream array. Needed for the ASPOSE methods.
myList.CopyTo(streams,0);
//Create our output stream which will hold our merged PDF
MemoryStream outStream = new MemoryStream();
//ASPOSE object to concatenate the PDF streams into our 1 single outStream MemoryStream
try{
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(streams, outStream);
outStream.Close();
}
catch(Exception e){
Response.Write(e.ToString());
Response.End();
}
//Set the appropriate ContentType and wrrite the stream to the browser.
Response.ContentType = "Application/pdf";
Response.BinaryWrite(outStream.GetBuffer());
Response.End();
}
protected MemoryStream CreatePDFStream(string faspath)
{
string documentid = faspath.Substring(faspath.Length - 12);
MemoryStream currstream = new MemoryStream();
Document currdoc;
try{
currdoc = new Document(File.OpenRead(faspath)); //faspath is reading from a share such as\\sharename\folder1\folder2\WordDoc1.DOC. This works if I read from my web code folders. Such as, Server.MapPath("TemFolder\\WordDoc1.DOC") and it works.
currdoc.Save(currstream, SaveFormat.Pdf);
}
catch (Exception e){
Response.Write(e.ToString());
Response.End();
}
return currstream;
}
Hello
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for additional information. I cannot reproduce the problem on my side using the latest version Aspose.Words and Aspose.Pdf.Kit. I use the same code as you provide, my file path looks like the following @"\\192.168.0.1\temp\1.doc". Could you please create simple application which will allow me to reproduce the problem on my side?
Best regards,