当前位置: 首页>>代码示例>>PHP>>正文


PHP Font::Create方法代码示例

本文整理汇总了PHP中Font::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP Font::Create方法的具体用法?PHP Font::Create怎么用?PHP Font::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Font的用法示例。


在下文中一共展示了Font::Create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CreateButtonAppearance

function CreateButtonAppearance($doc, $button_down)
{
    // Create a button appearance stream ------------------------------------
    $build = new ElementBuilder();
    $writer = new ElementWriter();
    $writer->Begin($doc->GetSDFDoc());
    // Draw background
    $element = $build->CreateRect(0, 0, 101, 37);
    $element->SetPathFill(true);
    $element->SetPathStroke(false);
    $element->GetGState()->SetFillColorSpace(ColorSpace::CreateDeviceGray());
    $element->GetGState()->SetFillColor(new ColorPt(0.75, 0.0, 0.0));
    $writer->WriteElement($element);
    // Draw 'Submit' text
    $writer->WriteElement($build->CreateTextBegin());
    $text = "Submit";
    $element = $build->CreateTextRun($text, Font::Create($doc->GetSDFDoc(), Font::e_helvetica_bold), 12.0);
    $element->GetGState()->SetFillColor(new ColorPt(0.0, 0.0, 0.0));
    if ($button_down) {
        $element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 33.0, 10.0);
    } else {
        $element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 30.0, 13.0);
    }
    $writer->WriteElement($element);
    $writer->WriteElement($build->CreateTextEnd());
    $stm = $writer->End();
    // Set the bounding box
    $stm->PutRect("BBox", 0, 0, 101, 37);
    $stm->PutName("Subtype", "Form");
    return $stm;
}
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:31,代码来源:InteractiveFormsTest.php

示例2: AddCoverPage

function AddCoverPage($doc)
{
    // Here we dynamically generate cover page (please see ElementBuilder
    // sample for more extensive coverage of PDF creation API).
    $page = $doc->PageCreate(new Rect(0.0, 0.0, 200.0, 200.0));
    $builder = new ElementBuilder();
    $writer = new ElementWriter();
    $writer->Begin($page);
    $font = Font::Create($doc->GetSDFDoc(), Font::e_helvetica);
    $writer->WriteElement($builder->CreateTextBegin($font, 12.0));
    $element = $builder->CreateTextRun("My PDF Collection");
    $element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 50.0, 96.0);
    $element->GetGState()->SetFillColorSpace(ColorSpace::CreateDeviceRGB());
    $element->GetGState()->SetFillColor(new ColorPt(1.0, 0.0, 0.0));
    $writer->WriteElement($element);
    $writer->WriteElement($builder->CreateTextEnd());
    $writer->End();
    $doc->PagePushBack($page);
    // Alternatively we could import a PDF page from a template PDF document
    // (for an example please see PDFPage sample project).
    // ...
}
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:22,代码来源:PDFPackageTest.php

示例3: CreateTestAnnots

