PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
PdfSharp and Sharepoint 2010 https://forum.pdfsharp.net/viewtopic.php?f=2&t=1980 |
Page 1 of 1 |
Author: | ronyz [ Thu Apr 19, 2012 2:00 pm ] |
Post subject: | PdfSharp and Sharepoint 2010 |
Hello, i am trying to use PdfSharp to create Sharepoint designer workflow to merge 2 pdf document. However when i try to pass the file url to PdfReader to open the document i am getting an error about URI formats not supported. Any help would be really appreciated. If i can't pass the file path as a URI how can i open the file with PdfReader ?? Regards, RZ |
Author: | Thomas Hoevel [ Mon Apr 23, 2012 11:52 am ] |
Post subject: | Re: PdfSharp and Sharepoint 2010 |
Hi! ronyz wrote: If i can't pass the file path as a URI how can i open the file with PdfReader? Use .NET to read the PDF file from the URI into a stream, then use PdfReader to read from that stream.
|
Author: | Hawkmoth [ Wed May 09, 2012 2:18 pm ] |
Post subject: | Re: PdfSharp and Sharepoint 2010 |
Hi Thomas I have the same issue. I'm a novice so could you expand on your answer? This is the code I have so far:- Code: string strPDF = @"http://Myserver/MyPdf.pdf"; HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(strPDF); HttpWebResponse myResponce = (HttpWebResponse)myRequest.GetResponse(); PdfDocument inputDocument1; try { inputDocument1 = PdfSharp.Pdf.IO.PdfReader.Open(myResponce.GetResponseStream(),PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import ); } catch(Exception ex) { lblMessage.Text = ex.ToString(); return; } Many thanks in advance Hawkmoth |
Author: | Thomas Hoevel [ Wed May 09, 2012 2:26 pm ] |
Post subject: | Re: PdfSharp and Sharepoint 2010 |
Hi! Hawkmoth wrote: I'm a novice so could you expand on your answer? So far the code looks correct.Where's the problem? |
Author: | Hawkmoth [ Wed May 09, 2012 2:32 pm ] |
Post subject: | Re: PdfSharp and Sharepoint 2010 |
Hi Thomas Thanks for your speedy reply. I get thie error from the catch statment:- System.NotSupportedException: This stream does not support seek operations. at System.Net.ConnectStream.get_Length() at PdfSharp.Pdf.IO.Lexer..ctor(Stream pdfInputStream) at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider) at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode) at IWManuals.Default.CombinePDFDocument(List`1 strFilename) in D:\Old_D_Drive\My Programs\CSharp 2010\IWManuals\IWManuals\Default.aspx.cs:line 47 Thanks |
Author: | Hawkmoth [ Wed May 09, 2012 3:32 pm ] |
Post subject: | Re: PdfSharp and Sharepoint 2010 |
Hi Thomas Think I've solved mine. Like I said, I'm a novice at this so I'm not sure why this works and the origanal didn't. So for anyone following in the future, This code now works:- Code: string strPDF = "http://MyServer/MyPdf.pdf; byte[] buffer = new byte[4096]; WebRequest wr = WebRequest.Create(strPDF); WebResponse response = wr.GetResponse(); Stream responseStream = response.GetResponseStream(); MemoryStream memoryStream = new MemoryStream(); int count = 0; do { count = responseStream.Read(buffer, 0, buffer.Length); memoryStream.Write(buffer, 0, count); } while (count != 0); PdfDocument inputDocument1; try { inputDocument1 = PdfSharp.Pdf.IO.PdfReader.Open(memoryStream, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import); } catch(Exception ex) { lblMessage.Text = ex.ToString(); return; } All the best Hawkmoth |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |