예제 #1
0
        static public void SaveXpsPageToBitmap(string xpsFileName)
        {
            System.Windows.Xps.Packaging.XpsDocument       xpsDoc = new System.Windows.Xps.Packaging.XpsDocument(xpsFileName, FileAccess.Read);
            System.Windows.Documents.FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();

            // You can get the total page count from docSeq.PageCount
            for (int pageNum = 0; pageNum < docSeq.DocumentPaginator.PageCount; ++pageNum)
            {
                DocumentPage       docPage      = docSeq.DocumentPaginator.GetPage(pageNum);
                RenderTargetBitmap renderTarget =
                    new RenderTargetBitmap((int)docPage.Size.Width,
                                           (int)docPage.Size.Height,
                                           96, // WPF (Avalon) units are 96dpi based
                                           96,
                                           PixelFormats.Default);

                renderTarget.Render(docPage.Visual);

                BitmapEncoder encoder = new BmpBitmapEncoder(); // Choose type here ie: JpegBitmapEncoder, etc
                encoder.Frames.Add(BitmapFrame.Create(renderTarget));

                FileStream pageOutStream = new FileStream(xpsFileName + ".Page" + pageNum + ".bmp", FileMode.Create, FileAccess.Write);
                encoder.Save(pageOutStream);
                pageOutStream.Close();
            }
        }
예제 #2
0
        public static void Concat(string targetFileName, params string[] filesToConcat)
        {
            var fixedDocumentSequence = new FixedDocumentSequence();

            var tempFileName = Path.GetTempFileName();
            using (var target = new XpsDocument(tempFileName, FileAccess.Write))
            {
                var xpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(target);

                if (filesToConcat != null)
                {
                    foreach (var doc in filesToConcat)
                    {
                        Add(doc, fixedDocumentSequence);
                    }
                }

                xpsDocumentWriter.Write(fixedDocumentSequence);
            }

            if (File.Exists(targetFileName))
            {
                File.Delete(targetFileName);
            }
            File.Move(tempFileName, targetFileName);
        }
예제 #3
0
        /// <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();
        }
예제 #4
0
        public static void DoItTTT()
        {
            string filename    = "c:\\tmp\\goof.xps";
            string newFilename = "c:\\tmp\\new_goof.xps";

            XpsDocument xpsOld = new XpsDocument(filename, System.IO.FileAccess.Read);

            System.Windows.Documents.FixedDocumentSequence seqOld = xpsOld.GetFixedDocumentSequence();
            System.IO.Packaging.Package container = System.IO.Packaging.Package.Open(newFilename, System.IO.FileMode.Create);
            XpsDocumentWriter           writer    = XpsDocument.CreateXpsDocumentWriter(new XpsDocument(container));

            System.Windows.Documents.Serialization.SerializerWriterCollator vxpsd = writer.CreateVisualsCollator();
            int pageno = 1;

            foreach (System.Windows.Documents.DocumentReference r in seqOld.References)
            {
                System.Windows.Documents.FixedDocument d = r.GetDocument(false);
                foreach (System.Windows.Documents.PageContent pc in d.Pages)
                {
                    System.Windows.Documents.FixedPage fixedPage = pc.GetPageRoot(false);
                    double width           = fixedPage.Width;
                    double height          = fixedPage.Height;
                    System.Windows.Size sz = new System.Windows.Size(width, height);
                    fixedPage.Measure(sz);
                    fixedPage.Arrange(new System.Windows.Rect(new System.Windows.Point(), sz));
                    fixedPage.UpdateLayout();
                    ContainerVisual newpage = new ContainerVisual();
                    newpage.Children.Add(fixedPage);
                    newpage.Children.Add(CreateWatermark(400, 400, "hello world"));
                    pageno++;
                    vxpsd.Write(newpage);
                }
            }
            vxpsd.EndBatchWrite();
            container.Close();
            xpsOld.Close();
        }
예제 #5
0
 public override void Write(FixedDocumentSequence fixedDocumentSequence)
 {
     Write(fixedDocumentSequence, null);
 }
예제 #6
0
 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence)
 {
     throw new NotSupportedException();
 }
        //-------------------------------------------------------------------
        //
        //  Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        internal FixedDocumentSequencePaginator(FixedDocumentSequence document)
        {
            _document = document;
        }
예제 #8
0
 public void RemoveDocument(int docIndex)
 {
     _documents.RemoveAt(docIndex);
     _fixedDocumentSequence = null;
 }
예제 #9
0
        private void PrintGrid(Grid grid)
        {
            if (File.Exists("C:\\test\\FixedDocumentSequence.xps"))
            {
                File.Delete("C:\\test\\FixedDocumentSequence.xps");
            }
            var xpsDocument          = new XpsDocument("C:\\test\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
            XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);

            writer.Write(this.GridEstimate);
            System.Windows.Documents.FixedDocumentSequence Document = xpsDocument.GetFixedDocumentSequence();
            xpsDocument.Close();
            //var windows = new PrintWindow(Document);
            //windows.ShowDialog();

            //Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            //dlg.FileName = "MyReport"; // Default file name
            //dlg.DefaultExt = ".xps"; // Default file extension
            //dlg.Filter = "XPS Documents (.xps)|*.xps"; // Filter files by extension

            //// Show save file dialog box
            //Nullable<bool> result = dlg.ShowDialog();

            // Process save file dialog box results


            PrintDialog print = new PrintDialog();
            //pDialog.PageRangeSelection = PageRangeSelection.AllPages;
            //pDialog.UserPageRangeEnabled = true;
            var data = this.GridEstimate;

            //Nullable<Boolean> print = pDialog.ShowDialog();
            if (print.ShowDialog() == true)
            {
                PrintCapabilities capabilities = print.PrintQueue.GetPrintCapabilities(print.PrintTicket);
                double            scale        = Math.Min(capabilities.PageImageableArea.ExtentWidth / grid.ActualWidth,
                                                          capabilities.PageImageableArea.ExtentHeight / grid.ActualHeight);
                Transform oldTransform = grid.LayoutTransform;

                grid.LayoutTransform = new ScaleTransform(scale, scale);



                //string path = "C:\\test\\FixedDocumentSequence.xps";

                //System.IO.Packaging.Package package = System.IO.Packaging.Package.Open(path, System.IO.FileMode.Create);
                //System.Windows.Xps.Packaging.XpsDocument document = new System.Windows.Xps.Packaging.XpsDocument(package);
                //System.Windows.Xps.XpsDocumentWriter writer = System.Windows.Xps.Packaging.XpsDocument.CreateXpsDocumentWriter(document);
                //FixedDocument doc = new FixedDocument();

                //FixedPage page1 = new FixedPage();
                //PageContent page1Content = new PageContent();
                //((System.Windows.Markup.IAddChild)page1Content).AddChild(page1);

                ////add the element from the scrollable control to the fixed page
                ////page1.Children.Add(….);

                //doc.Pages.Add(page1Content);
                //writer.Write(doc);
                //document.Close();
                //package.Close();
                //XpsDocument xpsDocument = new XpsDocument("C:\\test\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
                //FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                print.PrintVisual(grid, "Test print job");
            }
        }
예제 #10
0
 // ------------------ GetAnnotationDocumentPaginator ------------------
 /// <summary>
 ///   Returns a paginator for printing annotations.</summary>
 /// <param name="fds">
 ///   The FixedDocumentSequence containing
 ///   the annotations to print.</param>
 /// <returns>
 ///   An paginator for printing the document's annotations.</returns>
 public AnnotationDocumentPaginator GetAnnotationDocumentPaginator(
                                             FixedDocumentSequence fds)
 {
     return new AnnotationDocumentPaginator(
                    fds.DocumentPaginator, _annotService.Store);
 }
 public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket, object userState);
 public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket);
 /// <summary>
 /// Asynchronous Write a single FixedDocumentSequence and close package
 /// </summary>
 public abstract void WriteAsync(FixedDocumentSequence fixedDocumentSequence);
