新做的一个绘图软件,需要在上面加上将图形保存为PDF格式。求指教

解决方案 »

  1.   

    找个生成pdf的控件,将图 insert进去,然后就可以生成pdf了
      

  2.   

    先保存成图片,再转化为pdf,要不然就是往pdf里插入这个图片
      

  3.   

    用iTextSharp
     Document document = null;            PdfWriter writer = null;
                string fileSavePath = "d:\\";
                System.Drawing.Image sourceImg = null;            iTextSharp.text.Image pdfImage = null;            try
                {
                 //   filePath = fileSavePath + "\temp" +  ".pdf";
                    filePath = @"d:\temp.pdf";
                    iTextSharp.text.Rectangle rectPageSize = new iTextSharp.text.Rectangle(PageSize.A4);             //   rectPageSize = rectPageSize.Rotate();                document = new Document(rectPageSize, 0, 0, 0, 0);                writer = PdfWriter.GetInstance(document, new FileStream(filePath, FileMode.Create));                document.Open();            //    sourceImg = System.Drawing.Image.FromFile(fileSavePath + "\\" + fileInputName);
                    sourceImg =System.Drawing.Image.FromFile( fileInputName);
                    pdfImage = iTextSharp.text.Image.GetInstance(sourceImg, GetImageFormat(GetFileExtendName(fileInputName)));                pdfImage.Alignment = iTextSharp.text.Image.ALIGN_CENTER;                float height = document.Top - document.TopMargin;
                    //图片原始大小
                    pdfImage.ScaleToFit(sourceImg.Width > document.Right ? document.Right : sourceImg.Width, sourceImg.Height > height ? height : sourceImg.Height);                //pdfImage.ScaleToFit(document.Right ,height);                document.Add(pdfImage);
                    document.NewPage();
                    sourceImg = System.Drawing.Image.FromFile("2.jpg");
                    pdfImage = iTextSharp.text.Image.GetInstance(sourceImg, GetImageFormat(GetFileExtendName("2.jpg")));
                    pdfImage.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
                    pdfImage.ScaleToFit(sourceImg.Width > document.Right ? document.Right : sourceImg.Width, sourceImg.Height > height ? height : sourceImg.Height);
                    document.Add(pdfImage);
                    
                    sourceImg = null;                pdfImage = null;                document.Close();                writer.Close();
      

  4.   

    我的图片很大很长,插入PDF里面后显示不全,怎么设置