コード例 #1
0
        public void OnSerialize(PDFXEdit.IOperation op)
        {
            if (op == null)
            {
                return;
            }

            PDFXEdit.ICabNode opts = op.Params.Root["Options"];

            PDFXEdit.ICabNode pagesRange = opts["PagesRange"];
            pagesRange["Type"].v = PDFXEdit.RangeType.RangeType_Exact;
            pagesRange["Text"].v = tPages.Text;

            opts["OpenFolder"].v = ckOpenFolder.Checked;

            string action = "AllToOneFile";

            if (cbExportMode.SelectedIndex == 1)
            {
                action = "EachToFile";
            }
            else if (cbExportMode.SelectedIndex == 2)
            {
                action = "EachRangeToFile";
            }
            opts["ExtractPagesAction"].v = action;
        }
コード例 #2
0
        public void OnSerialize(PDFXEdit.IOperation op)
        {
            if (op == null)
            {
                return;
            }

            PDFXEdit.ICabNode opts = op.Params.Root["Options"];

            opts["Text"].v = tText.Text;

            Color clrText = btnTextClr.BackColor;

            opts["Font.FColor"].v = String.Format("rgbd({0},{1},{2})", clrText.R, clrText.G, clrText.B);
            opts["Opacity"].v     = (double)tOpacity.Value;

            opts["Rotation"].v         = tRotation.Value;
            opts["UseRelativeScale"].v = true;
            opts["RelativeScale"].v    = 100.0;

            // pages range
            PDFXEdit.ICabNode  pagesRange = opts["PagesRange"];
            PDFXEdit.RangeType rangeType  = PDFXEdit.RangeType.RangeType_All;
            if (rbCurPage.Checked)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Current;
            }
            else if (rbPages.Checked)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Exact;
            }
            pagesRange["Type"].v = rangeType;
            pagesRange["Text"].v = tPages.Text;
        }
コード例 #3
0
        public void OnSerialize(PDFXEdit.IOperation op)
        {
            if (op == null)
            {
                return;
            }

            PDFXEdit.ICabNode opts = op.Params.Root["Options"];

            // src
            opts["Src"].v = mainFrm.fsInst.DefaultFileSys.StringToName(tSrcToOpen.Text);

            // src pages range
            PDFXEdit.ICabNode  pagesRange = opts["PagesRange"];
            PDFXEdit.RangeType rangeType  = PDFXEdit.RangeType.RangeType_All;
            if (rbPages.Checked)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Exact;
            }
            pagesRange["Type"].v = rangeType;
            pagesRange["Text"].v = tPages.Text;

            // dest
            opts["Location"].v = "Before";
            opts["Position"].v = (int)tDestPos.Value - 1;
        }