예제 #14
0
 private static void Add(string path, FixedDocumentSequence fixedDocumentSequence)
 {
     using (var doc = new XpsDocument(path, FileAccess.Read))
     {
         var sourceSequence = doc.GetFixedDocumentSequence();
         if (sourceSequence != null)
         {
             foreach (var dr in sourceSequence.References)
             {
                 var newDocumentReference = new DocumentReference
                                            {
                                                Source = dr.Source
                                            };
                 var baseUri = ((IUriContext)dr).BaseUri;
                 ((IUriContext)newDocumentReference).BaseUri = baseUri;
                 var fd = newDocumentReference.GetDocument(true);
                 newDocumentReference.SetDocument(fd);
                 fixedDocumentSequence.References.Add(newDocumentReference);
             }
         }
     }
 }
예제 #15
0
파일: gsprint.cs 프로젝트: surjit/mupdf-1
        /* Main print entry point */
        public void Print(PrintQueue queu, FixedDocumentSequence fixdoc)
        {
            XpsDocumentWriter docwrite = GetDocWriter(queu);

            m_busy = true;
            docwrite.WritingPrintTicketRequired +=
                new WritingPrintTicketRequiredEventHandler(PrintTicket);
            PrintPages(docwrite, fixdoc);
        }
예제 #16
0
        // --------------- CreatePopulatedFixedDocumentSequence ---------------
        /// <summary>
        ///   Creates a FixedDocumentSequence with content.</summary>
        /// <param name="pq">
        ///   The print queue to print to.</param>
        /// <returns>
        ///   A FixedDocumentSequence with content.</returns>
        public FixedDocumentSequence CreatePopulatedFixedDocumentSequence(
            PrintQueue pq)
        {
            // Create FixedDocumentSequence
            FixedDocumentSequence fixedDocumentSequence =
                new FixedDocumentSequence();

            // Add Documents to a Fixed Document Sequence
            DocumentReference documentRef = new DocumentReference();
            documentRef.SetDocument(CreateFixedDocumentWithPages(pq));
            fixedDocumentSequence.References.Add(documentRef);

            return fixedDocumentSequence;
        }
