当前位置: 首页>>代码示例>>C#>>正文


C# XpsDocument.Close方法代码示例

本文整理汇总了C#中XpsDocument.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XpsDocument.Close方法的具体用法?C# XpsDocument.Close怎么用?C# XpsDocument.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XpsDocument的用法示例。


在下文中一共展示了XpsDocument.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveXPS

        public static bool SaveXPS(FixedPage page, bool isSaved)
        {
            FixedDocument fixedDoc = new FixedDocument();//创建一个文档
            fixedDoc.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);

            PageContent pageContent = new PageContent();
            ((IAddChild)pageContent).AddChild(page);
            fixedDoc.Pages.Add(pageContent);//将对象加入到当前文档中

            string containerName = GetXPSFromDialog(isSaved);
            if (containerName != null)
            {
                try
                {
                    File.Delete(containerName);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                XpsDocument _xpsDocument = new XpsDocument(containerName, FileAccess.Write);

                XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);
                xpsdw.Write(fixedDoc);//写入XPS文件
                _xpsDocument.Close();
                return true;
            }
            else return false;
        }
开发者ID:mydipcom,项目名称:MEIKReport,代码行数:30,代码来源:FileHelper.cs

示例2: Window_Loaded

 private void Window_Loaded(object sender, EventArgs e)
 {            
     XpsDocument doc = new XpsDocument("test.xps", FileAccess.ReadWrite);
     docViewer.Document = doc.GetFixedDocumentSequence();
     
     doc.Close();
 }
开发者ID:ssickles,项目名称:archive,代码行数:7,代码来源:Xps.xaml.cs

示例3: ViewDocument

 public void ViewDocument(string fileName)
 {
     if (System.IO.File.Exists(fileName) == true)
     {
         XpsDocument xpsDocument = new XpsDocument(fileName, System.IO.FileAccess.Read);
         this.Viewer.Document = xpsDocument.GetFixedDocumentSequence();
         xpsDocument.Close();
     }
 }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:9,代码来源:XpsDocumentViewer.xaml.cs

示例4: LoadQuickStartToDocummentViewer

        private void LoadQuickStartToDocummentViewer()
        {
            string fileName = @"Quick Start Guide.xps";
            XpsDocument document = new XpsDocument(fileName, FileAccess.Read);
            this.documentViewer.Document = document.GetFixedDocumentSequence();
            document.Close();

            this.documentViewer.FitToWidth();

            var contentHost = this.documentViewer.Template.FindName("PART_ContentHost", this.documentViewer) as ScrollViewer;
            var grid = contentHost?.Parent as Grid;
            grid?.Children.RemoveAt(0);
        }
开发者ID:MarcoMedrano,项目名称:WinR,代码行数:13,代码来源:SettingsView.xaml.cs

