cart: empty [ Login ]

Export inserted Images into pdf file

1 
morque
10/28/2008 7:57 PM
Hi, In my code I'm opening a document DWG and I'm inserting an image, this is done correctly. The image is showing in the DfxModel viewer quite well. The problem is that when I export the DxfModel to PDF or DXF the image I inserted does not appear into the PDF or DXF. Is there a way to insert the image into an DxfModel and to be part of the PDF or DXF file? am I doing something wrong or there is a bug? I use your example from: http://www.woutware.com/forum/index.php?topic=87.0, to insert an image. and I export to PDF like in the help file :
C# Code:
      GraphicsConfig graphicsConfig = (GraphicsConfig)GraphicsConfig.WhiteBackgroundCorrectForBackColor.Clone();       graphicsConfig.DisplayLineWeight = false;       graphicsConfig.DrawImages = true;       GDIGraphics3D cadGraphics = new GDIGraphics3D(graphicsConfig);       cadGraphics.CreateDrawables(_model);       Bounds3D bounds = new Bounds3D();       cadGraphics.BoundingBox(bounds, Matrix4D.Identity);       PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.Letter);       float pageWidth = paperSize.Width / 100f;       float pageHeight = paperSize.Height / 100f;       float margin = 0.5f;       Matrix4D to2DTransform = DxfUtil.GetScaleTransform(          bounds.Corner1,          bounds.Corner2,          new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d),          new Point3D(new Vector3D(margin, margin, 0d) * PdfExporter.InchToPixel),          new Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0d) * PdfExporter.InchToPixel),          new Point3D(new Vector3D(pageWidth / 2d, pageHeight - margin, 0d) * PdfExporter.InchToPixel)       );       using (Stream ms = File.Create(filename))       {         PdfExporter pdf = new PdfExporter(ms);         pdf.DrawPage(_model, graphicsConfig, to2DTransform, paperSize);         pdf.EndDocument();       }
Thanks for yor help
Wout
10/28/2008 8:13 PM
Hi, The PDF exporter does not (yet) support images. The export to DXF of the image should work, so that might be a bug. I'll investigate it tomorrow! Wout
Wout
10/29/2008 11:53 AM
Hi, Saving a DXF file with an image looks ok, using the example from the documentation:
C# Code:
using System; using System.Collections.Generic; using System.Text; using WW.Cad.Model; using WW.Cad.Model.Entities; using WW.Cad.Model.Objects; using WW.Cad.IO; using WW.Math; namespace WW.Cad.Examples {   public class ImageWriteExample {     public static void CreateModelWithImage() {       DxfModel model = new DxfModel();       DxfImageDef imageDef = new DxfImageDef(model);       imageDef.Filename = 'image.png';       imageDef.Name = imageDef.Filename;       imageDef.Size = new Size2D(840d, 525d);       imageDef.DefaultPixelSize = new Size2D(1d, 1d);       imageDef.ImageIsLoaded = true;       model.Images.Add(imageDef);       DxfImage image = new DxfImage();       image.ImageDef = imageDef;       image.InsertionPoint = new Point3D(3d, 2d, 0d);       image.ImageDisplayFlags = ImageDisplayFlags.ShowImage;       image.SetDefaultBoundaryVertices();       model.Entities.Add(image);       DxfWriter.WriteDxf('ImageTest.dxf', model, false);     }   } }
Are you storing the image with the DXF file though? About exporting to PDF that would be some work to implement, you can always sponsor specific features if you need them. Thanks! Wout
1