我正在尝试使用Java中的PDFBox库创建pdf。我必须用渐变创建矩形,但我不知道怎么做,也找不到任何东西。任何人都可以帮我吗?
答案 0 :(得分:0)
找到这个例子。看看它是否适合你
{%- block form_start -%}
{% spaceless %}
{% set method = method|upper %}
{%- if method in ["GET", "POST"] -%}
{% set form_method = method %}
{%- else -%}
{% set form_method = "POST" %}
{%- endif -%}
{% set attr = attr|merge({'class': (attr.class|default('form-horizontal'))|trim }) %}
<form
name="{{ name }}" method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}"/>
{%- endif -%}
{% endspaceless %}
{%- endblock form_start -%}
{% block form_row %}
{% spaceless %}
<div class="form-group row{{ errors|length > 0 ? ' has-error':'' }}">
{{ form_label(form) }}
<div class="col-10">
{{ form_widget(form) }}
{{ form_errors(form) }}
</div>
</div>
{% endspaceless %}
{% endblock form_row %}
{# Labels #}
{%- block form_label -%}
{% spaceless %}
{% if label is not same as(false) -%}
{% if not compound -%}
{% set label_attr = label_attr|merge({'for': id}) %}
{%- endif -%}
{% if required -%}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
{%- endif -%}
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' col-sm-2 col-form-label')|trim }) %}
{% if label is empty -%}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{%- endif -%}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</label>
{%- endif -%}
{% endspaceless %}
{%- endblock form_label -%}
{# Widgets #}
{%- block form_widget_simple -%}
{% spaceless %}
{%- set type = type|default('text') -%}
{% if type != 'file' %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
{% endif %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endspaceless %}
{%- endblock form_widget_simple -%}
{%- block textarea_widget -%}
{% spaceless %}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{% endspaceless %}
{%- endblock textarea_widget -%}
{%- block choice_widget_collapsed -%}
{% spaceless %}
{%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%}
{% set required = false %}
{%- endif -%}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' form-control')|trim }) %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{%- if placeholder is not none -%}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder != '' ? (translation_domain is same as(false) ? placeholder : placeholder|trans({}, translation_domain)) }}</option>
{%- endif -%}
{%- if preferred_choices|length > 0 -%}
{% set options = preferred_choices %}
{{- block('choice_widget_options') -}}
{%- if choices|length > 0 and separator is not none -%}
<option disabled="disabled">{{ separator }}</option>
{%- endif -%}
{%- endif -%}
{%- set options = choices -%}
{{- block('choice_widget_options') -}}
</select>
{% endspaceless %}
{%- endblock choice_widget_collapsed -%}
{%- block choice_widget_expanded -%}
{% spaceless %}
{%- for child in form %}
<div class="checkbox">
<label>
{{- form_widget(child) -}}
{{- form_label(child, null, {translation_domain: choice_translation_domain}) -}}
</label>
</div>
{% endfor -%}
{% endspaceless %}
{%- endblock choice_widget_expanded -%}
{% block form_errors %}
{% spaceless %}
{% for error in errors %}
<span class="help-block">{{ error.message }}</span>
{% endfor %}
{% endspaceless %}
{% endblock form_errors %}
{% block button_row %}
{% spaceless %}
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">
{{ form_widget(form) }}
</div>
</div>
{% endspaceless %}
{% endblock button_row %}
{%- block button_widget -%}
{%- if label is empty -%}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{%- endif -%}
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' btn')|trim }) %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</button>
{%- endblock button_widget -%}
{% block submit_widget %}
{% spaceless %}
{% set type = type|default('submit') %}
{% set attr = attr|merge({'class': (attr.class|default('btn btn-primary'))|trim }) %}
{{ block('button_widget') }}
{% endspaceless %}
{% endblock submit_widget %}