Image Viewer CP Pro SDK ActiveX

Image Viewer CP Pro SDK ActiveX

Platform : Windows 10, Windows 8, Vista, Windows 7, XP

It is a PDF Viewer and Document Viewer SDK , Export to PDF ,Image processing, 1D and 2D Barcode Reader, Writer, DICOM and OCR with C#, C , VB.NET , VB, Delphi, Vfp, MS Access.

Popular Solution Go   Back

C# - How to create a Chinese searchable PDF file using C#

Step 1: To install the Image Viewer CP Pro ActiveX Control, begin by launching the setup file (http://www.viscomsoft.com/demo/imageviewercpprosetup.exe). Select the desired installation folder for the Image Viewer CP Pro ActiveX and continue with the installation on your development computer.

Step 2: Create New Visual C# Project, select Windows Forms Application. 
 

 Step 3: The next step is to install Image Viewer CP Pro ActiveX in ToolBox. Select Toolbox, select Components item, right click mouse button, select Choose Items...

 
 Step 4: Select COM Components tab, select Image Viewer CP Pro ActiveX Control , click OK. 
 

Step 5: From the Toolbox, add the Image Viewer CP Pro ActiveX control to the design surface.
 

 

Step 6:  Add three button, two RadioButton , one textbox in form with the following code. 
 

 private void buttonSelectImage_Click(object sender, EventArgs e)

        {   this.openFileDialog1.Filter = "All Files (*.*)|*.*|PDF (*.pdf)|*.pdf|PhotoShop (*.psd)|*.psd|JPEG 2000 (*.j2k)|*.j2k;*.j2c|JPEG (*.jpg)|*.jpg|PCX (*.pcx)|*.pcx|WMF (*.wmf)|*.wmf|Wireless Bitmap (*.wbmp)|*.wbmp|Bitmap (*.bmp)|*.bmp|TIF (*.tif)|*.tif|TGA (*.tga)|*.tga|Gif (*.gif)|*.gif |PGX (*.pgx)|*.pgx|RAS (*.ras)|*.ras|PNM (*.pnm)|*.pnm|PNG (*.png)|*.png|Icon (*.ico)|*.ico";

            if (this.openFileDialog1.ShowDialog(this) == DialogResult.OK)

            {

                this.axImageViewer1.FileName = openFileDialog1.FileName;

                this.axImageViewer1.MouseTrackMode = SCRIBBLELib.MOUSE_TRACKMODE.NoSelectionRectMode;

            }

        }

 

        private void buttonSelFontFile_Click(object sender, EventArgs e)

        {

            openFileDialog1.Filter = "True type font(*.TTF file)|*.ttf";

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)

            {

                txtfontfile.Text = openFileDialog1.FileName;

            }

        }

 

        private void buttonConvert_Click(object sender, EventArgs e)

        {

            if (this.axImageViewer1.FileName == "")

            {

                MessageBox.Show("Please select image first");
               return;

            }

            axImageViewer1.OCRScanTextAsync(true);

 

            short ilangindex = 0;

 

            if (radioLang1.Checked)
               ilangindex = 0;
           else

            {

                ilangindex = 7;

                axImageViewer1.OCR2SearchablePDFFontFile = txtfontfile.Text;

            }

 

            if(txtfontfile.Text == "" && ilangindex == 7)

            {

                MessageBox.Show("Please select unicode font file");

                return;

            }

 

            axImageViewer1.OCRCharFilter = "";

            axImageViewer1.OCRSetRect(0, 0, 0, 0);

            axImageViewer1.OCRRecognizeMode = 2;

            short iresult;

            this.saveFileDialog1.Filter = "PDF File (*.pdf)|*.pdf";

            if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)

            {
                   iresult = axImageViewer1.OCR2SearchableMultipagePDF(saveFileDialog1.FileName, ilangindex, "dictfiles");

            }

 

        } 

Step 7:  You may download the sample chinese image file from http://www.viscomsoft.com/doc/imageviewercppro/chinese simplified sample.zip
unzip it and run the sample, select this image.

Step 8:  Selected  Chinese (Simplified)

Step 9:  In Font File Name, click select button, because your pdf document need display chinese. you need select unicode font file.
e.g. Arial Unicode Ms Font.
If you do not want to select font file, you may call OCR2SearchablePDFFontFile property to select chinese font name in your computer.

Step 10: When  OCRScanTextAsync(true), it will fire OCRPDFA event. In OCRPDFA event, add the following code 

 private void axImageViewer1_OCRPDFA(object sender, AxSCRIBBLELib._DImageViewerEvents_OCRPDFAEvent e)

        {

            if(e.iProgress==100)
           MessageBox.Show("Save Completed");

        }

Step 11: After converted to PDF file, open the converted PDF with adobe reader. You may selected the text, right click the mouse, select the Copy. then open the Notepad,  press Ctrl V to paste the texts.


Step 12: Download the sample source code from http://www.viscomsoft.com/doc/imageviewercppro/ocr-chinese-pdfa.zip