Пример #1
0
        /// <summary>
        ///     Once PDFToImage button clicked, will convert PDF to image
        ///     for selected format
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PDFToImageButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                bool           result         = false;

                if (openFileDialog.ShowDialog() == true)
                {
                    if (PDFToPNG.IsChecked == true)
                    {
                        result = ImagesAndPDFHelper.PDFToImage(openFileDialog, ImageFormat.Png);
                    }
                    else if (PDFToJPEG.IsChecked == true)
                    {
                        result = ImagesAndPDFHelper.PDFToImage(openFileDialog, ImageFormat.Jpeg);
                    }
                    else if (PDFToGIF.IsChecked == true)
                    {
                        result = ImagesAndPDFHelper.PDFToImage(openFileDialog, ImageFormat.Gif);
                    }
                    else if (PDFToTIFF.IsChecked == true)
                    {
                        result = ImagesAndPDFHelper.PDFToImage(openFileDialog, ImageFormat.Tiff);
                    }
                    else
                    {
                        result = ImagesAndPDFHelper.PDFToImage(openFileDialog, ImageFormat.Bmp);
                    }
                }

                if (result)
                {
                    MessageBox.Show("Succesfully converted PDF to image");
                }
                else
                {
                    MessageBox.Show("Could not convert PDF to image");
                }
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error occured: {ex.Message}");
                Close();
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImageToPDF_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = true;
            bool result = false;

            if (openFileDialog.ShowDialog() == true)
            {
                result = ImagesAndPDFHelper.ImageToPDF(openFileDialog);
            }

            if (result)
            {
                MessageBox.Show("Image succesfully converted to PDF!");
            }
            else
            {
                MessageBox.Show("Image could not be converted to PDF, formats supported are JPEG, PNG, and GIF.");
            }
        }