|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
Important Notice:
We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024.
If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
View previous topic :: View next topic |
Author |
Message |
danbli
Joined: 10 Feb 2008 Posts: 1
|
Posted: Sun Feb 10, 2008 10:34 pm Post subject: Cant create PDF from my Webproject |
|
|
Hello!
I've tried to create a PDF from my webpage project by including the DLL and everything works fine with the compiling and that but when running the project i get "You cannot draw on a page that is not owned by a PdfDocument object.".
This comes from XGraphics.cs
if (page.Owner == null)
throw new ArgumentException("You cannot draw on a page that is not owned by a PdfDocument object.", "page");
Iv'e tried a normal console application and there everythin workes fine.
I've also enabled the attribute write on the webapplication in Internet Information Server.
My code looks like this.
using System;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PdfSharp;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
PdfDocument dokument = new PdfDocument();
PdfPage sida = new PdfPage();
XGraphics grafik = XGraphics.FromPdfPage(sida);
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
grafik.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, sida.Width, sida.Height),XStringFormat.Center);
string filename = "HelloWorld.pdf";
dokument.Save(filename);
Process.Start(filename);
}
} |
|
Back to top |
|
|
|
|
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 vote in polls in this forum
|
|