EMF problem with 6.3.2942.31648
Moderators: SDS, support, admin
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
EMF problem with 6.3.2942.31648
Given the following snippet of code, which generates several variations of EMF's from a DWG:
When I run this, all the EMF files are empty. If I uncomment the above commented line which first renders the image to an EMF surface using Draw(), then all the subsequent EMF's are rendered correctly to their respective locations.
Code: Select all
CADImport.CADImage img = new CADImport.DWG.DWGImage();
img.LoadFromFile(@"e:\Sample Matter\DWG\456253.DWG");
img.SetCurrentLayout(img.DefaultLayoutIndex);
using (System.Windows.Forms.Form f = new System.Windows.Forms.Form())
using (System.Drawing.Graphics g = f.CreateGraphics())
using (System.Drawing.Imaging.Metafile mfo = new Metafile("c:\\out.emf", g.GetHdc(), EmfType.EmfOnly))
using (Graphics go = Graphics.FromImage(mfo))
{
<font color="green">//img.Draw(go, new RectangleF(0, 0, (float)(img.AbsWidth * 1000), (float)(img.AbsHeight * 1000)));</font id="green">
g.ReleaseHdc();
img.ExportToMetafile("c:\\out1.emf", new CADImport.DRect(0, 0, img.AbsWidth * 1000.0, img.AbsHeight * 1000.0));
System.Drawing.Imaging.Metafile mf = new System.Drawing.Imaging.Metafile("c:\\out1.emf");
using (System.Drawing.Imaging.Metafile mfnew = new System.Drawing.Imaging.Metafile("c:\\out2.emf", g.GetHdc(), System.Drawing.Imaging.EmfType.EmfOnly))
using (Graphics gnew = Graphics.FromImage(mfnew))
{
metafile1 = mf;
gnew.EnumerateMetafile(mf, new Point(0, 0), new Graphics.EnumerateMetafileProc(MetafileCallback));
}
}
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
On a similar note ... I use this code to feed to another module so I can create a fixed document format file.
On the older version of CADImport I was using (6.0.2645.16081) generated an EMF with text drawing instructions -- such that my final output document had selectable text.
The latest version, with no other code changes, doesn't generate an EMF that I can get selectable text from.
On the older version of CADImport I was using (6.0.2645.16081) generated an EMF with text drawing instructions -- such that my final output document had selectable text.
The latest version, with no other code changes, doesn't generate an EMF that I can get selectable text from.
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
Hello!
Could you please explain the main goal of your metafile import-export actions?
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Could you please explain the main goal of your metafile import-export actions?
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
Sure ... here's what I need to do with a DWG:
My end goal is to convert a DWG to PDF with selectable text. This is a small piece of a much larger program to convert many file types to PDF.
The older version of CADImport produced an EMF which I was able to rewrite to PDF. Debugging the metafile playback, I was able to see the various EMF Text drawing functions being played back.
The newer version however, when playing back the EMF records, there are no text drawing functions. Further debugging shows that CADImport sets the Antialias setting to ON, which triggers a different rendering method for drawing text to the metafile -- resulting in no actual text drawing functions being called. The characters are actually drawn with lines from GDI+.
That's the more critical of my needs. Ideally I'd like to be able to call LoadFromFile() to load the DWG, and ExportToMetafile() to export to EMF. The old version allowed me to do that, but the new version requires that I first call Draw() to render the dwg to a hidden surface.
Some bells and whistles that'd be nice would be:
- The ability to set the font smoothing mode in CADConst
- The ability to specify the EMF type in CADConst (EmfOnly, EmfPlusDual, EmfPlus)
Thanks for your time
My end goal is to convert a DWG to PDF with selectable text. This is a small piece of a much larger program to convert many file types to PDF.
The older version of CADImport produced an EMF which I was able to rewrite to PDF. Debugging the metafile playback, I was able to see the various EMF Text drawing functions being played back.
The newer version however, when playing back the EMF records, there are no text drawing functions. Further debugging shows that CADImport sets the Antialias setting to ON, which triggers a different rendering method for drawing text to the metafile -- resulting in no actual text drawing functions being called. The characters are actually drawn with lines from GDI+.
That's the more critical of my needs. Ideally I'd like to be able to call LoadFromFile() to load the DWG, and ExportToMetafile() to export to EMF. The old version allowed me to do that, but the new version requires that I first call Draw() to render the dwg to a hidden surface.
Some bells and whistles that'd be nice would be:
- The ability to set the font smoothing mode in CADConst
- The ability to specify the EMF type in CADConst (EmfOnly, EmfPlusDual, EmfPlus)
Thanks for your time
Hello Robert,
We suppose there is a little bit easier way for converting DWG file contents to anithing you need. CAD Import .NET gives access to all entities inside of DWG file including texts. The following code is based on <b>Viewer</b> demo:
Is this way is acceptable for you?
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
We suppose there is a little bit easier way for converting DWG file contents to anithing you need. CAD Import .NET gives access to all entities inside of DWG file including texts. The following code is based on <b>Viewer</b> demo:
Code: Select all
<font color="blue">for</font id="blue"> (<font color="blue">int</font id="blue"> i=0;i<<font color="blue">this</font id="blue">.cadImage.CurrentLayout.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
<font color="blue">if</font id="blue"> (<font color="blue">this</font id="blue">.cadImage.CurrentLayout.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i] <font color="blue">is</font id="blue"> CADText)
{
CADText entText = (CADText)<font color="blue">this</font id="blue">.cadImage.CurrentLayout.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
-
- Posts: 12
- Joined: 11 Dec 2007, 21:38
- Location: USA
For now I've reverted to using an older version of the cadimport library, which is kindof unfortunate. There's no way for me to write a whole rendering and translation program to draw the CAD drawing to PDF without purchasing another PDF library separately.
Also -- I couldn't find any of the objects you referenced in the CADImport.DLL assembly. CurrentLayout, ConvSection, CADText, etc.
Also -- I couldn't find any of the objects you referenced in the CADImport.DLL assembly. CurrentLayout, ConvSection, CADText, etc.
Hello!
<ol type="1"><li>There is an opportunity to prepare CADImport.DLL which will create EMF with readable texts. If you are interested, please contact us to support@vadsofttools.com with a reference to this topic in the e-mail.</li>
<li>We plan to add export to PDF file format soon.</li></ol id="1">
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<ol type="1"><li>There is an opportunity to prepare CADImport.DLL which will create EMF with readable texts. If you are interested, please contact us to support@vadsofttools.com with a reference to this topic in the e-mail.</li>
<li>We plan to add export to PDF file format soon.</li></ol id="1">
Sergey.
Please post questions to the forum or write to support@cadsofttools.com