Technology Sharing

Base64 file stream viewing and downloading PDF method -CSDN

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Problem Description

The PDF invoices returned by the Shupiaotong interface are returned as Base64 file streams, so you cannot directly view and preview the PDF invoices.

Approach

  1. Using third-party online tools:https://www.jyshare.com/front-end/61/

image.png

  1. Paste the following code in the Html code box
<embed type="application/pdf" src="data:application/pdf;base64,${fileSrc}" width="100%" height="600px">
  • 1
  1. Replace ${fileSrc} in the code with the base64 file stream returned by the message
  2. The result is as follows. The invoice corresponding to the file stream will be displayed in the lower right area, and you can download and save the PDF file:

image.png