.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Saving file as PDF Programatically

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :Sql Server

I want to be able to save any report that I generate from the system as a PDF in a document repository through my program.  I have a winforms, C# application using local reports.

Any help / pointers would be so awesome.

Thanks, JD

Thanks JD LinkedIn: www.linkedin.com/in/johndsanders

View Complete Post

More Related Resource Links

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or pasting into an application. 2D versions are also available:

Does this look correct for saving a file/ new record to a database


So thank you for all your help so far, So I think i got this right,
but would like for you all to look it over to see if there is any
areas I might run into trouble with:

//using asp.net mvc 2
the table (sql server 2005, using entities framework)
table fields
"Pattern_Media_GUID  uniqueid 
"Pattern_GUID  uniqueid
"Media varbinary(max)  
"height int
"Width int
"Media_Type String (50)

the form:
<h2> Add Media to this pattern</h2>
<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
    <%: Html.Label("height") %>
    <%: Html.TextBox("height") %>

    <%: Html.Label("width") %>
    <%: Html.TextBox("width") %>

    <%: Html.Label("Media") %>
    <input type="file" id="Media" name="Media" />
    <input type="submit" name=

VB.NET Saving Excel File

Hi, I am exporting my values in my textboxes to an excel spreadsheet (user clicks "Export" button on form). After it is done, it asks me if i want to overwrite my current excel spreadsheet. Is there a way that I can open a save as dialog box so I can choose what name and where to save it? Thanks   Private Sub ResultsExcelbgw_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles ResultsExcelbgw.DoWork Dim Resultsdata As ResultsDataDef = DirectCast(e.Argument, ResultsDataDef) Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Try xlApp = New Excel.ApplicationClass xlWorkBook = xlApp.Workbooks.Open("C:\program files\Noxious Weeds Report\Reports\nw_budget_Summary.xlsx") xlWorkSheet = xlWorkBook.Worksheets("sheet1") Catch ex As Exception MessageBox.Show("Excel connection error: Please contact your System Administrator.", "Communication Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End Try 'Use message box below to check current value in excel if needed 'MsgBox(xlWorkSheet.Cells(1, 1).value) 'edit the cell with new value Try xlWorkSheet.Cells(1, 1) = Resultsgrpbox.Text xlWorkSheet.Cells(18, 1) = "Report Generated: &quo

reading excel file without saving to disk first

Having an issue.  I need to be able to read an excel file from a file upload control but I can not save the file to disk first, it must be done in memory.string excelConnectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; excelConnectionstring += filePath.Replace("/", "\\"); excelConnectionstring += ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;'"; OleDbConnection con = new OleDbConnection(excelConnectionstring); OleDbDataAdapter da = new OleDbDataAdapter();Above is my code for reading the data file if it IS saved to disk, but again, I have to be able to do this without saving the file to disk, it must be done in memory.  I have not been able to find any sample code anywhere on how to do this from memory, everything seems to force the file be uploaded, saved to disk, and then read in the connection string, which again I can not do.Any advise would be great, thanks in advance.  I'm really in a bind here.

Saving Image File in a Folder on Sever from Client Machine using Sql Server

  Hi EveryOne... Can anyone help me Saving an Image file in a Server folder from a client machine using Sql server 2005....   

Saving SSIS results to Log or text file using dtexec

Hi, How to save the SSIS package results to log file using dtexec command............please help regaridng this...........   Thanks in advance,

Saving a generated text file

 I have an application that collects data and puts it in a text file.  When the data collection is complete the UI offers the user the opportunity to save or open the text file with a dialog box using this code: Response.Clear(); Response.ClearHeaders(); Response.AppendHeader("Content-Disposition", "attachment; filename=" + outputFilename + ";"); Response.Cache.SetCacheability(HttpCacheability.Private); Response.ContentType = "text/plain"; Response.WriteFile(outputFilePath + outputFilename); Response.End(); Response.Flush(); The problem is this.  The starting interface allows the user to select a large number of data gathering points.  If all are selected the program will run for about 90 minutes.  Sometimes it will present the dialog box, sometimes not.  Sometimes it will present the dialog box, but regardless of whether the user selects save or open, the dialog box simply disappears, and the data text file is neither displayed nor saved to the client system. When fewer data gather points are selected, and the program runs for 15 minutes or less, there is no problem.  The resulting data can be saved or displayed. The actual data text file is initially stored in the temporary path directory on the web server.  On at least one occasion, where the dialog box disappeared, I was able to

Send a csv file by email without saving it first

The following code pulls data from a table writes it to a csv file and then prompts a user to open or save the file. What I need to do is pull the data to the csv file and send it to a predetermined email address, without prompting the user or saving it. How can I do this? Dim MySQL As String = "" MySQL = "SELECT TOP 1 * FROM [tblSurvey] ORDER BY SurveyID DESC" Dim MyConn As New SqlConnection(ConnectStr) Dim cmd As New SqlCommand _ (MySQL, MyConn) 'Set the appropriate ContentType. Dim filename As String = "Data_" & txtName.Text & "_" & System.DateTime.Now & ".txt" cmd.CommandType = CommandType.Text cmd.Connection.Open() Dim myReader As SqlDataReader = _ cmd.ExecuteReader _ (CommandBehavior.CloseConnection) Dim i As Integer Dim sb As New System.Text.StringBuilder For i = 0 To myReader.FieldCount - 1 If i < (myReader.FieldCount - 1) Then sb.Append(myReader.GetName(i) & Chr(9)) Else sb.Append(myReader.GetName(i) & vbCrLf) End If Next While myReader.Read() For i = 0 To myReader.FieldC

Uploading doc file into SharePoint Document library Programatically.

Hi all, I want to upload the doc file into SharePoint document library using the FileUpload control. For that I am created a new document library in my SharePoint site. But I am not getting the path of Document library where I want to upload the file. Waiting for your valuable response. Regards,-Kaustubh

How to show a message box on an invalid filename entered while saving a file using save file dialog

Hi all i have written a code to display a message box if invalid characters are entered while saving the file but my message box is not displaying. Actually i will have a save file dialog option to save a file if the filename starts or consists of the following    \\/:*?<>|"  I would like to display a message box as invalid or illegalcharacters in file My code is as follows    Stream myStream;                          SaveFileDialog saveFileDialog1 = new SaveFileDialog();                            saveFileDialog1.InitialDirectory = @"C:\";                          saveFileDialog1.DefaultExt = "txt";                          saveFileDialog1.Filter = "(*.txt)|*.txt";                          saveFileDialog1.FilterIndex = 2;                          saveFileDialog1.RestoreDirectory = true;                            if (saveFileDialog1.ShowDialog() == DialogR

Windows 7, Office 2007, and WSS 3.0: Losing file path when saving to Document Library.

A client of ours recently purchased 5 desktops with Windows 7 and Office 2007.  They use Sharepoint to share all documents for their company. The computers that have Windows XP on them can browse the Sharepoint site, open documents (read only or edit), and chose to Save or Save As.  A new window pops open with their current file path of the Sharepoint Document Library so they can save the file in the same folder they opened it from.  I have tested this with Office 2003 and 2007 (Word and Excel) on XP and it always works. The 5 new desktops running Windows 7 cannot do this.  When a user opens a document by browsing to it from Internet Explorer and chooses to Save or Save As, they are kicked back to their last successful save point (usually My Documents or Desktop). The current work around is mapping a drive to the root Document Library directory and having them traverse through the folders to save it back in the original location. I've tried changing the Check Out save settings in Word 2007 and Excel 2007 to edit directly on the server, but I run into the same problem.  I've also made sure that IE sees the site as a Local Intranet site and Protected Mode is off. Any help would be appreciated.  Thanks in advance.

saving a text file in ms access data base

i have to read a text file in a text box then have to save it into ms access data base in column format how could i do this....

getting and saving (uploading) the file in FileUpload component


Hello all,

I have a question about saving an image file with it's thumbnail in vb.net.

I used the following code :

            If resim.PostedFile.ContentLength > 100 And resim.PostedFile.ContentLength < 10000000 And resim.PostedFile.ContentType.IndexOf("application") = -1 Then
                resim.SaveAs(Server.MapPath("firmadosyalari/a" + Session("firma").ToString + "/") + resim.FileName.ToString)
                If tf.bunuekle(" INSERT INTO firmaurunlerim " + _

Uploading .pdf files with FIle Upload control and then saving to database


Hi everyone!

I'd like to allow users to upload a .pdf file via the file upload control (if that's the best method), save the file to the db and then retrieve it so they can click on a link and open the .pdf they've uploaded.

I've been looking for a tutorial on how to do this but keep running into methods of saving the file directly on the server in a directory, not in SQL server  (using Linq and VB by the way)

Can someone please point me in the right direction on how to do this?   Thanks!

Error when saving file from Word: This file cannot be saved because some properties are missing or


I am receiving an error when trying to save a file from Word into SharePoint: "This file cannot be saved because some properties are missing or invalid"

I have got two different Content Types for this Document Library: "Policies" and "Procedures". Both documents have got exactly the same required fields, all required fields are displayed in the Document Information Panel. If I try to save a "Policy" the saving process works fine, if I try to save a "Procedure" I get the above error.

It's as if the Procedure had an additional required field, but I cannot figure out where that would come from? If I go to manage the Content Types and check the list of fields, I can clearly see which fields are required and which aren't.

Is there something I am missing? Or could one Content Type be corrupt? If so, how do I fix it without messing up all the files that have already been posted using this Content Type?

Applying a Windows .theme file programatically


After searching the internet high and low, I still can't find a documented method of changing a windows theme silently.  There are ways to apply themes to applications, and ways to apply msstyles without prompting the user, but I have run into considerable difficulty finding a supported way to apply a microsoft theme file.  Doesnt seem to matter if it is XP, Vista, or Win7 - they all cause a .cpl applet to appear and remain on the desktop.  Sendkeys is never a good solution, and I know I can close the window by the handle ID, but it still appears for a second and that's unacceptable.  Has anyone solved this problem?  Is there any way to prevent the control panel personalization (Win7) window from opening?

Thanks in advance. . .


Saving a Xml file to a RANDOM filename


Hello everybody,

I got an application that opens a xml file and writes to it and saves it to another (fixed) file name.

But my question is: Is there a way to save the Xml file to a random number or the input of a textbox?

I am using the XmlTextWriter in a Form app and the language is C#.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend