Ejemplo n.º 1
0
        private void _miFileLoadDataFromXML_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = string.Format("XML (*.xml)|*.xml");

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                PDFDocumentHelper.LoadFormsFieldsFromXML(dlg.FileName, _pdfDocument, _imageList);

                if (!PDFDocumentHelper.HasForms)
                {
                    MessageBox.Show("The XML file does not contain any forms data", "PDF Forms Demo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                PDFFormContolsHelper.SetPageControlsToCanvas(_imageList.ActiveItem as PDFPageItem, _imageViewer);

                _imageViewer.OnTransformChanged(e);
            }
        }
Ejemplo n.º 2
0
        private void LoadPDFFile(string fileName)
        {
            try
            {
                using (RasterCodecs codecs = new RasterCodecs())
                {
                    codecs.Options.RasterizeDocument.Load.XResolution = 300;
                    codecs.Options.RasterizeDocument.Load.YResolution = 300;
                    codecs.Options.Pdf.Load.HideFormFields            = true;

                    if (_pdfDocument != null)
                    {
                        _pdfDocument.Dispose();
                        _pdfDocument = null;
                    }

                    _pdfDocument = new PDFDocument(fileName);

                    PDFParseDocumentStructureOptions _parseDocumentStructOptions = PDFParseDocumentStructureOptions.InternalLinks | PDFParseDocumentStructureOptions.Bookmarks;

                    _pdfDocument.ParseDocumentStructure(_parseDocumentStructOptions);

                    PDFDocumentHelper.LoadPDFDocument(codecs, _pdfDocument, _imageList);

                    // Reset current page index value.
                    _currentPageIndex = 0;

                    _imageList.Items[_currentPageIndex].IsSelected = true;
                }
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex.Message);
            }
            finally
            {
                UpdateControls();
            }
        }