Click or drag to resize

save Method

Save (asynchronously) the document currently open in the PdfWebControl instance.

function save();



Return Value

Type: Boolean

true if save initiated successfully; otherwise, false.


This method is the equivalent of clicking the save button in the PdfWebControl interface.


Simple Example

var myApi = new PdfWebControlApi("PdfWebControl1"); // where "PdfWebControl1" is the ID (ClientID) assigned to the PdfWebControl instance; //this will save the data currently in PdfWebControl asynchronously

Full Example

This example illustrates how to use the JavaScript PdfWebControlApi Class to save all current data in PdfWebControl instance via an external button.

The following examples uses a ASP.NET page which as a PdfWebControl on it and a single code behind page.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Save.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="RadPdf" Namespace="RadPdf.Web.UI" TagPrefix="radPdf" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
<body style="margin:0px">
    <form id="form1" runat="server">
        <radPdf:PdfWebControl ID="PdfWebControl1" RunAt="server" Height="600px" Width="850px" HideSaveButton="True" />

        <asp:button id="Button1" runat="server" text="Save" OnClientClick="return PdfSave();" />

    <script type="text/javascript">
        function PdfSave()
          (new PdfWebControlApi("<%=Me.PdfWebControl1.ClientID%>")).save();
          return false;

VB Code Behind

Option Explicit On
Option Strict On

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Me.PdfWebControl1.CreateDocument("test", System.IO.File.ReadAllBytes("C:\fw4.pdf"))

        End If
    End Sub
End Class

Notice the value of property "OnClientClick" for Button1.

(new PdfWebControlApi('PdfWebControl1')).save();
return false;

This code will always return false so that clicking the button does not initiate a PostBack.

Examining the code more closely, we see that the JavaScript class PdfWebControlApi is created passing the id of the PdfWebControl to the constructor. This then makes a new instance of this object which we can call the save Method against.

See Also