예제 #17
0
	    public void LoadOperatorProcessReport(int operatorId)
	    {
	        var dataService = new OperatorReportDataService();
	        Report = dataService.GetOperatorProcessReport(operatorId, StartDate, EndDate);

	        var reportDocument = new ReportDocument();

	        var reader =
                new StreamReader(new FileStream(@"Views\Reporting\OperatorProcessReport.xaml", FileMode.Open, FileAccess.Read));
	        reportDocument.XamlData = reader.ReadToEnd();
	        reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Views\Reporting\");
	        reader.Close();

	        var data = new ReportData();

	        // set constant document values
	        data.ReportDocumentValues.Add("PrintDate", DateTime.Now);

	        var titleTabel = new DataTable("TitleTable");
	        titleTabel.Columns.Add("ReportTitle", typeof(string));
            var name = Common.Properties.Resources.ResourceManager.GetString("txtName") + Report.Title;
            var code = Common.Properties.Resources.ResourceManager.GetString("txtCode") + Report.Code;
	        var date = DateTime.Now.ToPersianCompactDateTimeString();
            titleTabel.Rows.Add(new object[] { name });
            titleTabel.Rows.Add(new object[] { code });
            titleTabel.Rows.Add(new object[] { date });

            data.DataTables.Add(titleTabel);

            var totalTabel = new DataTable("TotalTable");
            totalTabel.Columns.Add("TimeTotal", typeof(string));
            totalTabel.Columns.Add("CountTotal", typeof(string));

            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalTargetTime") + Format.ConvertToHMS((int) Report.TotalTargetTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalTargetCount") + Report.TotalTargetCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalProductionTime") + Format.ConvertToHMS((int)Report.TotalProductionTime), Common.Properties.Resources.ResourceManager.GetString("txTotalProductionCount") + Report.TotalProductionCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalExtraTime") + Format.ConvertToHMS((int)Report.TotalExtraTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalExtraCount") + Report.TotalExtraCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalShortageTime") + Format.ConvertToHMS((int)Report.TotalShortageTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalShortageCount") + Report.TotalShortageCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalDefectionTime") + Format.ConvertToHMS((int)Report.TotalDefectionTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalDefectionCount") + Report.TotalDefectionCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalWaste") + Report.TotalWaste, Common.Properties.Resources.ResourceManager.GetString("txtTotalSecondGrade") + Report.TotalSecondGrade });


            data.DataTables.Add(totalTabel);

	        var activitiesTable = new DataTable("ActivitiesReport");

            activitiesTable.Columns.Add("Date", typeof(string));
	        activitiesTable.Columns.Add("Product", typeof (string));
	        activitiesTable.Columns.Add("Station", typeof (string));
	        activitiesTable.Columns.Add("Activity", typeof (string));
	        activitiesTable.Columns.Add("TargetValue", typeof (string));
	        activitiesTable.Columns.Add("ProductionValue", typeof (string));
	        activitiesTable.Columns.Add("DefectionValue", typeof (string));
	        activitiesTable.Columns.Add("StoppageValue", typeof (string));
	        activitiesTable.Columns.Add("IsRework", typeof (string));

	        foreach (var item in Report.ActivityItems)
	        {
	            activitiesTable.Rows.Add(CurrentType == OEType.CountBased
	                ? new object[]
	                {
	                    item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, item.TargetCount, item.ProductionCount,
	                    item.DefectionCount, item.StoppageCount, item.IsRework
	                }
	                : new object[]
	                {
	                    item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, item.TargetTime, item.ProductionTime,
	                    item.DefectionTime, item.StoppageTime, item.IsRework
	                });
	        }

	        data.DataTables.Add(activitiesTable);

            var qualitiveTable = new DataTable("QualitiveReport");

            qualitiveTable.Columns.Add("Date", typeof(string));
            qualitiveTable.Columns.Add("Product", typeof(string));
            qualitiveTable.Columns.Add("Station", typeof(string));
            qualitiveTable.Columns.Add("Activity", typeof(string));
            qualitiveTable.Columns.Add("DefectionValue", typeof(string));
            qualitiveTable.Columns.Add("SecondGrade", typeof(string));
            qualitiveTable.Columns.Add("Waste", typeof(string));

            foreach (var item in Report.QualitiveItems)
            {
                var waste = item.Status == QualitiveStatus.Waste ? "*" : string.Empty;
                var secondGrade = item.Status == QualitiveStatus.SecondGrade ? "*" : string.Empty;
                var defection = CurrentType == OEType.CountBased ? item.DefectionCount : item.DefectionTime;
                qualitiveTable.Rows.Add(new object[]
                    {
                        item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, defection, secondGrade, waste
	                });
            }

            data.DataTables.Add(qualitiveTable);

            var technicalTable = new DataTable("TechnicalReport");

            technicalTable.Columns.Add("Date", typeof(string));
            technicalTable.Columns.Add("Product", typeof(string));
            technicalTable.Columns.Add("Station", typeof(string));
            technicalTable.Columns.Add("Activity", typeof(string));
            technicalTable.Columns.Add("StoppageValue", typeof(string));

            foreach (var item in Report.TechnicalItems)
            {
                var stoppage = CurrentType == OEType.CountBased ? item.StoppageCount : item.StoppageTime;
                technicalTable.Rows.Add(new object[]
                    {
                        item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, stoppage
	                });
            }

            data.DataTables.Add(technicalTable);


	        XpsDocument xps = reportDocument.CreateXpsDocument(data);

	        Document = xps.GetFixedDocumentSequence();
            
	    }
예제 #18
0
 public void AddPage(int docIndex, Uri source, Uri uri)
 {
     var rollUpFixedDocument = _documents[docIndex];
     TestForExistingPages(rollUpFixedDocument);
     rollUpFixedDocument.Pages.Add(new RollUpFixedPage(source, uri));
     _fixedDocumentSequence = null;
 }
