- Generate the PDF media you want and store it locally.
- Go to the console, run your python file to convert the PDF to Hex code
- In the code, list the filepath for the PDF you wish to convert
- Go to your directory where it is stored in the terminal, then run python3 pdf_to_hex.py
- For example, this was my output:
- Page 1 Hexadecimal String: 546869730a69730a610a746573740a646f63756d656e740a77650a77696c6c0a686176650a636f6e7665727465640a746f0a68657861646563696d616c0a737472696e67732e0a53696e636572656c792c0a5468650a41666768616e0a44414f0a7465616d
- Save this output
- I created a file called solidity_smart_contract_basic.sol
- I compile that code using Remix IDE
- Once it was compiled, I went to deploy the code
- I selected the Injected Provider - Metamask
- I made sure on Metamask that I was selecting a production-level network. I chose Ethereum Mainnet as my network.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract PdfStorage {
mapping(uint => string) public pdfData;
function storePdf(uint pageNum, string memory hexString) public {
pdfData[pageNum] = hexString;
}
function getPdf(uint pageNum) public view returns (string memory) {
return pdfData[pageNum];
}
}