PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 27, 2024 9:16 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Aug 12, 2014 6:30 pm 
Offline

Joined: Tue Aug 12, 2014 6:18 pm
Posts: 6
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 12, 2014 6:40 pm 
Offline

Joined: Tue Aug 12, 2014 2:07 pm
Posts: 2
This should help...

http://stackoverflow.com/questions/9847935/upload-a-document-to-a-sharepoint-list-from-client-side-object-model


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 13, 2014 9:21 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3110
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 13, 2014 3:48 pm 
Offline

Joined: Tue Aug 12, 2014 6:18 pm
Posts: 6
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 13, 2014 4:16 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3110
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 14, 2014 3:25 pm 
Offline

Joined: Tue Aug 12, 2014 6:18 pm
Posts: 6
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 14, 2014 4:33 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3110
Location: Cologne, Germany
Maybe a size limit of the web server (IIS?).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 14, 2014 4:40 pm 
Offline

Joined: Tue Aug 12, 2014 6:18 pm
Posts: 6
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 14, 2014 5:12 pm 
Offline

Joined: Tue Aug 12, 2014 6:18 pm
Posts: 6
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);


Top
 Profile  
Reply with quote  
PostPosted: Sun Aug 17, 2014 6:16 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 345
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.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 54 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group