We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

saving a pdf file

Thread ID:

Created:

Updated:

Platform:

Replies:

67104 Aug 8,2007 10:51 PM UTC Aug 9,2007 02:16 PM UTC WinForms 1
loading
Tags: PDF
Wen Jiang
Asked On August 8, 2007 10:51 PM UTC


Syncfusion 4.4.

I have a pdfDocument and I want to save it as a pdf file. Here are my two questions:

1. Can I get the sample code to save the pdfDocument as a pdf file, and provide dialog for user to choose the path and name.

2. When I use the following code to save the file:
pdfDocument.Save("report.pdf");
System.Diagnostics.Process.Start("report.pdf");

The report file is saved and opened, but the file has to be closed if I want to regenerate the report, otherwise the program will crash.

Thanks a lot for helping me out.

Jane



Melba Winshia [Syncfusion]
Replied On August 9, 2007 02:16 PM UTC

Hi Jane,

Thank you for your interest in Essential PDF.

Issue 1: (provide dialog for user to choose the path)
--------

You can use SaveFileDialog class to provide dialog for user to choose the path and name.

[C#]


SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Files(*.pdf)|*.pdf";
saveFileDialog.AddExtension = true;
saveFileDialog.DefaultExt = ".pdf";

if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.CheckPathExists)
{
//Save the PDF Document to disk.
pdfDoc.Save(saveFileDialog.FileName);
pdfDoc.Close();

//Message box confirmation to view the created PDF document.
if (MessageBox.Show("Do you want to view the PDF file?", "PDF File Created",
MessageBoxButtons.YesNo, MessageBoxIcon.Information)
== DialogResult.Yes)
{
Process proc = new Process();
proc.StartInfo.FileName = saveFileDialog.FileName;
proc.Start();
}
}

Please refer the (modified - if one is provided earlier) sample in the below link which illustrates the above.



http://websamples.syncfusion.com/samples/XlsIO.Windows/67104/main.htm


Please try running the above sample and let me know if this helps.

Issue 2: (the file has to be closed)
--------

You can close the document by using close method of PDFDocument.

[C#]

//Save
pdfDocument.Save("report.pdf");

//Close the document
pdfDoc.Close();

//Open
System.Diagnostics.Process.Start("report.pdf");

Please let me know if you have any other questions.

Thanks,
Melba

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;