Click here to Skip to main content
13,095,663 members (52,326 online)
Rate this:
Please Sign up or sign in to vote.
See more:
how to save image and pdf formet in SaveFileDialog?
public static bool SaveDIBAs( string picname, IntPtr bminfo, IntPtr pixdat )
		SaveFileDialog sd = new SaveFileDialog();
		sd.FileName = picname;
		sd.Title = "Save bitmap as...";
		sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*";
		sd.FilterIndex = 1;
		if( sd.ShowDialog() != DialogResult.OK )
			return false;
		Guid clsid;
		if( ! GetCodecClsid( sd.FileName, out clsid ) )
			MessageBox.Show( "Unknown picture format for extension " + Path.GetExtension( sd.FileName ),
							"Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information );
			return false;
		IntPtr img = IntPtr.Zero;
		int st = GdipCreateBitmapFromGdiDib( bminfo, pixdat, ref img );
		if( (st != 0) || (img == IntPtr.Zero) )
			return false;
		st = GdipSaveImageToFile( img, sd.FileName, ref clsid, IntPtr.Zero );
		GdipDisposeImage( img );
		return st == 0;
Posted 1-Apr-13 18:52pm
Updated 1-Apr-13 21:54pm
What is "formet"?
File dialog boxes do not save anything, they are used to require a file name and obtain it from the user.
minu1989 2-Apr-13 2:26am
yes, i agree with you.I want to save file in different formet like pdf,doc,Image)bmp,tiff,jpg,png)etc in c# win-form.
OK, save it. What's the problem? Creation of the content is the problem, to be considered separately for each format, a bit too much for a single question...
ThePhantomUpvoter 2-Apr-13 1:39am
Why don't you just add PDF to your filter?
minu1989 2-Apr-13 2:23am
A added pdf in filter. when i save file as image formet like bmp,TIFF,JPEG,PNG,GIF,gif save them, but in pdf formet it gives error.
Do we have to pull all the detail from you? What error..?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100