예제 #19
0
 public void AddPage(int docIndex, FixedPage page)
 {
     var rollUpFixedDocument = _documents[docIndex];
     TestForExistingPages(rollUpFixedDocument);
     rollUpFixedDocument.Pages.Add(new RollUpFixedPage(page));
     _fixedDocumentSequence = null;
 }
예제 #20
0
 public void InsertPage(int docIndex, int insertAfterPageIndex, Uri source, Uri uri)
 {
     var rollUpFixedDocument = _documents[docIndex];
     TestForExistingPages(rollUpFixedDocument);
     rollUpFixedDocument.Pages.Insert(insertAfterPageIndex, new RollUpFixedPage(source, uri));
     _fixedDocumentSequence = null;
 }
예제 #21
0
        /// <summary>
        /// Implements the PDF file to XPS file conversion.
        /// </summary>
        public static void Convert(string xpsFilename, string pdfFilename, int docIndex, bool createComparisonDocument)
        {
            if (String.IsNullOrEmpty(xpsFilename))
            {
                throw new ArgumentNullException("xpsFilename");
            }

            if (String.IsNullOrEmpty(pdfFilename))
            {
                pdfFilename = xpsFilename;
                if (IOPath.HasExtension(pdfFilename))
                {
                    pdfFilename = pdfFilename.Substring(0, pdfFilename.LastIndexOf('.'));
                }
                pdfFilename += ".pdf";
            }

            XpsDocument xpsDocument = null;

            try
            {
                xpsDocument = XpsDocument.Open(xpsFilename);
                FixedDocument fixedDocument = xpsDocument.GetDocument();
                PdfDocument   pdfDocument   = new PdfDocument();
                PdfRenderer   renderer      = new PdfRenderer();

                int pageIndex = 0;
                foreach (FixedPage page in fixedDocument.Pages)
                {
                    if (page == null)
                    {
                        continue;
                    }
                    Debug.WriteLine(String.Format("  doc={0}, page={1}", docIndex, pageIndex));
                    PdfPage pdfPage = renderer.CreatePage(pdfDocument, page);
                    renderer.RenderPage(pdfPage, page);
                    pageIndex++;

#if DEBUG
                    // stop at page...
                    if (pageIndex == 50)
                    {
                        break;
                    }
#endif
                }
                pdfDocument.Save(pdfFilename);
                xpsDocument.Close();
                xpsDocument = null;

                if (createComparisonDocument)
                {
                    System.Windows.Xps.Packaging.XpsDocument       xpsDoc = new System.Windows.Xps.Packaging.XpsDocument(xpsFilename, FileAccess.Read);
                    System.Windows.Documents.FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();
                    if (docSeq == null)
                    {
                        throw new InvalidOperationException("docSeq");
                    }

                    XPdfForm    form = XPdfForm.FromFile(pdfFilename);
                    PdfDocument pdfComparisonDocument = new PdfDocument();


                    pageIndex = 0;
                    foreach (PdfPage page in pdfDocument.Pages)
                    {
                        if (page == null)
                        {
                            continue;
                        }
                        Debug.WriteLine(String.Format("  doc={0}, page={1}", docIndex, pageIndex));

                        PdfPage pdfPage = /*renderer.CreatePage(pdfComparisonDocument, page);*/ pdfComparisonDocument.AddPage();
                        double  width   = page.Width;
                        double  height  = page.Height;
                        pdfPage.Width  = page.Width * 2;
                        pdfPage.Height = page.Height;


                        DocumentPage docPage = docSeq.DocumentPaginator.GetPage(pageIndex);
                        //byte[] png = PngFromPage(docPage, 96);

                        BitmapSource bmsource = BitmapSourceFromPage(docPage, 96 * 2);
                        XImage       image    = XImage.FromBitmapSource(bmsource);

                        XGraphics gfx = XGraphics.FromPdfPage(pdfPage);
                        form.PageIndex = pageIndex;
                        gfx.DrawImage(form, 0, 0, width, height);
                        gfx.DrawImage(image, width, 0, width, height);

                        //renderer.RenderPage(pdfPage, page);
                        pageIndex++;

#if DEBUG
                        // stop at page...
                        if (pageIndex == 50)
                        {
                            break;
                        }
#endif
                    }

                    string pdfComparisonFilename = pdfFilename;
                    if (IOPath.HasExtension(pdfComparisonFilename))
                    {
                        pdfComparisonFilename = pdfComparisonFilename.Substring(0, pdfComparisonFilename.LastIndexOf('.'));
                    }
                    pdfComparisonFilename += "-comparison.pdf";

                    pdfComparisonDocument.ViewerPreferences.FitWindow = true;
                    //pdfComparisonDocument.PageMode = PdfPageMode.
                    pdfComparisonDocument.PageLayout = PdfPageLayout.SinglePage;
                    pdfComparisonDocument.Save(pdfComparisonFilename);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                if (xpsDocument != null)
                {
                    xpsDocument.Close();
                }
                throw;
            }
            finally
            {
                if (xpsDocument != null)
                {
                    xpsDocument.Close();
                }
            }
        }
예제 #22
0
 public void RemovePage(int docIndex, int pageIndex)
 {
     var rollUpFixedDocument = _documents[docIndex];
     TestForExistingPages(rollUpFixedDocument);
     rollUpFixedDocument.Pages.RemoveAt(pageIndex);
     _fixedDocumentSequence = null;
 }
예제 #23
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //ConvertWordDocToXPSDoc("H:\\资料\\客户端流程设计.doc");
            //Uri source = new Uri(@"http://www.jjgjt.com/download/1.xps");

            //FtpWeb fw = new FtpWeb("www.jjgjt.com:8889", @"xps/", "Huiyou", "huiyouhuiyou");

            //Stream stream=fw.DownloadStream("1.xps");
            //if (stream != null)
            //{
            //    System.IO.Packaging.Package package = System.IO.Packaging.Package.Open(stream,FileMode.Open);
            //    string memoryStreamUri = "memorystream://printstream";
            //    Uri packageUri = new Uri(memoryStreamUri);
            //    System.IO.Packaging.PackageStore.AddPackage(packageUri, package);

            //    XpsDocument xps = new XpsDocument(package,System.IO.Packaging.CompressionOption.SuperFast, memoryStreamUri);

            //string memoryStreamUri = "memorystream://printstream";
            //Uri packageUri = new Uri(memoryStreamUri);
            //MemoryStream ms=new MemoryStream(Properties.Resources._1);
            //System.IO.Packaging.Package package = System.IO.Packaging.Package.Open(ms,FileMode.Open);
            //System.IO.Packaging.PackageStore.AddPackage(packageUri, package);
            //foreach(System.IO.Packaging.PackagePart pp in package.GetParts())
            //{
            //    MessageBox.Show(pp.ContentType);
            //}
                FixedPage fp = new FixedPage();
                Label ll = new Label();
                ll.Content = "测试数据可以吗?" + Environment.NewLine + "回车换行可以吗?";
                ll.Margin = new Thickness(20, 40, 20, 40);
                fp.Children.Add(ll);
                fp.UpdateLayout();
                PageContent pc = new PageContent();
                ((System.Windows.Markup.IAddChild)pc).AddChild(fp);
                FixedDocument fd = new FixedDocument();
                fd.Pages.Add(pc);
                FixedDocumentSequence fds = new FixedDocumentSequence();
                ((System.Windows.Markup.IAddChild)fds).AddChild(fd);
            documentViewer1.Document=fds;

            //System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
            //foreach( System.Net.NetworkInformation.NetworkInterface ni in  nics )
            //{
            //    MessageBox.Show(ni.Description);
            //    System.Net.NetworkInformation.PhysicalAddress address = ni.GetPhysicalAddress();
            //    byte[] bytes = address.GetAddressBytes();
            //    StringBuilder sb=new StringBuilder();
            //    for (int i = 0; i < bytes.Length; i++)
            //    {
            //        sb.Append(bytes[i].ToString("X2"));
            //        if(i<bytes.Length-1)
            //            sb.Append("-");
            //    }
            //    MessageBox.Show(sb.ToString());
            //}
            //fd. = "1234";

            //}
            //else
            //    MessageBox.Show(FtpWeb.error);
        }
