draw method

void draw(
  1. PdfPage page,
  2. Offset location
)

Draws a text web link on the PDF page.

//Create a new Pdf document
PdfDocument document = PdfDocument();
//Create the web link in the PDF page
PdfTextWebLink textWebLink = PdfTextWebLink(
    url: 'www.google.co.in',
    text: 'google',
    font: PdfStandardFont(PdfFontFamily.timesRoman, 14),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)),
    pen: PdfPens.brown,
    format: PdfStringFormat(
        alignment: PdfTextAlignment.center,
        lineAlignment: PdfVerticalAlignment.middle));
//Draw the web link in the PDF page
textWebLink.draw(document.pages.add(), Offset(50, 40));
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

void draw(PdfPage page, Offset location) {
  if (!PdfAnnotationHelper.getHelper(this).isLoadedAnnotation) {
    final PdfFont pdfFont =
        font != null ? font! : PdfStandardFont(PdfFontFamily.helvetica, 8);
    final Size textSize = pdfFont.measureString(text);
    final Rect rect = Rect.fromLTWH(
        location.dx, location.dy, textSize.width, textSize.height);
    _uriAnnotation = PdfUriAnnotation(bounds: rect, uri: url);
    _uriAnnotation.border = PdfAnnotationBorder(0, 0, 0);
    page.annotations.add(_uriAnnotation);
    _drawInternal(page.graphics, rect, pdfFont);
  }
}