|
Solid Framework Code SampleThis 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 filesUsing the Solid Framework ViewerPreferences objectYou 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. ![]()
In a PDF file, viewer preferences are located off the document's catalog as a Viewer Preferences dictionary: ![]()
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
| |||||||||||||||||||||||||||||||||||