예제 #24
0
 private void ReCreateFixedDocumentSequence()
 {
     _fixedDocumentSequence = new FixedDocumentSequence();
     foreach (var document in _documents)
     {
         var documentReference = new DocumentReference();
         FillDocumentReference(documentReference, document);
         var fixedDocument = documentReference.GetDocument(true);
         _fixedDocumentSequence.References.Add(documentReference);
     }
 }
        //--------------------------------------------------------------------
        //
        // Ctors
        //
        //---------------------------------------------------------------------

        #region Ctors
        internal FixedDocumentSequenceDocumentPage(FixedDocumentSequence documentSequence, DynamicDocumentPaginator documentPaginator, DocumentPage documentPage)
            : base((documentPage is FixedDocumentPage) ? ((FixedDocumentPage)documentPage).FixedPage : documentPage.Visual, documentPage.Size, documentPage.BleedBox, documentPage.ContentBox)
        {
            Debug.Assert(documentSequence != null);
            Debug.Assert(documentPaginator != null);
            Debug.Assert(documentPage != null);
            _fixedDocumentSequence = documentSequence;
            _documentPaginator = documentPaginator;
            _documentPage = documentPage;
        }
예제 #26
0
 public int AddDocument(FixedDocument fixedDocument)
 {
     _documents.Add(new RollUpFixedDocument(fixedDocument));
     _fixedDocumentSequence = null;
     return DocumentCount - 1;
 }
