Package org.pdfclown.documents.contents.xObjects

Examples of org.pdfclown.documents.contents.xObjects.FormXObject


  public static FormXObject createTemplate(
    Document document
    )
  {
    // Create a template (form)!
    FormXObject template = new FormXObject(document);

    // Size.
    template.setSize(document.getPageSize());
    Dimension2D templateSize = template.getSize();

    PrimitiveComposer composer = new PrimitiveComposer(template);

    Image image = null;
    try
View Full Code Here


  @Override
  public XObject toXObject(
    Document context
    )
  {
    FormXObject xObject = new FormXObject(context);
    {
      xObject.setSize(getSize());
      PrimitiveComposer composer = new PrimitiveComposer(xObject);
      toInlineObject(composer);
      composer.flush();
    }
    return xObject;
View Full Code Here

      Appearance appearance = widget.getAppearance();
      if(appearance == null)
      {widget.setAppearance(appearance = new Appearance(document));}

      AppearanceStates normalAppearance = appearance.getNormal();
      FormXObject onState = new FormXObject(document);
      normalAppearance.put(PdfName.Yes,onState);

//TODO:verify!!!
//   appearance.getRollover().put(PdfName.Yes,onState);
//   appearance.getDown().put(PdfName.Yes,onState);
//   appearance.getRollover().put(PdfName.Off,offState);
//   appearance.getDown().put(PdfName.Off,offState);

      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      Rectangle2D frame = new Rectangle2D.Double(0,0,size.getWidth(),size.getHeight());
      {
        onState.setSize(size);

        PrimitiveComposer composer = new PrimitiveComposer(onState);

        composer.beginLocalState();
        composer.setFillColor(getBackColor());
        composer.setStrokeColor(getForeColor());
        composer.drawRectangle(frame);
        composer.fillStroke();
        composer.end();

        BlockComposer blockComposer = new BlockComposer(composer);
        blockComposer.begin(frame,AlignmentXEnum.Center,AlignmentYEnum.Middle);
        composer.setFillColor(getForeColor());
        composer.setFont(
          new StandardType1Font(
            document,
            StandardType1Font.FamilyEnum.ZapfDingbats,
            true,
            false
            ),
          (float)(size.getHeight() * 0.8)
          );
        blockComposer.showText(new String(new char[]{getCheckSymbol()}));
        blockComposer.end();

        composer.flush();
      }

      FormXObject offState = new FormXObject(document);
      normalAppearance.put(PdfName.Off,offState);
      {
        offState.setSize(size);

        PrimitiveComposer composer = new PrimitiveComposer(offState);

        composer.beginLocalState();
        composer.setFillColor(getBackColor());
View Full Code Here

      Appearance appearance = widget.getAppearance();
      if(appearance == null)
      {widget.setAppearance(appearance = new Appearance(document));}

      AppearanceStates normalAppearance = appearance.getNormal();
      FormXObject onState = normalAppearance.get(new PdfName(((DualWidget)widget).getWidgetName()));

//TODO:verify!!!
//   appearance.getRollover().put(new PdfName(...),onState);
//   appearance.getDown().put(new PdfName(...),onState);
//   appearance.getRollover().put(PdfName.Off,offState);
//   appearance.getDown().put(PdfName.Off,offState);

      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      Rectangle2D frame = new Rectangle2D.Double(1,1,size.getWidth()-2,size.getHeight()-2);
      {
        onState.setSize(size);

        PrimitiveComposer composer = new PrimitiveComposer(onState);

        composer.beginLocalState();
        composer.setFillColor(getBackColor());
        composer.setStrokeColor(getForeColor());
        composer.drawEllipse(frame);
        composer.fillStroke();
        composer.end();

        BlockComposer blockComposer = new BlockComposer(composer);
        blockComposer.begin(frame,AlignmentXEnum.Center,AlignmentYEnum.Middle);
        composer.setFillColor(getForeColor());
        composer.setFont(
          new StandardType1Font(
            document,
            StandardType1Font.FamilyEnum.ZapfDingbats,
            true,
            false
            ),
          (float)(size.getHeight() * 0.8)
          );
        blockComposer.showText(new String(new char[]{getRadioSymbol()}));
        blockComposer.end();

        composer.flush();
      }

      FormXObject offState = new FormXObject(document);
      normalAppearance.put(PdfName.Off,offState);
      {
        offState.setSize(size);

        PrimitiveComposer composer = new PrimitiveComposer(offState);

        composer.beginLocalState();
        composer.setFillColor(getBackColor());
View Full Code Here

    Appearance appearance = widget.getAppearance();
    if(appearance == null)
    {widget.setAppearance(appearance = new Appearance(document));}

    FormXObject normalAppearanceState = new FormXObject(document);
    {
      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      normalAppearanceState.setSize(size);
      PrimitiveComposer composer = new PrimitiveComposer(normalAppearanceState);

      composer.beginLocalState();
      float lineWidth = 1;
      composer.setLineWidth(lineWidth);
View Full Code Here

    widget.getBaseDataObject().put(
      PdfName.DA,
      new PdfString("/Helv " + getFontSize() + " Tf 0 0 0 rg")
      );

    FormXObject normalAppearanceState = new FormXObject(document);
    {
      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      normalAppearanceState.setSize(size);
      PrimitiveComposer composer = new PrimitiveComposer(normalAppearanceState);

      composer.beginLocalState();
      float lineWidth = 1;
      composer.setLineWidth(lineWidth);
View Full Code Here

    widget.getBaseDataObject().put(
      PdfName.DA,
      new PdfString("/Helv " + getFontSize() + " Tf 0 0 0 rg")
      );

    FormXObject normalAppearanceState = new FormXObject(document);
    {
      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      normalAppearanceState.setSize(size);
      PrimitiveComposer composer = new PrimitiveComposer(normalAppearanceState);

      composer.beginLocalState();
      float lineWidth = 1;
      composer.setLineWidth(lineWidth);
View Full Code Here

          }
          )
        );
    }

    FormXObject normalAppearanceState = new FormXObject(document);
    {
      Rectangle2D widgetBox = widget.getBox();
      Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
      normalAppearanceState.setSize(size);
      PrimitiveComposer composer = new PrimitiveComposer(normalAppearanceState);

      composer.beginLocalState();
      float lineWidth = 1;
      composer.setLineWidth(lineWidth);
View Full Code Here

    }

    Document document = file.getDocument();

    // 2. Create a watermark (form)!
    FormXObject watermark = createWatermark(document);

    // 3. Apply the watermark to the pages of the document!
    applyWatermark(watermark);

    // (boilerplate metadata insertion -- ignore it)
View Full Code Here

  private FormXObject createWatermark(
    Document document
    )
  {
    // 1. Create a new external form object to represent the watermark!
    FormXObject watermark = new FormXObject(document);
    // Size.
    Dimension2D size = document.getSize();
    watermark.setSize(size);

    // 2. Inserting the contents of the watermark...
    // 2.1. Create a content composer for the watermark!
    PrimitiveComposer composer = new PrimitiveComposer(watermark);
    // 2.2. Inserting the contents...
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.xObjects.FormXObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.