Desktop Products:

Process Automation:

Software Development:

 
PDF to Word Converter Customers
 
Receive our Newsletter
 
 

Solid Framework Code Sample

This is a concise sample to help get Solid Framework up and running. It has been tested with the Free Developer License of Solid Framework using different versions of Microsoft's Visual Studio. For version specific instructions:

    Read and modify Viewer Preferences in PDF files

    Using the Solid Framework ViewerPreferences object

    You access the viewer preferences object by calling SolidFramework.Pdf.ViewerPreferences.Create static method with SolidFramework.Pdf.PdfDocument.Catalog as the paramater. SolidFramework.Pdf.PdfDocument is the document object that you already opened.

    viewersettings_sample.png

     

    In a PDF file, viewer preferences are located off the document's catalog as a Viewer Preferences dictionary:

    viewersettings_sample_2.png

     

    In the sample application, we use the ViewerPreferences object to display and modify the document preferences from the Document Properties dialog as seen below:



    internal void InitViewControls()
    {
      _preferences = SolidFramework.Pdf.ViewerPreferences.Create
                   ((SolidFramework.Pdf.Catalog)_document.Catalog);
      SolidFramework.Pdf.Catalog cat = (SolidFramework.Pdf.Catalog)
                                     SolidFramework.Pdf.Catalog.Create(_document);

      if (_preferences != null)
      {
        _properties.CenterWindow = cbCenter.Checked = _preferences.CenterWindow;
        _properties.HideMenubar = cbHideMenu.Checked = _preferences.HideMenuBar;
        _properties.HideToolbar = cbHideTools.Checked = _preferences.HideToolBar;
        _properties.HideWindowUI = cbHideControls.Checked = _preferences.HideWindowUI;
        _properties.FitWindow = cbResizeToInitial.Checked = _preferences.FitWindow;
      }
      
      _properties.PageMode = cat.PageMode;
      switch (_properties.PageMode)
      {
        case SolidFramework.Pdf.PageMode.UseOutlines:
          comboDisplay.SelectedIndex = 2;
          break;
        case SolidFramework.Pdf.PageMode.UseThumbs:
          comboDisplay.SelectedIndex = 1;
          break;
        default:
          comboDisplay.SelectedIndex = 0;
          break;
      }

      _properties.PageLayout = cat.PageLayout;
      switch (_properties.PageLayout)
      {
        case SolidFramework.Pdf.PageLayout.SinglePage:
          comboLayout.SelectedIndex = 0;
          break;
        case SolidFramework.Pdf.PageLayout.OneColumn:
          comboLayout.SelectedIndex = 1;
          break;
        case SolidFramework.Pdf.PageLayout.TwoColumnLeft:
        case SolidFramework.Pdf.PageLayout.TwoPageLeft:
          comboLayout.SelectedIndex = 2;
          break;
        case SolidFramework.Pdf.PageLayout.TwoColumnRight:
        case SolidFramework.Pdf.PageLayout.TwoPageRight:
          comboLayout.SelectedIndex = 3;
          break;
      }
    }

    In the InitViewControls function we assign the form fields and _properties object to the values in the ViewerPreferences object. The _properties object is just a class with booleans that we use to copy what is currently in the document to handle the Cancel button on the form. If the OK button is selected, we compare the booleans in the _properties object to the document preference values, and if they are different, we assign the new values back into the document ViewerPreferences object. This will set the IsModified Boolean to true on the PdfDocument that we can later check to see if we need to save the document.

    Steps for using the ViewerPreferences object

    1. Create a new PDFDocument object.

        PDFDocument document = new PDFDocument();

       
    2. Set the path of the PDF File to open.

        document.Path = @"Full path and filename";

       
    3. Open the document.

       document.Open();

       
    4. Get the ViewerPreferences object

       SolidFramework.Pdf.ViewerPreferences preferences =
         SolidFramework.Pdf.ViewerPreferences.Create((SolidFramework.Pdf.Catalog)
         document.Catalog);

       
    5. Assign or read any of the ViewerPreferences values.

        bool bCenterWindow = preferences.CenterWindow;
        preferences.FitWindow = true;

       
    6. If the document has been modified, save it.

       if (document.IsModified)
       {
         document.Save(SolidFramework.Plumbing.OverwriteMode.ForceOverwrite);
       }

       

     


    Site Map
    ©2000-2013 Solid Documents Limited - All Rights Reserved