Example #1
0
        public void OpenFile(string fileName)
        {
            int nID = Inst.Str2ID("op.openDoc", false);

            PDFXEdit.IOperation Op     = Inst.CreateOp(nID);
            PDFXEdit.IAFS_Inst  fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
            PDFXEdit.IAFS_Name  name   = fsInst.DefaultFileSys.StringToName(fileName);
            var input = Op.Params.Root["Input"];

            input.v = name;
            PDFXEdit.ICabNode options = Op.Params.Root["Options"];
            options["NativeOnly"].v = true;
            Op.Do();

            m_doc?.Close();
            m_doc = null;
            m_doc = (PDFXEdit.IPXC_Document)Op.Params.Root["Output"].v;
            OpenFile(m_doc);
        }
Example #2
0
        private void Redraw_PDF()
        {
            ProgressBar1 prBar = new ProgressBar1();

            try
            {
                prBar.Show();
                prBar.Refresh();
                int Rect_size_for_20 = page_Width / 22;
                if (workspace_ob.op.orientation_of_document == 0)
                {
                    Rect_size = (page_Width) / (workspace_ob.field_ex.width + 2);
                }
                else
                {
                    Rect_size = (page_Height) / (workspace_ob.field_ex.heigth + 2);
                }
                height     = workspace_ob.field_ex.heigth;
                width      = workspace_ob.field_ex.width;
                keys_count = workspace_ob.keys.Count;

                int nID = axPXV_Control1.Inst.Str2ID("op.document.insertEmptyPages", false); //Create new "InsertEmptyPages" operation iD
                PDFXEdit.IOperation pOp   = axPXV_Control1.Inst.CreateOp(nID);               //Create new operation
                PDFXEdit.ICabNode   input = pOp.Params.Root["Input"];                        //Create "Input" id to current operation
                IPXC_Document       pDoc  = axPXV_Control1.Doc.CoreDoc;

                input.v = pDoc;                                         //Specify that working with current document
                PDFXEdit.ICabNode options = pOp.Params.Root["Options"]; //Create "Option" id to current operation
                options["PaperType"].v = 2;                             //Apply custom paper type

                if (workspace_ob.op.orientation_of_document == 0)
                {
                    options["Width"].v  = 800;
                    options["Height"].v = 1200;
                }
                else
                {
                    options["Width"].v  = 1200;
                    options["Height"].v = 800;
                }
                pOp.Do();                                                               //Applying creation new pages
                nID     = axPXV_Control1.Inst.Str2ID("op.document.deletePages", false); //Create new "deletePages" operation id
                pOp     = axPXV_Control1.Inst.CreateOp(nID);                            //Create new operation
                input   = pOp.Params.Root["Input"];                                     //Create "Input" id to current operation
                input.v = pDoc;                                                         //Specify that working with current document
                options = pOp.Params.Root["Options"];                                   //Create "Option" id to current operation
                options["PagesRange.Custom"].v = 0;                                     //Specify range of deleting pages. In this case it is just one zeroth page
                pOp.Do();                                                               //Applying deletion range of pages

                var page = axPXV_Control1.Doc.CoreDoc.Pages[0];                         //Create handler to first page
                var CC   = axPXV_Control1.Doc.CoreDoc.CreateContentCreator();           //Create "Content Creator" for drawing on page.

                if (workspace_ob.op.orientation_of_document == 0)
                {
                    Redraw_field_vertical(width, height, CC, page);
                    Draw_Keys_Vartical(ref CC, ref page);
                }
                else if (workspace_ob.op.orientation_of_document == 1)
                {
                    Redraw_field_horisontal(width, height, CC, page);
                    Draw_Keys_Horisontal(ref CC, ref page);
                }
                CC.SetLineWidth(0.5); //Set line  width
                CC.StrokePath(true);  //Set end of drawing current element

                nID     = axPXV_Control1.Inst.Str2ID("op.document.resizePages", false);
                pOp     = axPXV_Control1.Inst.CreateOp(nID);
                input   = pOp.Params.Root["Input"];
                input.v = pDoc;
                options = pOp.Params.Root["Options"];
                options["PaperType"].v             = 2; //Document values table
                options["StdPaperIndex"].v         = 4; //A2
                options["ScalePage"].v             = true;
                options["ConstraintProportions"].v = true;
                options["PagesRange.Filter"].v     = 1;
                if (workspace_ob.op.orientation_of_document == 1)
                {
                    options["Width"].v  = 841.89;
                    options["Height"].v = 595.276;
                }
                pOp.Do();
                prBar.Hide();
                prBar.Refresh();
            }
            catch
            {
                MessageBox.Show("Generate PDF again.");
                prBar.Hide();
                prBar.Refresh();
                return;
            }
            prBar.Hide();
            prBar.Refresh();
        }