BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Michael,
Thank you for contacting Syncfusion support.
Currently DocIO does not provide any direct API to specify the resolution of the Image in Word to Image conversion. As a work around you can specify the resolution of the image before saving it. Please find the following code snippets for your reference.
WordDocument document = new WordDocument(openFileDialog1.FileName); Image[] images = document.RenderAsImages(ImageType.Bitmap); int i = 0; foreach (Image image in images) { //Specify the resolution of the image (image as Bitmap).SetResolution(100, 100); //Saves the images as jpeg image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg); i++; } |
WordDocument document = new WordDocument(FileName); //Modify the size of the pages in the document foreach(WSection section in document.Sections) { section.PageSetup.PageSize = new SizeF(620, 712); } //The images in the collection will have the width and height of the page in the Word document Image[] images = document.RenderAsImages(ImageType.Bitmap); //Close the document document.Close(); int i = 0; foreach (Image image in images) { //Saves the images as jpeg image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg); i++; |
WordDocument document = new WordDocument(FileName); Image[] images = document.RenderAsImages(ImageType.Metafile); //Close the document document.Close(); int i = 0; foreach (Image image in images) { Bitmap bitmap = null; Metafile metaFile = image as Metafile; bitmap = new Bitmap(1275, 1650); bitmap.SetResolution(150, 150); using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage(metaFile, 0, 0, 1275, 1650); g.Dispose(); } bitmap.Save("WordToImage_" + i + ".png", ImageFormat.Png); i++; |
try { bitmap = new Bitmap(bitmapWidth, bitmapHeight); bitmap.SetResolution(resolutionF, resolutionF); using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage(metafile, 0, 0, (float)bitmapWidth, (float)bitmapHeight); g.Dispose(); } bitmap.Save(@"..\..\ssImages\Sheet Specs" + i.ToString("D3") + ".png", ImageFormat.Png); bitmap.Dispose(); bitmap = null; populated = true; } |
Hi Michael,
You have specified that the add-in does not save the images with antialiasing and the Windows Forms does. If the code used to save the image in simple Windows Form sample and add-in varies then please provide us the code snippets you have used. Please find the following code snippet to specify the antialiasing of the image and let us know if it helps.
using (Graphics g = Graphics.FromImage(bitmap)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.DrawImage(metaFile, 0, 0, 1275, 1650); g.Dispose(); } |
Hi Michael,
Thank you for your reply.
We could not run your Addin in any of our machine. Can you please provide necessary software to run your Addin and RevitAPI.dll, RevitAPIUI.dll , Thereby we can proceed further.
Also can you please try the following code snippet to resolve your antialiasing problem?
using (Graphics g = Graphics.FromImage(bitmap)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.DrawImage(metafile, 0, 0, 1275, 1650); g.Dispose(); } |
If this code does not meet your expected result, go through the following link with more details about image processing techniques.
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.interpolationmode%28v=vs.110%29.aspx
Please let us know if you have any queries.
Best Regards,
Pradeep L