com.lowagie.text.pdf.PdfBoolean Java Examples

The following examples show how to use com.lowagie.text.pdf.PdfBoolean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PdfCollectionSort.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending	an array with every element corresponding with a name of a field.
 */
public void setSortOrder(boolean[] ascending) {
	PdfObject o = get(PdfName.S);
	if (o instanceof PdfArray) {
		if (((PdfArray)o).size() != ascending.length) {
			throw new IllegalArgumentException("The number of booleans in this array doesn't correspond with the number of fields.");
		}
		PdfArray array = new PdfArray();
		for (int i = 0; i < ascending.length; i++) {
			array.add(new PdfBoolean(ascending[i]));
		}
		put(PdfName.A, array);
	}
	else {
		throw new IllegalArgumentException("You need a single boolean for this collection sort dictionary.");
	}
}
 
Example #2
Source File: PdfCollectionSort.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending	an array with every element corresponding with a name of a field.
 */
public void setSortOrder(boolean[] ascending) {
	PdfObject o = get(PdfName.S);
	if (o instanceof PdfArray) {
		if (((PdfArray)o).size() != ascending.length) {
			throw new IllegalArgumentException("The number of booleans in this array doesn't correspond with the number of fields.");
		}
		PdfArray array = new PdfArray();
		for (int i = 0; i < ascending.length; i++) {
			array.add(new PdfBoolean(ascending[i]));
		}
		put(PdfName.A, array);
	}
	else {
		throw new IllegalArgumentException("You need a single boolean for this collection sort dictionary.");
	}
}
 
Example #3
Source File: PdfViewerPreferencesImp.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets the viewer preferences as the sum of several constants.
 * 
 * @param preferences
 *            the viewer preferences
 * @see PdfViewerPreferences#setViewerPreferences
 */
public void setViewerPreferences(int preferences) {
	this.pageLayoutAndMode |= preferences;
	// for backwards compatibility, it is also possible
	// to set the following viewer preferences with this method:
	if ((preferences & viewerPreferencesMask) != 0) {
		pageLayoutAndMode = ~viewerPreferencesMask & pageLayoutAndMode;
		if ((preferences & PdfWriter.HideToolbar) != 0)
			viewerPreferences.put(PdfName.HIDETOOLBAR, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.HideMenubar) != 0)
			viewerPreferences.put(PdfName.HIDEMENUBAR, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.HideWindowUI) != 0)
			viewerPreferences.put(PdfName.HIDEWINDOWUI, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.FitWindow) != 0)
			viewerPreferences.put(PdfName.FITWINDOW, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.CenterWindow) != 0)
			viewerPreferences.put(PdfName.CENTERWINDOW, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.DisplayDocTitle) != 0)
			viewerPreferences.put(PdfName.DISPLAYDOCTITLE, PdfBoolean.PDFTRUE);
		
		if ((preferences & PdfWriter.NonFullScreenPageModeUseNone) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USENONE);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseOutlines) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOUTLINES);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseThumbs) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USETHUMBS);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseOC) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOC);

		if ((preferences & PdfWriter.DirectionL2R) != 0)
			viewerPreferences.put(PdfName.DIRECTION, PdfName.L2R);
		else if ((preferences & PdfWriter.DirectionR2L) != 0)
			viewerPreferences.put(PdfName.DIRECTION, PdfName.R2L);

		if ((preferences & PdfWriter.PrintScalingNone) != 0)
			viewerPreferences.put(PdfName.PRINTSCALING, PdfName.NONE);			
	}
}
 
Example #4
Source File: PdfCollectionSort.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending	true is the default, use false for descending order
 */
public void setSortOrder(boolean ascending) {
	PdfObject o = get(PdfName.S);
	if (o instanceof PdfName) {
		put(PdfName.A, new PdfBoolean(ascending));
	}
	else {
		throw new IllegalArgumentException("You have to define a boolean array for this collection sort dictionary.");
	}
}
 
Example #5
Source File: PdfViewerPreferencesImp.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the viewer preferences as the sum of several constants.
 * 
 * @param preferences
 *            the viewer preferences
 * @see PdfViewerPreferences#setViewerPreferences
 */
public void setViewerPreferences(int preferences) {
	this.pageLayoutAndMode |= preferences;
	// for backwards compatibility, it is also possible
	// to set the following viewer preferences with this method:
	if ((preferences & viewerPreferencesMask) != 0) {
		pageLayoutAndMode = ~viewerPreferencesMask & pageLayoutAndMode;
		if ((preferences & PdfWriter.HideToolbar) != 0)
			viewerPreferences.put(PdfName.HIDETOOLBAR, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.HideMenubar) != 0)
			viewerPreferences.put(PdfName.HIDEMENUBAR, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.HideWindowUI) != 0)
			viewerPreferences.put(PdfName.HIDEWINDOWUI, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.FitWindow) != 0)
			viewerPreferences.put(PdfName.FITWINDOW, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.CenterWindow) != 0)
			viewerPreferences.put(PdfName.CENTERWINDOW, PdfBoolean.PDFTRUE);
		if ((preferences & PdfWriter.DisplayDocTitle) != 0)
			viewerPreferences.put(PdfName.DISPLAYDOCTITLE, PdfBoolean.PDFTRUE);
		
		if ((preferences & PdfWriter.NonFullScreenPageModeUseNone) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USENONE);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseOutlines) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOUTLINES);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseThumbs) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USETHUMBS);
		else if ((preferences & PdfWriter.NonFullScreenPageModeUseOC) != 0)
			viewerPreferences.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOC);

		if ((preferences & PdfWriter.DirectionL2R) != 0)
			viewerPreferences.put(PdfName.DIRECTION, PdfName.L2R);
		else if ((preferences & PdfWriter.DirectionR2L) != 0)
			viewerPreferences.put(PdfName.DIRECTION, PdfName.R2L);

		if ((preferences & PdfWriter.PrintScalingNone) != 0)
			viewerPreferences.put(PdfName.PRINTSCALING, PdfName.NONE);			
	}
}
 
