예제 #1
0
 /** Sets the open and close page additional action.
 * @param actionType the action type. It can be <CODE>PdfWriter.PAGE_OPEN</CODE>
 * or <CODE>PdfWriter.PAGE_CLOSE</CODE>
 * @param action the action to perform
 * @throws PdfException if the action type is invalid
 */
 public virtual void SetPageAction(PdfName actionType, PdfAction action)
 {
     if (!actionType.Equals(PAGE_OPEN) && !actionType.Equals(PAGE_CLOSE))
         throw new PdfException("Invalid page additional action type: " + actionType.ToString());
     pdf.SetPageAction(actionType, action);
 }
예제 #2
0
 protected static PdfAnnotation CreateLink(PdfWriter writer, Rectangle rect, PdfName highlight)
 {
     PdfAnnotation annot = new PdfAnnotation(writer, rect);
     annot.Put(PdfName.SUBTYPE, PdfName.LINK);
     if (!highlight.Equals(HIGHLIGHT_INVERT))
         annot.Put(PdfName.H, highlight);
     return annot;
 }
예제 #3
0
 /** Additional-actions defining the actions to be taken in
 * response to various trigger events affecting the document
 * as a whole. The actions types allowed are: <CODE>DOCUMENT_CLOSE</CODE>,
 * <CODE>WILL_SAVE</CODE>, <CODE>DID_SAVE</CODE>, <CODE>WILL_PRINT</CODE>
 * and <CODE>DID_PRINT</CODE>.
 *
 * @param actionType the action type
 * @param action the action to execute in response to the trigger
 * @throws PdfException on invalid action type
 */
 public virtual void SetAdditionalAction(PdfName actionType, PdfAction action)
 {
     if (!(actionType.Equals(DOCUMENT_CLOSE) ||
     actionType.Equals(WILL_SAVE) ||
     actionType.Equals(DID_SAVE) ||
     actionType.Equals(WILL_PRINT) ||
     actionType.Equals(DID_PRINT))) {
         throw new PdfException("Invalid additional action type: " + actionType.ToString());
     }
     pdf.AddAdditionalAction(actionType, action);
 }
예제 #4
0
 public void SetMKIconFit(PdfName scale, PdfName scalingType, float leftoverLeft, float leftoverBottom, bool fitInBounds)
 {
     PdfDictionary dic = new PdfDictionary();
     if (!scale.Equals(PdfName.A))
         dic.Put(PdfName.SW, scale);
     if (!scalingType.Equals(PdfName.P))
         dic.Put(PdfName.S, scalingType);
     if (leftoverLeft != 0.5f || leftoverBottom != 0.5f) {
         PdfArray array = new PdfArray(new PdfNumber(leftoverLeft));
         array.Add(new PdfNumber(leftoverBottom));
         dic.Put(PdfName.A, array);
     }
     if (fitInBounds)
         dic.Put(PdfName.FB, PdfBoolean.PDFTRUE);
     MK.Put(PdfName.IF, dic);
 }
예제 #5
0
 /**
 * Sets the annotation's highlighting mode. The values can be
 * <CODE>HIGHLIGHT_NONE</CODE>, <CODE>HIGHLIGHT_INVERT</CODE>,
 * <CODE>HIGHLIGHT_OUTLINE</CODE> and <CODE>HIGHLIGHT_PUSH</CODE>;
 * @param highlight the annotation's highlighting mode
 */
 public void SetHighlighting(PdfName highlight)
 {
     if (highlight.Equals(HIGHLIGHT_INVERT))
         Remove(PdfName.H);
     else
         Put(PdfName.H, highlight);
 }
예제 #6
0
 public void SetWidget(Rectangle rect, PdfName highlight)
 {
     Put(PdfName.TYPE, PdfName.ANNOT);
     Put(PdfName.SUBTYPE, PdfName.WIDGET);
     Put(PdfName.RECT, new PdfRectangle(rect));
     annotation = true;
     if (highlight != null && !highlight.Equals(HIGHLIGHT_INVERT))
         Put(PdfName.H, highlight);
 }
예제 #7
0
 /** Additional-actions defining the actions to be taken in
 * response to various trigger events affecting the document
 * as a whole. The actions types allowed are: <CODE>DOCUMENT_CLOSE</CODE>,
 * <CODE>WILL_SAVE</CODE>, <CODE>DID_SAVE</CODE>, <CODE>WILL_PRINT</CODE>
 * and <CODE>DID_PRINT</CODE>.
 *
 * @param actionType the action type
 * @param action the action to execute in response to the trigger
 * @throws PdfException on invalid action type
 */
 public override void SetAdditionalAction(PdfName actionType, PdfAction action)
 {
     if (!(actionType.Equals(DOCUMENT_CLOSE) ||
     actionType.Equals(WILL_SAVE) ||
     actionType.Equals(DID_SAVE) ||
     actionType.Equals(WILL_PRINT) ||
     actionType.Equals(DID_PRINT))) {
         throw new PdfException("Invalid additional action type: " + actionType.ToString());
     }
     PdfDictionary aa = reader.Catalog.GetAsDict(PdfName.AA);
     if (aa == null) {
         if (action == null)
             return;
         aa = new PdfDictionary();
         reader.Catalog.Put(PdfName.AA, aa);
     }
     MarkUsed(aa);
     if (action == null)
         aa.Remove(actionType);
     else
         aa.Put(actionType, action);
 }
예제 #8
0
 /**
 * Sets the open and close page additional action.
 * @param actionType the action type. It can be <CODE>PdfWriter.PAGE_OPEN</CODE>
 * or <CODE>PdfWriter.PAGE_CLOSE</CODE>
 * @param action the action to perform
 * @param page the page where the action will be applied. The first page is 1
 * @throws PdfException if the action type is invalid
 */
 internal void SetPageAction(PdfName actionType, PdfAction action, int page)
 {
     if (!actionType.Equals(PAGE_OPEN) && !actionType.Equals(PAGE_CLOSE))
         throw new PdfException("Invalid page additional action type: " + actionType.ToString());
     PdfDictionary pg = reader.GetPageN(page);
     PdfDictionary aa = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.AA), pg);
     if (aa == null) {
         aa = new PdfDictionary();
         pg.Put(PdfName.AA, aa);
         MarkUsed(pg);
     }
     aa.Put(actionType, action);
     MarkUsed(aa);
 }