url property

String get url

Gets or sets the Uri address.

//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));
//Sets the url
textWebLink.url = 'www.google.co.in';
//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

String get url {
  if (PdfAnnotationHelper.getHelper(this).isLoadedAnnotation) {
    return _obtainUrl()!;
  } else {
    return _url!;
  }
}
set url (String value)

Implementation

set url(String value) {
  if (value == '') {
    throw ArgumentError.value('Url - string can not be empty');
  }
  _url = value;
  if (PdfAnnotationHelper.getHelper(this).isLoadedAnnotation) {
    final PdfDictionary tempDictionary =
        PdfAnnotationHelper.getHelper(this).dictionary!;
    if (tempDictionary.containsKey(PdfDictionaryProperties.a)) {
      final PdfDictionary? dictionary =
          PdfCrossTable.dereference(tempDictionary[PdfDictionaryProperties.a])
              as PdfDictionary?;
      if (dictionary != null) {
        dictionary.setString(PdfDictionaryProperties.uri, _url);
      }
      tempDictionary.modify();
    }
  }
}