Example #6
Source File: PdfCollectionSort.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Defines the sort order of the field (ascending or descending).
 * @param ascending	true is the default, use false for descending order
 */
public void setSortOrder(boolean ascending) {
	PdfObject o = get(PdfName.S);
	if (o instanceof PdfName) {
		put(PdfName.A, new PdfBoolean(ascending));
	}
	else {
		throw new IllegalArgumentException("You have to define a boolean array for this collection sort dictionary.");
	}
}
 
Example #7
Source File: PdfViewerPreferencesImp.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Sets the viewer preferences for printing.
 */
public void addViewerPreference(PdfName key, PdfObject value) {
	switch(getIndex(key)) {
	case 0: // HIDETOOLBAR
	case 1: // HIDEMENUBAR
	case 2: // HIDEWINDOWUI
	case 3: // FITWINDOW
	case 4: // CENTERWINDOW
	case 5: // DISPLAYDOCTITLE
	case 14: // PICKTRAYBYPDFSIZE
		if (value instanceof PdfBoolean) {
			viewerPreferences.put(key, value);
		}
		break;
	case 6: // NONFULLSCREENPAGEMODE
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, NONFULLSCREENPAGEMODE_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 7: // DIRECTION
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, DIRECTION_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 8:  // VIEWAREA
	case 9:  // VIEWCLIP
	case 10: // PRINTAREA
	case 11: // PRINTCLIP
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, PAGE_BOUNDARIES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 12: // PRINTSCALING
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, PRINTSCALING_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 13: // DUPLEX
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, DUPLEX_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 15: // PRINTPAGERANGE
		if (value instanceof PdfArray) {
			viewerPreferences.put(key, value);
		}
		break;
	case 16: // NUMCOPIES
		if (value instanceof PdfNumber)  {
			viewerPreferences.put(key, value);
		}
		break;
	}
}
 
Example #8
Source File: PdfViewerPreferencesImp.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Sets the viewer preferences for printing.
 */
public void addViewerPreference(PdfName key, PdfObject value) {
	switch(getIndex(key)) {
	case 0: // HIDETOOLBAR
	case 1: // HIDEMENUBAR
	case 2: // HIDEWINDOWUI
	case 3: // FITWINDOW
	case 4: // CENTERWINDOW
	case 5: // DISPLAYDOCTITLE
	case 14: // PICKTRAYBYPDFSIZE
		if (value instanceof PdfBoolean) {
			viewerPreferences.put(key, value);
		}
		break;
	case 6: // NONFULLSCREENPAGEMODE
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, NONFULLSCREENPAGEMODE_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 7: // DIRECTION
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, DIRECTION_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 8:  // VIEWAREA
	case 9:  // VIEWCLIP
	case 10: // PRINTAREA
	case 11: // PRINTCLIP
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, PAGE_BOUNDARIES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 12: // PRINTSCALING
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, PRINTSCALING_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 13: // DUPLEX
		if (value instanceof PdfName
				&& isPossibleValue((PdfName)value, DUPLEX_PREFERENCES)) {
			viewerPreferences.put(key, value);
		}
		break;
	case 15: // PRINTPAGERANGE
		if (value instanceof PdfArray) {
			viewerPreferences.put(key, value);
		}
		break;
	case 16: // NUMCOPIES
		if (value instanceof PdfNumber)  {
			viewerPreferences.put(key, value);
		}
		break;
	}
}
 
Example #9
Source File: PdfCollectionField.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Sets the initial visibility of the field.
 * @param visible	the default is true (visible)
 */
public void setVisible(boolean visible) {
	put(PdfName.V, new PdfBoolean(visible));
}
 
Example #10
Source File: PdfCollectionField.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Indication if the field value should be editable in the viewer.
 * @param editable	the default is false (not editable)
 */
public void setEditable(boolean editable) {
	put(PdfName.E, new PdfBoolean(editable));
}
 
Example #11
Source File: PdfCollectionField.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the initial visibility of the field.
 * @param visible	the default is true (visible)
 */
public void setVisible(boolean visible) {
	put(PdfName.V, new PdfBoolean(visible));
}
 
Example #12
Source File: PdfCollectionField.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Indication if the field value should be editable in the viewer.
 * @param editable	the default is false (not editable)
 */
public void setEditable(boolean editable) {
	put(PdfName.E, new PdfBoolean(editable));
}