public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir+ "input.pdf");

            //change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            //save output PDF file
            contentEditor.Save(dataDir+ "output.pdf");
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "input.pdf");

            //change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            //save output PDF file
            contentEditor.Save(dataDir + "output.pdf");
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
            //open document
            PdfContentEditor contentEditor = new PdfContentEditor();

            contentEditor.BindPdf(dataDir + "SetViewerPreference.pdf");

            //change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            //save output PDF file
            contentEditor.Save(dataDir + "SetViewerPreference_out.pdf");
        }
        public static void Run()
        {
            // ExStart:SetViewerPreference
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
            // Open document
            PdfContentEditor contentEditor = new PdfContentEditor();
            contentEditor.BindPdf(dataDir + "SetViewerPreference.pdf");

            // Change Viewer Preferences
            contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
            contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
            contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);

            // Save output PDF file
            contentEditor.Save(dataDir+ "SetViewerPreference_out.pdf");
            // ExEnd:SetViewerPreference            
        }
 /// <summary>
 /// Sets the PDF to be showing the Bookmarks pane (document outline) on document open.
 /// </summary>
 /// <param name="pdf">PDF byte array</param>
 /// <returns>PDF byte array</returns>
 private static byte[] setShowBookmarksPaneOnOpen(byte[] pdf)
 {
     using (var tmpPdf = new MemoryStream(pdf)) {
         var pce = new PdfContentEditor();
         pce.BindPdf(tmpPdf);
         pce.ChangeViewerPreference(ViewerPreference.PageModeUseOutlines);
         using (var saveStream = new MemoryStream()) {
             pce.Save(saveStream);
             return(saveStream.ToArray());
         }
     }
 }
Exemple #6
0
        public static void SetPrintDlgPropertiesUsingPdfContentEditor()
        {
            //ExStart:SetPrintDlgPropertiesUsingPdfContentEditor
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            string outputFile = dataDir + "input.pdf";

            using (PdfContentEditor ed = new PdfContentEditor())
            {
                ed.BindPdf(outputFile);
                if ((ed.GetViewerPreference() & ViewerPreference.DuplexFlipShortEdge) > 0)
                {
                    Console.WriteLine("The file has duplex flip short edge");
                }

                ed.ChangeViewerPreference(ViewerPreference.DuplexFlipShortEdge);
                ed.Save(dataDir + "SetPrintDlgPropertiesUsingPdfContentEditor_out.pdf");
            }
            //ExEnd: SetPrintDlgPropertiesUsingPdfContentEditor
        }
 /// <summary>
 /// Sets the PDF to be showing the Bookmarks pane (document outline) on document open.
 /// </summary>
 /// <param name="pdf">PDF byte array</param>
 /// <returns>PDF byte array</returns>
 private static byte[] setShowBookmarksPaneOnOpen( byte[] pdf )
 {
     using( var tmpPdf = new MemoryStream( pdf ) ) {
         var pce = new PdfContentEditor();
         pce.BindPdf( tmpPdf );
         pce.ChangeViewerPreference( ViewerPreference.PageModeUseOutlines );
         using( var saveStream = new MemoryStream() ) {
             pce.Save( saveStream );
             return saveStream.ToArray();
         }
     }
 }