Saving Rendered Report with signature as PDF to SQL Server

Stimulsoft Reports.WEB discussion
Post Reply
adam2177
Posts: 3
Joined: Mon Nov 27, 2023 2:34 pm

Saving Rendered Report with signature as PDF to SQL Server

Post by adam2177 »

I am using the following code from a button click to generate a PDF of the current report and then saving it to my SQL DB. My report contains a digital signature field. Everything work great except when I click my save button the report is successfully saved but the signature field is blank.

Protected Sub SaveFinishedReportToDB(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim report = StiWebViewer1.Report
Dim Settings = New Stimulsoft.Report.Export.StiPdfExportSettings()
Dim Service = New Stimulsoft.Report.Export.StiPdfExportService()
Dim Stream = New System.IO.MemoryStream()
Service.ExportTo(report, Stream, Settings)
Dim bytes As Byte() = Stream.ToArray()

------ Save bytes to the DB ---------
End Sub

Any help is appreciated!
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Saving Rendered Report with signature as PDF to SQL Server

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
adam2177
Posts: 3
Joined: Mon Nov 27, 2023 2:34 pm

Re: Saving Rendered Report with signature as PDF to SQL Server

Post by adam2177 »

Not exactly sure what the best way to do that is so I have attached the mrt file

Here is the aspx code in it's entirety -
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="sample.aspx.vb" Inherits="sample" %>
<%@ Register assembly="Stimulsoft.Report.Web, Version=2023.4.3, Culture=neutral, PublicKeyToken=ebe6666cba19647a" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="frmMain" runat="server">
<asp:Button ID="cmdSave" runat="server" Text="Save It" Visible="true" />
</form>
<cc1:StiWebViewer ID="StiWebViewer1" runat="server" ViewMode="Continuous"></cc1:StiWebViewer>
</body>
</html>

And here is the vb code behind in it's entirety -
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Imports System.Data.SqlClient
Imports Stimulsoft.Report
Imports Stimulsoft.Report.Web

Partial Class sample
Inherits System.Web.UI.Page

Protected Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Stimulsoft.Base.StiLicense.LoadFromFile(Server.MapPath("Reports/license.key"))

Dim report = StiReport.CreateNewReport()
Dim path = Server.MapPath("Reports/report.mrt")
report.Load(path)

StiWebViewer1.Report = report
End Sub


Protected Sub SaveFinishedReportToDB(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim report = StiWebViewer1.Report

Dim Settings = New Stimulsoft.Report.Export.StiPdfExportSettings()
Dim Service = New Stimulsoft.Report.Export.StiPdfExportService()
Dim Stream = New System.IO.MemoryStream()

Service.ExportTo(report, Stream, Settings)

Dim bytes As Byte() = Stream.ToArray()
Dim constr As String = "you need to put your connection string here"
Using con As New SqlConnection(constr)
Dim query As String = "INSERT INTO tblFiles(chrDocType,chrDocName,binData) values (@chrDocType,@chrDocName,@binData)"
Using command As New SqlCommand(query)
command.Connection = con

command.Parameters.AddWithValue("@chrDocType", "sample")
command.Parameters.AddWithValue("@chrDocName", "sample.pdf")
command.Parameters.AddWithValue("@binData", bytes)

con.Open()
command.ExecuteNonQuery()
con.Close()
End Using
End Using
End Sub
End Class
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Again after I click my save button it successfuly saves but when I open the saved pdf the signature did not save.
Attachments
Report.mrt
(3.81 KiB) Downloaded 102 times
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Saving Rendered Report with signature as PDF to SQL Server

Post by Lech Kulikowski »

Hello,

We couldn't reproduce the issue on our samples.
Please send a full sample project that we can run and reproduce the issue.

Thank you.
adam2177
Posts: 3
Joined: Mon Nov 27, 2023 2:34 pm

Re: Saving Rendered Report with signature as PDF to SQL Server

Post by adam2177 »

Can you post the code needed to accomplish the following?

ie using asp.net and VB or c#, open a report in the web viewer that contains a signature (or use the one I posted). After signing the report, programmatically save it (including the signature) as a PDF to SQL server.
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: Saving Rendered Report with signature as PDF to SQL Server

Post by Lech Kulikowski »

Hello,

Please check the following article:
https://www.stimulsoft.com/en/documenta ... export.htm

Thank you.
Post Reply