示例5: button2_Click

    private void button2_Click(object sender, RoutedEventArgs e)
    {
      string filename = "Test.txt";
      File.Delete(filename);
      XpsDocument doc = new XpsDocument(filename, System.IO.FileAccess.ReadWrite);
      XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(doc);

      //PageContent content = CreateFifthPageContent();
      FixedPage page = CreateFifthPageContent();
      //page.conten
//      page.
      xpsdw.Write(page);
      doc.Close();
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:14,代码来源:DrawingTest.xaml.cs

示例6: SaveToFile

 internal void SaveToFile(string fileName)
 {
     Transform transform = canvasContainer.LayoutTransform;
     canvasContainer.LayoutTransform = null;
     Size size = new Size(canvasContainer.Width, canvasContainer.Height);
     canvasContainer.Measure(size);
     canvasContainer.Arrange(new Rect(size));
     Package package = Package.Open(fileName, System.IO.FileMode.Create);
     XpsDocument doc = new XpsDocument(package);
     XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
     writer.Write(canvasContainer);
     doc.Close();
     package.Close();
     canvasContainer.LayoutTransform = transform;
 }
开发者ID:Miraculix,项目名称:Git-Source-Control-Provider,代码行数:15,代码来源:HistoryGraph.xaml.cs

示例7: LoadDocument

        /// <summary>
        /// Loads the specified DocumentPaginatorWrapper document for print preview.
        /// </summary>
        public void LoadDocument(DocumentPaginatorWrapper document)
        {
            m_Document = document;
            string temp = System.IO.Path.GetTempFileName();
            if (File.Exists(temp))
            {
                File.Delete(temp);
            }

            XpsDocument xpsDoc = new XpsDocument(temp, FileAccess.ReadWrite);
            XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
            xpsWriter.Write(document);

            documentViewer.Document = xpsDoc.GetFixedDocumentSequence();
            xpsDoc.Close();
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:19,代码来源:PrintPreview.xaml.cs

示例8: SaveVisualToByteArray

        /// <summary>
        /// Store a visual in an array of bytes.
        /// </summary>
        /// <param name="v">The <see cref="Visual"/> to serialise.</param>
        /// <returns>The serialised <see cref="Visual"/>.</returns>
        public static byte[] SaveVisualToByteArray(this Visual v)
        {
            // Open new package
            MemoryStream stream = new MemoryStream();
            Package package = Package.Open(stream, FileMode.Create);
            // Create new xps document based on the package opened
            XpsDocument doc = new XpsDocument(package);
            // Create an instance of XpsDocumentWriter for the document
            XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
            // Write the Visual to the document
            writer.Write(v);
            // Close document
            doc.Close();
            // Close package
            package.Close();

            return stream.ToArray();
        }
开发者ID:ElecNetKit,项目名称:ElecNetKit,代码行数:23,代码来源:DrawingVisualSerialisers.cs

示例9: Xps_Click

        private void Xps_Click(object sender, RoutedEventArgs e)
        {
            FixedPage page = new FixedPage() { Background = Brushes.White, Width = Dpi * PaperWidth, Height = Dpi * PaperHeight };

            TextBlock tbTitle = new TextBlock { Text = "My InkCanvas Sketch", FontSize = 24, FontFamily = new FontFamily("Arial") };
            FixedPage.SetLeft(tbTitle, Dpi * 0.75);
            FixedPage.SetTop(tbTitle, Dpi * 0.75);
            page.Children.Add((UIElement)tbTitle);

            var toPrint = myInkCanvasBorder;
            myGrid.Children.Remove(myInkCanvasBorder);

            FixedPage.SetLeft(toPrint, Dpi * 2);
            FixedPage.SetTop(toPrint, Dpi * 2);
            page.Children.Add(toPrint);

            Size sz = new Size(Dpi * PaperWidth, Dpi * PaperHeight);
            page.Measure(sz);
            page.Arrange(new Rect(new Point(), sz));
            page.UpdateLayout();

            var filepath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "PrintingTest");
            if (!File.Exists(filepath))
                Directory.CreateDirectory(filepath);
            var filename = System.IO.Path.Combine(filepath, "myXpsFile.xps");

            FixedDocument doc = new FixedDocument();

            PageContent pageContent = new PageContent();
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(page);
            doc.Pages.Add(pageContent);

            XpsDocument xpsd = new XpsDocument(filename, FileAccess.Write);
            XpsDocument.CreateXpsDocumentWriter(xpsd).Write(doc);               //requires System.Printing namespace

            xpsd.Close();

            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
                printDialog.PrintQueue.AddJob("MyInkCanvas print job", filename, true);

            page.Children.Remove(toPrint);
            myGrid.Children.Add(toPrint);
        }
开发者ID:nanomouse,项目名称:stratasys,代码行数:44,代码来源:Window3.xaml.cs

示例10: cmdShowFlow_Click

        private void cmdShowFlow_Click(object sender, RoutedEventArgs e)
        {
            
            if (File.Exists("test2.xps")) File.Delete("test2.xps");

            using (FileStream fs = File.Open("FlowDocument1.xaml", FileMode.Open))
            {
                FlowDocument doc = (FlowDocument)XamlReader.Load(fs);

                XpsDocument xpsDocument = new XpsDocument("test2.xps", FileAccess.ReadWrite);
                XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

                writer.Write(((IDocumentPaginatorSource)doc).DocumentPaginator);

                // Display the new XPS document in a viewer.
                docViewer.Document = xpsDocument.GetFixedDocumentSequence();
                xpsDocument.Close();
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:19,代码来源:Xps.xaml.cs

示例11: LoadDocument

        /// <summary>
        /// Loads the specified FlowDocument document for print preview.
        /// </summary>
        public void LoadDocument(FlowDocument document)
        {
            mDocument = document;

              string temp = System.IO.Path.GetTempFileName();

              if (File.Exists(temp) == true)
            File.Delete(temp);

              XpsDocument xpsDoc = new XpsDocument(temp, FileAccess.ReadWrite);

              XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

              xpsWriter.Write(((FlowDocument)document as IDocumentPaginatorSource).DocumentPaginator);

              documentViewer.Document = xpsDoc.GetFixedDocumentSequence();

              xpsDoc.Close();
        }
开发者ID:joazlazer,项目名称:ModdingStudio,代码行数:22,代码来源:PrintPreviewDialog.xaml.cs

示例12: ConvertToXps

        /// <summary>
        /// Convert a FixedDocument to an XPS file.
        /// </summary>
        /// <param name="fixedDoc">The FixedDocument to convert.</param>
        /// <param name="outputStream">The output stream.</param>
        public static void ConvertToXps(FixedDocument fixedDoc, Stream outputStream)
        {
            var package = Package.Open(outputStream, FileMode.Create);
            var xpsDoc = new XpsDocument(package, CompressionOption.Normal);
            XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);

            // xps documents are built using fixed document sequences
            var fixedDocSeq = new FixedDocumentSequence();
            var docRef = new DocumentReference();
            docRef.BeginInit();
            docRef.SetDocument(fixedDoc);
            docRef.EndInit();
            ((IAddChild)fixedDocSeq).AddChild(docRef);

            // write out our fixed document to xps
            xpsWriter.Write(fixedDocSeq.DocumentPaginator);

            xpsDoc.Close();
            package.Close();
        }
开发者ID:cipjota,项目名称:Chronos,代码行数:25,代码来源:XpsHelper.cs

示例13: Print

        public static void Print(List<object> printCollection, 
            String FinalTargetFileName, String HeadLineText, String PrintPageOrientation = "Portrait")
            {

            PrintDialog PrtDialog = new PrintDialog();
            LocalPrintServer LPS = new LocalPrintServer();
            PrintQueue DefaultPrinterQueue = LocalPrintServer.GetDefaultPrintQueue();
            PrintTicket DefaultTicket = DefaultPrinterQueue.DefaultPrintTicket;
            PrintCapabilities DefaultCapabilities = DefaultPrinterQueue.GetPrintCapabilities(DefaultTicket);

            if (PrintPageOrientation == "Landscape")
                PrtDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            else
                PrtDialog.PrintTicket.PageOrientation = PageOrientation.Portrait;

            PAPER_SIZE_WIDTH = PrtDialog.PrintableAreaWidth;
            PAPER_SIZE_HEIGHT = PrtDialog.PrintableAreaHeight;
            TOP_MARGIN = PrtDialog.PrintableAreaHeight * 0.08;
            SIDE_MARGIN = PrtDialog.PrintableAreaWidth * 0.08;

            double MaxOWidth = PAPER_SIZE_WIDTH - (2 * SIDE_MARGIN);
            double MaxOHeight = PAPER_SIZE_HEIGHT - (2 * TOP_MARGIN) - 20;

            FixedDocument PageDocumentToPrint = new FixedDocument();
            DefinitionsForPrintWithXAMLControls XAMLDefinitionsForOnePage = GenerateNewContent(PageDocumentToPrint);
            ObservableCollection<object> PageCollection = XAMLDefinitionsForOnePage.GlobalContainer.ItemsSource as ObservableCollection<object>;
            int NumberOfPages = CreatePages (XAMLDefinitionsForOnePage, PageDocumentToPrint, MaxOHeight, printCollection,
                PageCollection, HeadLineText);



            XpsDocument XpsDoc = new XpsDocument(FinalTargetFileName, FileAccess.Write);
            XpsDocumentWriter XpsWriter = XpsDocument.CreateXpsDocumentWriter(XpsDoc);
            XpsWriter.Write(PageDocumentToPrint.DocumentPaginator);
            XpsDoc.Close();
		
            }
开发者ID:heinzsack,项目名称:DEV,代码行数:37,代码来源:CommonXpsPrinter.cs

示例14: FlowDocumentToPDF

        public void FlowDocumentToPDF(DocumentPaginator paginator, string filename, string reportName, bool overWrite)
        {
            MemoryStream lMemoryStream = new MemoryStream();
            Package package = Package.Open(lMemoryStream, FileMode.Create);
            XpsDocument doc = new XpsDocument(package);

            XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);

            XpsPackagingPolicy packagePolicy = new XpsPackagingPolicy(doc);
            XpsSerializationManager serializationMgr = new XpsSerializationManager(packagePolicy, false);

            writer.Write(paginator);
            doc.Close();
            package.Close();

            var pdfXpsDoc = PdfSharp.Xps.XpsModel.XpsDocument.Open(lMemoryStream);
            PdfSharp.Xps.XpsConverter.Convert(pdfXpsDoc, filename, 0);
            pdfXpsDoc.Close();
        }
开发者ID:klot-git,项目名称:scrum-factory,代码行数:19,代码来源:Report.cs

示例15: Save

        public void Save()
        {
            if (Uri == null)
            {
                throw new ArgumentException("Uri has not been specified");
            }

            var xpsDocument = new XpsDocument(Uri.OriginalString, FileAccess.ReadWrite);
            var xpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
            xpsDocumentWriter.Write(FixedDocumentSequence);
            xpsDocument.Close();
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:12,代码来源:RollupDocument.cs


注:本文中的XpsDocument.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。