Third Party PDF Tool

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
precisiondi
User
Posts: 2

Third Party PDF Tool

Post by precisiondi »

I'm new to .net and new to aspmaker.net. What I need to do is put a button on the view page that will execute the following code but I struggling with this process if anyone could point me in the right direct it would be greatly appreciated.

Here is the third party code

void Page_Load(Object Source, EventArgs E)
{
// Create instance of the PDF manager.
PdfManager objPDF = new PdfManager();

// Create new document.
PdfDocument objDoc = objPDF.CreateDocument();

// Specify title and creator for the document.
objDoc.Title = "AspPDF Chapter 3 Hello World Sample";
objDoc.Creator = "John Smith";

// Add a page to document.
PdfPage objPage = objDoc.Pages.Add();

// Obtain font.
PdfFont objFont = objDoc.Fonts["Helvetica"];

// Draw text using this parameter string:
string strParams = "x=0; y=650; width=612; alignment=center; size=50";
objPage.Canvas.DrawText("Hello World!", strParams, objFont);    

// Save, generate unique file name to avoid overwriting existing file.
string strFilename = objDoc.Save(Server.MapPath("hello.pdf"), false);
txtResult.Text = "Success! Download your PDF file <A TARGET=_new HREF=" + strFilename + ">here</A>";

}


motfs
User
Posts: 258

Post by motfs »

There is an extension, iTextSharp, for exporting PDF already. You may try to use it so you need to write code yourself. See Thirty Party Tools in help file.

If you want to use other third party PDF tool, you need to:

  1. modify the export link for PDF so you do not need to create another button or create another button
  2. add your code in the Page_Load server event for View Page to handle the export.

I would suggest you to use the existing extension to export.


precisiondi
User
Posts: 2

Post by precisiondi »

Thanks for the information. Since I'm new to ASP.NET Maker could you tell me what file I need to edit the current export link code?


motfs
User
Posts: 258

Post by motfs »

You can modify the export option in Page_Render server event (read the Server event and Client script in the help file ), e.g:

ExportOptions["pdf"].Body = "<a href="xxxlist.cshtml?<your parameters>">xxx</a>"; // assume you use C#

You should write your code for your page and do the export. For example, the export link can link back to the page itself and then handle it in Page_Load server event which should detect your URL parameters and export accordingly.

Note that your posted code was for old .aspx pages, you must update it so that it can be used in .cshtml pages. Try your hand at it, if it does work work, post your code for discussion.


Post Reply