コード例 #1
0
function CreateGroup2($doc, $layer)
{
    $writer = new ElementWriter();
    $writer->Begin($doc->GetSDFDoc());
    // Create a path object in the shape of a heart.
    $builder = new ElementBuilder();
    $builder->PathBegin();
    // start constructing the path
    $builder->MoveTo(306, 396);
    $builder->CurveTo(681, 771, 399.75, 864.75, 306, 771);
    $builder->CurveTo(212.25, 864.75, -69, 771, 306, 396);
    $builder->ClosePath();
    $element = $builder->PathEnd();
    // the path geometry is now specified.
    // Set the path FILL color space and color.
    $element->SetPathFill(true);
    $gstate = $element->GetGState();
    $gstate->SetFillColorSpace(ColorSpace::CreateDeviceCMYK());
    $gstate->SetFillColor(new ColorPt(1.0, 0.0, 0.0, 0.0));
    // cyan
    // Set the path STROKE color space and color.
    $element->SetPathStroke(true);
    $gstate->SetStrokeColorSpace(ColorSpace::CreateDeviceRGB());
    $gstate->SetStrokeColor(new ColorPt(1.0, 0.0, 0.0));
    // red
    $gstate->SetLineWidth(20);
    $gstate->SetTransform(0.5, 0.0, 0.0, 0.5, 280.0, 300.0);
    $writer->WriteElement($element);
    $grp_obj = $writer->End();
    // Indicate that this form (content group) belongs to the given layer (OCG).
    $grp_obj->PutName("Subtype", "Form");
    $grp_obj->Put("OC", $layer);
    $grp_obj->PutRect("BBox", 0, 0, 1000, 1000);
    // Set the clip box for the content.
    return $grp_obj;
}
コード例 #2
0
$writer->Begin($page);
// begin writing to this page
$builder->Reset();
// Reset the GState to default
// Write some transparent text at the bottom of the page.
$element = $builder->CreateTextBegin(Font::Create($doc->GetSDFDoc(), Font::e_times_roman), 100.0);
// Set the text knockout attribute. Text knockout must be set outside of
// the text group.
$gstate = $element->GetGState();
$gstate->SetTextKnockout(false);
$gstate->SetBlendMode(GState::e_bl_difference);
$writer->WriteElement($element);
$element = $builder->CreateTextRun("Transparency");
$element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 30.0, 30.0);
$gstate = $element->GetGState();
$gstate->SetFillColorSpace(ColorSpace::CreateDeviceCMYK());
$gstate->SetFillColor(new ColorPt(1.0, 0.0, 0.0, 0.0));
$gstate->SetFillOpacity(0.5);
$writer->WriteElement($element);
// Write the same text on top the old; shifted by 3 points
$element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 33.0, 33.0);
$gstate->SetFillColor(new ColorPt(0.0, 1.0, 0.0, 0.0));
$gstate->SetFillOpacity(0.5);
$writer->WriteElement($element);
$writer->WriteElement($builder->CreateTextEnd());
// Draw three overlapping transparent circles.
$builder->PathBegin();
// start constructing the path
$builder->MoveTo(459.223, 505.646);
$builder->CurveTo(459.223, 415.841, 389.85, 343.04, 304.273, 343.04);
$builder->CurveTo(218.697, 343.04, 149.324, 415.841, 149.324, 505.646);