Produtos de Desktop :

Automação de Processos :

Desenvolvimento de Software:

Conversor de PDF para Word Clientes

Solid Framework - Amostra de Código

Este é um exemplo conciso para ajudar instalar e executar Solid Framework.Já foi testado com a Licença de Desenvolvedor Livre para Solid Framework utilizando diferentes versões do Visual Studio da Microsoft.

Render PDF Page Image

The code below shows you how to render a PDF page image to a Picture Box control on a form.

Render PDF Page Image

Clique para executar o Vídeo/Tutorial

Steps to Render a PDF Page Image

  1. Import the trial Developer License:

    License.Import(new StreamReader(@"C:\Users\Joe\license.xml"));

  2. Locate the PDF files using OpenFileDialog:

    License.Import(new StreamReader(@"C:\Users\Joe\license.xml"));

  3. Define 2 variables to manage navigation of pages and 1 for a PdfDocument Object:

    int currentPage;
    IList<PdfPage> pages;
    PdfDocument document;

  4. Create an OpenFileDialog that manages selection of files:

    OpenFileDialog OpFile = new OpenFileDialog();
    //show only PDF Files
    OpFile.Filter = "PDF Files (*.pdf)|*.pdf";

    if (OpFile.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

  5. Create a new PdfDocument Object:

    //Create a new PDFDocument object add the selected file.
    document = new PdfDocument();
    document.Path = OpFile.FileName;

    //Open the selected file

    //Set the current page to 0
    currentPage = 0;

    // GetPages() traverses the PDF page tree so you really only want to do it once
    pages = document.GetPages();

    //Update the thumbnail area with whatever the current page is.

  6. Create a UpdateThumbnail Method to manage User Interaction with the form:

    private void UpdateThumbnail(int index)
    if ((index >= 0) && (index < pages.Count))
      currentPage = index;

    //Only enable the buttons if there is a page to go to
    previous.Enabled = currentPage > 0;
    next.Enabled = currentPage < pages.Count - 1;

    //Call Invalidate to capture when the image changes


  7. Define the page navigation when the user clicks on the buttons:

     private void previous_Click(object sender, EventArgs e)
       UpdateThumbnail(currentPage - 1);

     private void next_Click(object sender, EventArgs e)
       UpdateThumbnail(currentPage + 1);


  8. Set up the Picture Box to display an image of the page that is selected:

    if (pages != null)
      PdfPage page = pages[currentPage];
      // draw PDF page to bitmap in real time at 40 dpi
      Bitmap bitmap = page.DrawBitmap(40);

    // 40 dpi works because pages are typically 8.5 x 11 inches and our pictureBox is 512 x 512
    // 8.5 * 40 = 340 pixels
    // 11 * 40 = 440 pixels
    // both of these are less than 512


  9. Create keyboard shortcut keys for the next and previous button:

    switch (e.KeyCode)
      case Keys.PageUp:
      UpdateThumbnail(currentPage + 1); // next

      case Keys.PageDown:
      UpdateThumbnail(currentPage - 1); // previous

      case Keys.Home:
      UpdateThumbnail(0); // first

      case Keys.End:
      UpdateThumbnail(pages.Count - 1); // last



Mapa do site
©2000-2018 Solid Documents Limited - Todos os direitos reservados.