I need to build a pdf file from an wpf window. that window contains a canvas with some draw and some textboxes and labels whith data.
一位朋友告诉我说,他用了结晶报告,但似乎不是我的好解决办法。
我想印刷一下信道上的形象,并写出一些电.盒和标签的 whi。
我需要一个不付报酬的解决办法。
我如何能够这样做?
I need to build a pdf file from an wpf window. that window contains a canvas with some draw and some textboxes and labels whith data.
一位朋友告诉我说,他用了结晶报告,但似乎不是我的好解决办法。
我想印刷一下信道上的形象,并写出一些电.盒和标签的 whi。
我需要一个不付报酬的解决办法。
我如何能够这样做?
我通过称为iTextSharp的自由工具(EDIT)找到了解决这一问题的办法: iTextSharp是无商业用途的NOT,是假信息的 s。 实际上,我需要把世界森林论坛的固定文件转换为人民抵抗力量,因此,这与你想要做的工作略有不同,但或许也可以帮助你们。 基本上,这种做法是采用WPF固定文件(实际上是一种XPS格式),将其转换成图象。 之后,使用ITextSharp s PdfWriter语,将这一图像作为PDF文件的一个页子添加。 我尝试了其他几种方法,包括一种称为gxps的自由用途,但这种方法对我来说是最好的。
我的法典就是一个例子。
using iTextSharp.text;
using iTextSharp.text.pdf;
.
.
.
// create an iTextSharp document
Document doc = new Document(PageSize.LETTER, 0f, 0f, 0f, 0f);
PdfWriter.GetInstance(doc, new FileStream("C:\myFile.pdf", FileMode.Create));
doc.Open();
// cycle through each page of the WPF FixedDocument
DocumentPaginator paginator = myFixedDocument.DocumentPaginator;
for (int i = 0; i < paginator.PageCount; i++)
{
// render the fixed document to a WPF Visual object
Visual visual = paginator.GetPage(i).Visual;
// create a temporary file for the bitmap image
string targetFile = Path.GetTempFileName();
// convert XPS file to an image
using (FileStream outStream = new FileStream(targetFile, FileMode.Create))
{
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(CreateBitmapFromVisual(visual, 300, 300)));
enc.Save(outStream);
}
// add the image to the iTextSharp PDF document
using (FileStream fs = new FileStream(targetFile, FileMode.Open))
{
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), System.Drawing.Imaging.ImageFormat.Png);
png.ScalePercent(24f);
doc.Add(png);
}
}
doc.Close();
这里指的是如何在C#中建立固定文件:
using System.Windows.Documents;
using System.Windows.Documents.Serialization;
using System.Windows.Markup;
// create an instance of your XAML object (Window or UserControl)
var yourXAMLObj = new YourXAMLObject();
// create a FixedDocument and add a page of your XAML object
var fixedDocument = new FixedDocument();
fixedDocument.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
fixedPage.Children.Add(yourXAMLObj);
fixedDocument.Pages.Add(pageContent);
((IAddChild)pageContent).AddChild(fixedPage);
我希望这一图书馆能帮助你。
PDFsharp
is a .NET Library forprocess PDF file. 你利用从全球发展趋势+中了解的节目制作PDF网页。 几乎可以与全球发展指数+做的任何事情也将与人民抵抗力量合作。 只有基本文字布局得到人民抵抗力量的支持,没有自动造成页数中断。 同样的绘画常规可用于屏幕、PDF或元文档。
http://www.pdfsharp.net/MainPage.ashx
PDFsharp在麻省理工学院出版。
ok,它用于gdi+,但也许足够了。
I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...
Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...
I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...
Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...
Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...
I ve got some code which sets up a datacontext. Often enough, the datacontext should be set to some underlying data collection, such as an ObservableCollection - but occasionally I d like to set it ...
I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...
NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...