コード例 #4
0
        public void ExtractDocToTiff(object obj)
        {
            try
            {
                stData data = (stData)obj;

                var importCV                    = FindNeededImportConverter(Path.GetExtension(data.sDoc));
                PDFXEdit.IAFS_Name name         = m_fsInst.DefaultFileSys.StringToName(data.sDoc);
                int openFileFlags               = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead);
                PDFXEdit.IAFS_File     destFile = m_fsInst.DefaultFileSys.OpenFile(name, openFileFlags);
                PDFXEdit.IPXC_Document Doc      = importCV.Convert(m_Inst, destFile);

                //PDFXEdit.IPXC_Document Doc = m_pxcInst.OpenDocumentFromFile(data.sDoc, null);
                PDFXEdit.IOperation Op    = m_Inst.CreateOp(m_nID);
                PDFXEdit.ICabNode   input = Op.Params.Root["Input"];
                input.Add().v             = Doc;
                PDFXEdit.ICabNode options = Op.Params.Root["Options"];
                options["PagesRange.Type"].v  = "All";
                options["DestFolder"].v       = data.sFolder;           //Output folder
                options["ExportMode"].v       = "AllToMutliPage";
                options["Zoom"].v             = 150;
                options["ShowResultFolder"].v = data.bLast;                 //We'll show the result folder only when we'll work with last doc
                //Saving as tiff
                PDFXEdit.ICabNode fmtParams = options["FormatParams"];
                //Compression type
                fmtParams["COMP"].v = 5;                 //LZW compression
                //X DPI
                fmtParams["DPIX"].v = 150;
                //Y DPI
                fmtParams["DPIY"].v = 150;
                //Image format
                fmtParams["FMT"].v = PDFXEdit.IXC_ImageFileFormatIDs.FMT_TIFF_ID; //TIFF
                //Image type
                fmtParams["ITYP"].v = 16;                                         //24 TrueColor
                //Use Predictor
                fmtParams["PRED"].v = 1;                                          //Yes
                //Thumbnail
                fmtParams["ITYP"].v = 0;                                          //No
                Op.Do();
                Doc.Close();
                m_nSavedFilesCount++;
                if (m_nSavedFilesCount == m_aFiles.Count)
                {
                    MessageBox.Show("Export completed");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: mashinc/PDFEditorSDKExamples
 public void ExtractDocToTiff(object obj)
 {
     try
     {
         stData data = (stData)obj;
         PDFXEdit.IPXC_Document Doc   = m_pxcInst.OpenDocumentFromFile(data.sDoc, null);
         PDFXEdit.IOperation    Op    = m_Inst.CreateOp(m_nID);
         PDFXEdit.ICabNode      input = Op.Params.Root["Input"];
         input.Add().v             = Doc;
         PDFXEdit.ICabNode options = Op.Params.Root["Options"];
         options["PagesRange.Type"].v  = "All";
         options["DestFolder"].v       = data.sFolder;           //Output folder
         options["ExportMode"].v       = "AllToMutliPage";
         options["Zoom"].v             = 150;
         options["ShowResultFolder"].v = data.bLast;                 //We'll show the result folder only when we'll work with last doc
         //Saving as tiff
         PDFXEdit.ICabNode fmtParams = options["FormatParams"];
         //Compression type
         fmtParams["COMP"].v = 5;                 //LZW compression
         //X DPI
         fmtParams["DPIX"].v = 150;
         //Y DPI
         fmtParams["DPIY"].v = 150;
         //Image format
         fmtParams["FMT"].v = 1414088262;         //TIFF
         //Image type
         fmtParams["ITYP"].v = 16;                //24 TrueColor
         //Use Predictor
         fmtParams["PRED"].v = 1;                 //Yes
         //Thumbnail
         fmtParams["ITYP"].v = 0;                 //No
         Op.Do();
         Doc.Close();
         m_nSavedFilesCount++;
         if (m_nSavedFilesCount == m_aFiles.Count)
         {
             MessageBox.Show("Export completed");
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #6
0
        public virtual bool Run(MainFrm mainFrm, bool bShowOpDlg, bool bAllowOpUI)
        {
            PDFXEdit.IOperation op = null;
            try
            {
                op = mainFrm.pdfCtl.Inst.CreateOp(ID);
            }
            catch
            {
                return(false);
            }

            if (op == null)
            {
                return(false);
            }

            Form ui = UI;

            if (ui != null)
            {
                IFormHelper hlp = (IFormHelper)ui;
                if (hlp != null)
                {
                    hlp.OnSerialize(op);
                }
            }

            uint flags = Flags;

            if ((flags & (uint)DemoFlags.Input_Doc) != 0)
            {
                PDFXEdit.IPXV_Document doc = mainFrm.pdfCtl.Doc;
                if (doc == null)
                {
                    return(false);
                }
                PDFXEdit.ICabNode input = op.Params.Root["Input"];
                if (input.Type == PDFXEdit.CabDataTypeID.dt_Array)
                {
                    input.Add().v = doc;
                }
                else
                {
                    input.v = doc;
                }
            }
            else if (!bShowOpDlg && ((flags & (uint)DemoFlags.Input_Mask) != 0))
            {
                string fileFilter = "";
                if ((flags & (uint)DemoFlags.Input_AllSupp) != 0)
                {
                    fileFilter = "<allSupp>";
                }
                else if ((flags & (uint)DemoFlags.Input_AllSuppImg) != 0)
                {
                    fileFilter = "<allSuppImg>";
                }
                else if ((flags & (uint)DemoFlags.Input_AllSuppRasterImg) != 0)
                {
                    fileFilter = "<allSuppRasterImg>";
                }
                else if ((flags & (uint)DemoFlags.Input_PdfFile) != 0)
                {
                    fileFilter = "PDF Documents (*.pdf)|*.pdf";
                }
                else if ((flags & (uint)DemoFlags.Input_TxtFile) != 0)
                {
                    fileFilter = "Plain Text Documents (*.txt)|*.txt";
                }
                else if ((flags & (uint)DemoFlags.Input_RtfFile) != 0)
                {
                    fileFilter = "RTF Files (*.rtf)|*.rtf";
                }

                PDFXEdit.IAFS_NamesCollection fileNames = mainFrm.ShowOpenFilesDlg((flags & (uint)DemoFlags.Input_MultFiles) != 0, fileFilter);
                if (fileNames == null || (fileNames.Count == 0))
                {
                    return(false);
                }

                PDFXEdit.ICabNode input = op.Params.Root["Input"];
                if (input.Type == PDFXEdit.CabDataTypeID.dt_Array)
                {
                    for (uint i = 0; i < fileNames.Count; i++)
                    {
                        input.Add().v = fileNames[i];
                    }
                }
                else
                {
                    input.v = fileNames[0];
                }
            }

            if (bShowOpDlg)
            {
                try
                {
                    op.ShowSetupUI((uint)mainFrm.Handle);
                }
                catch (Exception ex)
                {
                    int hr = Marshal.GetHRForException(ex);
                    if (hr != HResults.E_NOTIMPL)
                    {
                        return(false);
                    }
                }
            }

            if (!OnBeforeRun(mainFrm, op))
            {
                return(false);
            }


            int opExecFlags = 0;

            if (!bAllowOpUI)
            {
                opExecFlags |= (int)PDFXEdit.OpExecFlags.OpExecFlag_NoUI;
            }

            try
            {
                if ((flags & (int)DemoFlags.SyncDo) != 0)
                {
                    op.Do(opExecFlags);
                }
                else
                {
                    mainFrm.pdfCtl.Inst.AsyncDoAndWaitForFinish(op, (uint)opExecFlags);
                }
            }
            catch (Exception ex)
            {
                int hr = Marshal.GetHRForException(ex);
                mainFrm.ShowErrMsg(hr);

                return(false);
            }

            if ((flags & (int)DemoFlags.Output_Doc) != 0)
            {
                PDFXEdit.ICabNode      output     = op.Params.Root["Output"];
                PDFXEdit.IPXC_Document newCoreDoc = null;
                try
                {
                    if (output.Type == PDFXEdit.CabDataTypeID.dt_Array)
                    {
                        if (output.Count != 0)
                        {
                            newCoreDoc = (PDFXEdit.IPXC_Document)output[0].Unknown;
                        }
                    }
                    else
                    {
                        newCoreDoc = (PDFXEdit.IPXC_Document)output.Unknown;
                    }

                    if (newCoreDoc != null)
                    {
                        mainFrm.pdfCtl.OpenDocFrom(newCoreDoc);
                    }
                }
                catch { }
            }

            return(true);
        }
コード例 #7
0
 public virtual bool OnBeforeRun(MainFrm mainFrm, PDFXEdit.IOperation op)
 {
     return(true);
 }
コード例 #8
0
        public void OnSerialize(PDFXEdit.IOperation op)
        {
            if (op == null)
            {
                return;
            }

            PDFXEdit.ICabNode opts = op.Params.Root["Options"];

            // printer opts
            opts["PrinterName"].v = cbPrinter.Text;
            bool ok;

            opts["Copies"].v  = (int)MainFrm.Str2Num(tCopies.Text, out ok, 1);
            opts["Collate"].v = ckCollate.Checked ? 1 : 0;
            opts["Duplex"].v  = cbDuplex.SelectedIndex;

            opts["Collate"].v = ckCollate.Checked ? 1 : 0;

            opts["AsImages"].v = ckAsImage.Checked;

            opts["Paper.Name"].v = "A4";

            // pages range
            PDFXEdit.ICabNode  pagesRange = opts["PagesRange"];
            PDFXEdit.RangeType rangeType  = PDFXEdit.RangeType.RangeType_All;
            if (rbCurPage.Checked)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Current;
            }
            else if (rbPages.Checked)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Exact;
            }
            pagesRange["Type"].v     = rangeType;
            pagesRange["Text"].v     = tPages.Text;
            pagesRange["Reversed"].v = ckPagesRevOrder.Checked;

            rangeType = PDFXEdit.RangeType.RangeType_All;
            if (cbPagesSubset.SelectedIndex == 1)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Odd;
            }
            else if (cbPagesSubset.SelectedIndex != 0)
            {
                rangeType = PDFXEdit.RangeType.RangeType_Even;
            }
            pagesRange["Filter"].v = rangeType;

            MainFrm.ComboboxItem it = (MainFrm.ComboboxItem)cbPrintDocFilter.SelectedItem;
            if (it != null)
            {
                opts["Content"].v = it.Value;
            }

            // page scaling and placement
            opts["ScaleType"].String = ((MainFrm.ComboboxItem2)cbPagesScale.SelectedItem).Value;
            opts["ScaleType"].v      = cbPagesScale.SelectedIndex;

            opts["ColorOverride"].v = cbClrOver.Text;
//			opts["ColorOverride"].v = cbClrOver.SelectedIndex;


            if (rbSheets.Checked)
            {
                opts["SheetsRange.Text"].v = tSheets.Text;
            }
        }