예제 #27
0
 public override void Write(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket)
 {
     SerializeObjectTree(fixedDocumentSequence);
 }
예제 #28
0
 public int AddDocument(Uri source, Uri uri)
 {
     _documents.Add(new RollUpFixedDocument(source, uri));
     _fixedDocumentSequence = null;
     return DocumentCount - 1;
 }
예제 #29
0
 public override void WriteAsync(FixedDocumentSequence fixedDocumentSequence, PrintTicket printTicket,
     object userState)
 {
     throw new NotSupportedException();
 }
예제 #30
0
 public void InsertDocument(int insertAfterDocIndex, FixedDocument fixedDocument)
 {
     _documents.Insert(insertAfterDocIndex, new RollUpFixedDocument(fixedDocument));
     _fixedDocumentSequence = null;
 }
예제 #31
0
파일: gsprint.cs 프로젝트: surjit/mupdf-1
 /* Send it */
 private void PrintPages(XpsDocumentWriter xpsdw, FixedDocumentSequence fixdoc)
 {
     m_docWriter = xpsdw;
     xpsdw.WritingCompleted +=
         new WritingCompletedEventHandler(AsyncCompleted);
     xpsdw.WritingProgressChanged +=
         new WritingProgressChangedEventHandler(AsyncProgress);
     xpsdw.WriteAsync(fixdoc);
 }
예제 #32
0
 public void InsertDocument(int insertAfterDocIndex, Uri source, Uri uri)
 {
     _documents.Insert(insertAfterDocIndex, new RollUpFixedDocument(source, uri));
     _fixedDocumentSequence = null;
 }
 private void DoPrint(FixedDocumentSequence documemt)
 {
     PrintedDocument = documemt;
     OnPrintingFinished();
 }
        private FixedDocumentSequence CreateFixedDocumentSequence(IEnumerable<IEnumerable<string>> projects,
            Size areaExtent,
            Size areaOrigin,
            bool fixedStrokeThickness,
            DiagramTable table)
        {
            var fixedDocumentSeq = new FixedDocumentSequence() { Name = "diagrams" };

            foreach (var diagrams in projects)
            {
                var fixedDocument = CreateFixedDocument(diagrams,
                    areaExtent,
                    areaOrigin,
                    fixedStrokeThickness,
                    table);

                var documentRef = new DocumentReference();
                documentRef.BeginInit();
                documentRef.SetDocument(fixedDocument);
                documentRef.EndInit();

                (fixedDocumentSeq as IAddChild).AddChild(documentRef);
            }

            return fixedDocumentSeq;
        }