PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Save PDF document to Sharepoint Document Library https://forum.pdfsharp.net/viewtopic.php?f=2&t=2895 |
Page 1 of 1 |
Author: | mevasquez [ Tue Aug 12, 2014 6:30 pm ] |
Post subject: | Save PDF document to Sharepoint Document Library |
I have created a Web page using asp.net C#. I have developed this page on my local machine; however, when I published my code to the server everthing works except when I try to save the file using mydoc.Save(filename), I get an access denied error on the server. I don't have rights to write to the server so it was suggested that I write to a SharePoint site. Does anyone have sample code of how to save the file to a sharepoint document library? Thanks in advance. Mike V |
Author: | fubak [ Tue Aug 12, 2014 6:40 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
This should help... http://stackoverflow.com/questions/9847935/upload-a-document-to-a-sharepoint-list-from-client-side-object-model |
Author: | Thomas Hoevel [ Wed Aug 13, 2014 9:21 am ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
mevasquez wrote: when I published my code to the server everthing works except when I try to save the file using mydoc.Save(filename), I get an access denied error on the server. Do you want to store the file on the server or do you want to return the PDF file to the user?A MemoryStream is the solution if you want to return the file to the user. |
Author: | mevasquez [ Wed Aug 13, 2014 3:48 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
I want to user to click on a button called DailySchedule and view the schedule in pdf format. So it seems I will need to use MemoryStream. In my code PdfDocument myDoc = new PdfDocument(); I want to have the end user view myDoc. Any sample code? Thanks, Mike V |
Author: | Thomas Hoevel [ Wed Aug 13, 2014 4:16 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
Here's a PDFsharp sample that returns a PDF file to the browser: http://www.pdfsharp.net/wiki/Clock-sample.ashx With MigraDoc you create the PDF in a slightly different way, but returning it to the browser is the same way. |
Author: | mevasquez [ Thu Aug 14, 2014 3:25 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
I used this part of the sample: Code: // Send PDF to browser MemoryStream stream = new MemoryStream(); document.Save(stream, false); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", stream.Length.ToString()); Response.BinaryWrite(stream.ToArray()); Response.Flush(); stream.Close(); Response.End(); This works on my development machine but when I go to publish to the server, there is one button that does not produce the pdf. When I went to check the length of the stream it was 1.63 mb I have another button that produced a smaller pdf and it works great. Any ideas of what I can do to make this work on the server. The page count of the pdf document that is not produced is four pages. Thanks, Mike |
Author: | Thomas Hoevel [ Thu Aug 14, 2014 4:33 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
Maybe a size limit of the web server (IIS?). |
Author: | mevasquez [ Thu Aug 14, 2014 4:40 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
Found the problem. The last page is trying to get an image from my x: drive, which the server does not have. I just have to move the image to the server and get the image from there. Thanks, Mike V. |
Author: | mevasquez [ Thu Aug 14, 2014 5:12 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
how would I read the image in from the image folder on the server, IIS 7 on Windows 2008 R2. I tried to read the file using URL but that is not supported. Code: XImage xImage = XImage.FromFile(filename.jpg);
|
Author: | () => true [ Sun Aug 17, 2014 6:16 pm ] |
Post subject: | Re: Save PDF document to Sharepoint Document Library |
mevasquez wrote: how would I read the image in from the image folder on the server, IIS 7 on Windows 2008 R2. Use the address of the file on the local file system ("C:\..."), not the external http address.
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |