load Online Document Pdf

Hi Syncfusion 

I'm just want to ask ,is it possible to load Online Document Pdf (url or Firebase) and add text or drawning string ?


2 Replies

SV Surya Venkatesan Syncfusion Team January 31, 2022 02:45 PM UTC

Hi Saber, 


We can read the PDF document from webspace/website by using the HTTP package and drawn the text. Kindly try the following code example in your end.


  1.  Add http package in dependencies section of pubspec.yaml file

dependencies: 

  http: ^0.13.4 


  1. Import the following package in your dart file.

import 'package:http/http.dart' show get; 


  1. Get image data
  1. //Read an PDF from website/webspace
  2.     var url = Uri(
  3.         path:
  4.             Input pdf address link);
  5.  
  6.     var response = await get(url);
  7.     var data = response.bodyBytes;


  1. Drawstring in PDF
  1. // Create a new PDF document
  2.     PdfDocument document = PdfDocument(inputBytes: data);
  3.     // PdfDocument document = PdfDocument();
  4.  
  5.     //Draw string on the existing page graphics
  6.     document.pages[0].graphics.drawString(
  7.         "Sample text content", new PdfStandardFont(PdfFontFamily.helvetica, 17),
  8.         bounds: const Rect.fromLTWH(100, 20, 200, 50));
  9.     //Save and launch the document
  10.     final List<int> bytes = document.save();
  11.     //Dispose the document.
  12.     document.dispose();


Kindly refer to the following articles for more details,

KB: https://www.syncfusion.com/kb/12757/how-to-load-a-pdf-document-from-firebase-storage-in-syncfusion-flutter-pdfviewer


Regards,

Surya V



SA Saber replied to Surya Venkatesan February 2, 2022 12:27 PM UTC

THANK YOU SO MUCH

THIS WILL HELP ME .


Loader.
Up arrow icon