0

I have a problem, I can't figure out how to convert. I have an entity (for a block). In the entity, I have a variable where I store a pdf file in base64 format. I want to convert a string (from base 64) into a PDF and display this PDF in a modal window. If someone has done this, I will be grateful for help. My goal is to convert base 64, which is in pdfBase, into a file, in order to display this pdf file in the widget

I just want to say the file (but it is not necessary to save it).

My entity

    import 'dart:convert';
    import 'dart:typed_data';

    import 'package:freezed_annotation/freezed_annotation.dart';

    part 'warranty_pdf_entity.freezed.dart';

    @freezed
    class WarrantyPdfEntity with _$WarrantyPdfEntity {
      const WarrantyPdfEntity._();

      const factory WarrantyPdfEntity({
        @Default('') String? pdfBase,
        final dynamic filePdf,
      }) = _WarrantyPdfEntity;

  PdfImage copyWithSelected() {
    var pdfDataBytes = base64.decode(pdfgarranty!);
    var img = decodeImage(pdfDataBytes);
    PdfImage image = PdfImage(
        pdf,
        image: img!.data.buffer.asUint8List(),
        width: img.width,
        height: img.height);
    return image;
  }


    }
  • Does this answer your question? [Convert base64 String into PDF file in Flutter](https://stackoverflow.com/questions/66996416/convert-base64-string-into-pdf-file-in-flutter) – L3odr0id Aug 25 '22 at 06:12

1 Answers1

-1

I think this question is a dublicate. Here is the answer about how to convert base64 to pdf in flutter: https://stackoverflow.com/a/66997078/15776812

L3odr0id
  • 170
  • 1
  • 10