function CreateTestAnnots($doc)
{
    $ew = new ElementWriter();
    $eb = new ElementBuilder();
    $first_page = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $doc->PagePushBack($first_page);
    $ew->Begin($first_page, ElementWriter::e_overlay, false);
    // begin writing to this page
    $ew->End();
    // save changes to the current page
    //
    // Test of a free text annotation.
    //
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(10.0, 400.0, 160.0, 570.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetQuaddingFormat(0);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(100.0, 100.0, 350.0, 500.0));
    $txtannot->SetContentRect(new Rect(200.0, 200.0, 350.0, 500.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetCalloutLinePoints(new Point(200.0, 300.0), new Point(150.0, 290.0), new Point(110.0, 110.0));
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetEndingStyle(LineAnnot::e_ClosedArrow);
    $txtannot->SetColor(new ColorPt(0.0, 1.0, 0.0));
    $txtannot->SetQuaddingFormat(1);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(400.0, 10.0, 550.0, 400.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetColor(new ColorPt(0.0, 0.0, 1.0));
    $txtannot->SetOpacity(0.2);
    $txtannot->SetQuaddingFormat(2);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $page = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $doc->PagePushBack($page);
    $ew->Begin($page, ElementWriter::e_overlay, false);
    // begin writing to this page
    $eb->Reset();
    // Reset the GState to default
    $ew->End();
    // save changes to the current page
    //Create a Line annotation...
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(250.0, 250.0, 400.0, 400.0));
    $line->SetStartPoint(new Point(350.0, 270.0));
    $line->SetEndPoint(new Point(260.0, 370.0));
    $line->SetStartStyle(LineAnnot::e_Square);
    $line->SetEndStyle(LineAnnot::e_Circle);
    $line->SetColor(new ColorPt(0.3, 0.5, 0.0), 3);
    $line->SetContents("Dashed Captioned");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->SetBorderStyle(new BorderStyle(BorderStyle::e_dashed, 2.0, 0.0, 0.0, array(2.0, 2.0)));
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(347.0, 377.0, 600.0, 600.0));
    $line->SetStartPoint(new Point(385.0, 410.0));
    $line->SetEndPoint(new Point(540.0, 555.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_OpenArrow);
    $line->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $line->SetContents("Inline Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Inline);
    $line->SetLeaderLineExtensionLength(-4.0);
    $line->SetLeaderLineLength(-12.0);
    $line->SetLeaderLineOffset(2.0);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(10.0, 400.0, 200.0, 600.0));
    $line->SetStartPoint(new Point(25.0, 426.0));
    $line->SetEndPoint(new Point(180.0, 555.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_Square);
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetInteriorColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $line->SetContents("Offset Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->SetTextHOffset(-60);
    $line->SetTextVOffset(10);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(200.0, 10.0, 400.0, 70.0));
    $line->SetStartPoint(new Point(220.0, 25.0));
    $line->SetEndPoint(new Point(370.0, 60.0));
    $line->SetStartStyle(LineAnnot::e_Butt);
    $line->SetEndStyle(LineAnnot::e_OpenArrow);
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetContents("Regular Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(200.0, 70.0, 400.0, 130.0));
    $line->SetStartPoint(new Point(220.0, 111.0));
//.........这里部分代码省略.........
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:101,代码来源:AnnotationTest.php

示例4: CreateGroup3

function CreateGroup3($doc, $layer)
{
    $writer = new ElementWriter();
    $writer->Begin($doc->GetSDFDoc());
    // Create a path object in the shape of a heart.
    $builder = new ElementBuilder();
    // Begin writing a block of text
    $element = $builder->CreateTextBegin(Font::Create($doc->GetSDFDoc(), Font::e_times_roman), 120.0);
    $writer->WriteElement($element);
    $element = $builder->CreateTextRun("A text layer!");
    // Rotate text 45 degrees, than translate 180 pts horizontally and 100 pts vertically.
    $transform = Matrix2D::RotationMatrix(-45 * (3.1415 / 180.0));
    $transform->Concat(1, 0, 0, 1, 180, 100);
    $element->SetTextMatrix($transform);
    $writer->WriteElement($element);
    $writer->WriteElement($builder->CreateTextEnd());
    $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;
}
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:24,代码来源:PDFLayersTest.php

示例5: Matrix2D

$enc->PushBackName("Lossy");
$img = Image::Create($doc->GetSDFDoc(), $input_path . "multipage.tif");
$element = $builder->CreateImage($img, new Matrix2D(612.0, 0.0, 0.0, 794.0, 0.0, 0.0));
$writer->WritePlacedElement($element);
$writer->End();
// Save the page
$doc->PagePushBack($page);
// Add the page to the document page sequence
// ----------------------------------------------------------
// Add a JPEG2000 (JP2) image to the output file
// Create a new page
$page = $doc->PageCreate();
$writer->Begin($page);
// Begin writing to the page
// Embed the image
$img = Image::Create($doc->GetSDFDoc(), $input_path . "palm.jp2");
// Position the image on the page
$element = $builder->CreateImage($img, new Matrix2D((double) $img->GetImageWidth(), 0.0, 0.0, (double) $img->GetImageHeight(), 96.0, 80.0));
$writer->WritePlacedElement($element);
// Write 'JPEG2000 Sample' text string under the image
$writer->WriteElement($builder->CreateTextBegin(Font::Create($doc->GetSDFDoc(), Font::e_times_roman), 32.0));
$element = $builder->CreateTextRun("JPEG2000 Sample");
$element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 190.0, 30.0);
$writer->WriteElement($element);
$writer->WriteElement($builder->CreateTextEnd());
$writer->End();
// Finish writing to the page
$doc->PagePushBack($page);
$doc->Save($output_path . "addimage.pdf", SDFDoc::e_linearized);
$doc->Close();
echo nl2br("Done. Result saved in addimage.pdf...\n");
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:31,代码来源:AddImageTest.php

示例6: PageSet

$s->SetPosition(10.0, 10.0);
$img = Image::Create($doc->GetSDFDoc(), $input_path . "peppers.jpg");
$ps = new PageSet(1, $doc->GetPageCount(), PageSet::e_all);
$s->StampImage($doc, $img, $ps);
$doc->Save($output_path . $input_filename . ".ex7.pdf", SDFDoc::e_linearized);
$doc->Close();
//--------------------------------------------------------------------------------
// Example 8) Add Text stamp to first 2 pages, and image stamp to first page.
//          Because text stamp is set as background, the image is top of the text
//          stamp. Text stamp on the first page is not visible.
$doc = new PDFDoc($input_path . $input_filename);
$doc->InitSecurityHandler();
$s = new Stamper(Stamper::e_relative_scale, 0.07000000000000001, -0.1);
$s->SetAlignment(Stamper::e_horizontal_right, Stamper::e_vertical_bottom);
$s->SetAlignment(Stamper::e_horizontal_center, Stamper::e_vertical_top);
$s->SetFont(Font::Create($doc->GetSDFDoc(), Font::e_courier, true));
$red = new ColorPt(1.0, 0.0, 0.0, 0.0);
$s->SetFontColor($red);
//set color to red
$s->SetTextAlignment(Stamper::e_align_right);
$s->SetAsBackground(true);
//set text stamp as background
$ps = new PageSet(1, 2);
$s->StampText($doc, "This is a title!", $ps);
$img = Image::Create($doc->GetSDFDoc(), $input_path . "peppers.jpg");
$s->SetAsBackground(false);
// set image stamp as foreground
$first_page_ps = new PageSet(1);
$s->StampImage($doc, $img, $first_page_ps);
$doc->Save($output_path . $input_filename . ".ex8.pdf", SDFDoc::e_linearized);
$doc->Close();
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:31,代码来源:StamperTest.php

示例7: PDFDoc

    $domain = $function->PutArray("Domain");
    $domain->PushBackNumber(0);
    $domain->PushBackNumber(1);
    $function->PutNumber("FunctionType", 2);
    $function->PutNumber("N", 1);
    return $pattern_dict;
}
//---------------------------------------------------------------------------------------
PDFNet::Initialize();
$doc = new PDFDoc();
$writer = new ElementWriter();
$builder = new ElementBuilder();
// The following sample illustrates how to create and use tiling patterns
$page = $doc->PageCreate();
$writer->Begin($page);
$element = $builder->CreateTextBegin(Font::Create($doc->GetSDFDoc(), Font::e_times_bold), 1.0);
$writer->WriteElement($element);
// Begin the text block
$data = "G";
$element = $builder->CreateTextRun($data);
$element->SetTextMatrix(720.0, 0.0, 0.0, 720.0, 20.0, 240.0);
$gs = $element->GetGState();
$gs->SetTextRenderMode(GState::e_fill_stroke_text);
$gs->SetLineWidth(4);
// Set the fill color space to the Pattern color space.
$gs->SetFillColorSpace(ColorSpace::CreatePattern());
$gs->SetFillColor(new PatternColor(CreateTilingPattern($doc)));
$writer->WriteElement($element);
$writer->WriteElement($builder->CreateTextEnd());
// Finish the text block
$writer->End();
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:31,代码来源:PatternTest.php

示例8: Matrix2D

// mask is the explicit mask for the primary (base) image
$img->SetMask($mask);
$element = $builder->CreateImage($img, new Matrix2D(200.0, 0.0, 0.0, -200.0, 320.0, 380.0));
$writer->WritePlacedElement($element);
$writer->End();
// save changes to the current page
$doc->PagePushBack($page);
// Transparency sample ----------------------------------
// Start a new page -------------------------------------
$page = $doc->PageCreate();
$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);
开发者ID:anrao91,项目名称:PDFNetWrappers,代码行数:31,代码来源:ElementBuilderTest.php


注:本文中的Font::Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。