I am using GetBitmapFromCollection for taking the images of page in Bitmap format. Then these pages is used for printing. Quality of bitmap images are not good, thats why, quality of print is also bad.
My query is that, can't we get emf images (vector images) from above method.
Any other suggestions are also welcome.
Best Regards/
Piyush Vaishnav

Your image is probably being limited to 2000 x 2000 by the particular form of GetBitmapFromCollection you are using.

See Exporting View to Bitmap

No support for emf, but you can export to SVG. See NodeLinkDemo.

Actually, there is support for EMF if you use the MetafileView example class in NodeLinkDemo (or Demo1 in older kits).

Hi Walter,

Thanks for the reponse.
I am able to generate Metafile by using MetafileView class.
Now I am trying to save this metafile in Emf format like:
Metafile.Save(Stream, ImageFormat.Emf);
Exception has thrown "encoder is missing".
I googled i found there is no encoder has been provided from Microsoft for this format.
But there is alternative way by using Windows API:
But emf file which i am saving, is not having good image quality.
I think, i am missing something.
DO u have any idea that how to save metafile into Emf format.
Piyush Vaishnav

There’s a WriteMetafile method in the MetaFileView sample class…

Hi Jake,

Actually i could only found these methods there in MetafileView Class :
protected override DataObject CreateDataObject(IGoCollection coll, GoDocument clipdoc)
public virtual Metafile GetMetafileFromCollection(IGoCollection coll, RectangleF bounds, float scale, bool paper)
public virtual Metafile GetMetafile()
I could not found WriteMetafile method.
Can u tell which version of go diagram having this method.
Best Regards/
Piyush Vaishnav

Hi Jake,

I found method public virtual void WriteMetafileFromCollection(String path, IGoCollection coll, RectangleF bounds, float scale, bool paper) { lock (typeof(GoView)) { Graphics g = CreateGraphics(); IntPtr bufdc = g.GetHdc(); Metafile mf = new Metafile(path, bufdc, bounds, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual); Graphics gmf = Graphics.FromImage(mf); gmf.PageUnit = GraphicsUnit.Pixel; gmf.SmoothingMode = this.SmoothingMode; gmf.TextRenderingHint = this.TextRenderingHint; gmf.InterpolationMode = this.InterpolationMode; //gmf.CompositingQuality = this.CompositingQuality; //gmf.PixelOffsetMode = this.PixelOffsetMode; if (paper) { RectangleF b = bounds; b.Inflate(1, 1); PaintPaperColor(gmf, b); } foreach (GoObject obj in coll) { if (!obj.CanView()) continue; obj.Paint(gmf, this); } gmf.Dispose(); g.ReleaseHdc(bufdc); g.Dispose(); mf.Dispose(); }
Through this method i am saving my image as emf format.
But quality is still issue. While zooming all the GoTexts in page are not readable.
Am I missing something?
Best Regards/
Piyush Vaishnav

How big is your GoDocument.Bounds?

GoDucment.Bounds = {x= 1.0 , y = 1.5, width = 1462.0, Height = 929.0 }

ok, so scaling down to make it be a reasonable amount of memory doesn’t appear to be happening. Have you tried saving to PNG format?

Ya PNG format is much better than EMF format for this case.

For PNG images at the time of printing, GoText present in Document is not readable. Thats why trying with EMF format.

I guess I should have asked this at the top, but why aren’t you just use the print support, instead of creating a bitmap and then printing that? Things get imaged at the resolution of the printer if you do that, and should be better quality.

Ya I have tried direct printing option and this is the best out of all. But we wanted these images not only for printing but also for saving as PDF files. But the vector images should be always excellent. Can’t we save as good quality vector image out of these bounds which i posted in earlier reply.

PDF is a scalable format (unless you stick a bitmap in the PDF). We don’t provide a mechanism to go straight to PDF currently. We do support SVG, which is a more modern standard than metafiles. And, there does appear to be SVG to PDF code/products on the web. Plugging one of those into our SVG support may be the quickest way to a PDF file.

Hi Jake,

Now I am trying with direct printing GoView.Print() and GoView.PrintPreview()
I am using these line of code for fitting the GoView area to fit into printing area:
SizeF docsize = actView.PrintDocumentSize; if (docsize.Width > 1 || docsize.Height > 1) { PrintDocument pd = new PrintDocument(); Rectangle b = pd.DefaultPageSettings.Bounds; Margins m = pd.DefaultPageSettings.Margins; float w = b.Width - (m.Left + m.Right); float h = b.Height - (m.Top + m.Bottom); float ratio = Math.Min(w / docsize.Width, h / docsize.Height); if (ratio > 1) ratio = 1; actDiagram.PrintScale = ratio; } actView.PrintPreview();
I am having so many pages inside GoView and GoView.PrintDocumentSize returning whole area. So If there are 3 pages in project so these 3 pages are coming in only one page of PrintPreview.
I want separate page in PrintPreview for each pages in view.
Do you have any idea?
Best Regards/
Piyush Vaishnav

The code you have here is designed to take the whole set of printable objects and scale the preview so that it fits on a single printed sheet.

Try just calling PrintPreview without the rest of the code above.

Hi Jake,

If I am removing those lines, then in preview, pages are not coming properly.
My one page is having size width = 1472, Height = 942.
I am having 2 pages. Then first page of preview Height wise one full page and some portion of second page is coming. Width wise only half is coming. Remaining part is coming in another pages.

Sorry, I’m not understanding your requirement. Do you have some notion of a “page” that you are trying to get to map 1:1 with physical pages when you print?

Hi Jake,
Ya I am trying to map 1:1 with physical pages.
Actually we are having GoSheet(or call as Page).

This one page size is Width = 1472, Height = 942.
Best Regards/
Piyush Vaishnav

You have more than 1 GoSheet in a GoDocument?