I am not seeing where its gets downloaded. It should be like downloaded any other thing on your phone it shows up in the notification bar and you can click on it to view the document.
// components/PDFGenerator.js

import React, { useContext, useState } from 'react';
import { StyleSheet, View, Button, Alert, TouchableOpacity, Text, Platform, Linking } from 'react-native';
import * as Print from 'expo-print';
import * as FileSystem from 'expo-file-system';
import { MediaContext } from '../context/MediaContext';
import { Ionicons } from '@expo/vector-icons'; // For icons

const PDFGenerator = () => {
  const { media } = useContext(MediaContext);
  const [pdfUri, setPdfUri] = useState(null); // State to store PDF URI

  const generatePDF = async () => {
    // Create HTML content for PDF
    let mediaHtml = '';

    if (media.photo) {
      mediaHtml += `<h2>Captured Photo</h2><img src="${media.photo}" style="width:100%; height:auto;" />`;
    }

    if (media.video) {
      // Note: Embedding video in PDF is not widely supported
      mediaHtml += `<h2>Recorded Video</h2>
                    <p>Video recorded at: <a href="${media.video}">Download Video</a></p>`;
    }

    if (media.audio) {
      // Note: Embedding audio in PDF is not widely supported
      mediaHtml += `<h2>Recorded Voice</h2>
                    <p>Audio recorded at: <a href="${media.audio}">Download Audio</a></p>`;
    }

    const htmlContent = `
      <html>
        <head>
          <style>
            body { font-family: Arial, sans-serif; padding: 20px; }
            h1 { text-align: center; }
            img { max-width: 100%; height: auto; }
            a { color: blue; text-decoration: none; }
          </style>
        </head>
        <body>
          <h1>Consent Document</h1>
          <p>${legalText}</p>
          ${mediaHtml}
        </body>
      </html>
    `;

    try {
      // Generate PDF from HTML
      const { uri } = await Print.printToFileAsync({ html: htmlContent });

      let destinationPath;

      if (Platform.OS === 'android') {
        // Define the path to save the PDF in the Downloads directory
        destinationPath = `${FileSystem.documentDirectory}Download/ConsentDocument_${Date.now()}.pdf`;

        // Ensure the Downloads directory exists
        const downloadsDir = `${FileSystem.documentDirectory}Download`;
        const dirInfo = await FileSystem.getInfoAsync(downloadsDir);
        if (!dirInfo.exists) {
          await FileSystem.makeDirectoryAsync(downloadsDir, { intermediates: true });
        }
      } else {
        // For iOS, save to the app's documents directory
        destinationPath = `${FileSystem.documentDirectory}ConsentDocument_${Date.now()}.pdf`;
      }

      // Move the PDF to the desired location
      await FileSystem.moveAsync({
        from: uri,
        to: destinationPath,
      });

      // Update state with the new PDF URI
      setPdfUri(destinationPath);

      Alert.alert('Success', `PDF has been downloaded successfully!\n\nPath: ${destinationPath}`);
    } catch (error) {
      Alert.alert('Error', 'Failed to generate PDF: ' + error.message);
    }
  };

  const openDownloadLocation = async () => {
    if (!pdfUri) {
      Alert.alert('No PDF', 'Please generate the PDF first.');
      return;
    }

    if (Platform.OS === 'android') {
      // Attempt to open the Downloads folder on Android
      // Note: This approach may not work on all devices due to variations in file manager implementations
      try {
        // Construct the URI for the Downloads directory
        const downloadsPath = FileSystem.documentDirectory + 'Download/';

        // Use Android's file URI scheme
        const uri = `file://${downloadsPath}`;

        // Attempt to open the Downloads folder using an intent
        await Linking.openURL(uri);
      } catch (error) {
        Alert.alert('Error', 'Cannot open Downloads folder. Please locate the PDF manually.');
      }
    } else {
      // For iOS, there's no straightforward way to open the Files app to a specific location
      Alert.alert(
        'Download Complete',
        'PDF has been saved to the app’s document directory.\n\nTo access it, use the Files app and navigate to "On My iPhone" > [Your App Name].'
      );
    }
  };

  return (
    <View style={styles.container}>
      <View style={styles.section}>
        <Button title="Download PDF" onPress={generatePDF} />
      </View>
      {pdfUri && (
        <TouchableOpacity style={styles.iconContainer} onPress={openDownloadLocation}>
          <Ionicons name="folder-open" size={40} color="#4CAF50" />
          <Text style={styles.iconText}>Open Download Location</Text>
        </TouchableOpacity>
      )}
    </View>
  );
};

// --- Legal Text (Should be imported or passed as a prop) ---
const legalText = `YOUR LEGAL TEXT GOES HERE...

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vel turpis at quam aliquet lobortis. Integer sit amet ligula vitae justo commodo fermentum. Donec vitae massa a augue blandit porttitor. Proin id purus nec justo mollis finibus sit amet at justo. Mauris ac sem vitae nisl interdum interdum.`;

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  section: {
    marginBottom: 30,
    backgroundColor: '#ffffff',
    padding: 15,
    borderRadius: 10,
    elevation: 2, // For Android
    shadowColor: '#000', // For iOS
    shadowOffset: { width: 0, height: 2 }, // For iOS
    shadowOpacity: 0.25, // For iOS
    shadowRadius: 3.84, // For iOS
    alignItems: 'center',
  },
  iconContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    marginTop: 10,
    padding: 10,
    backgroundColor: '#e0f7fa',
    borderRadius: 10,
  },
  iconText: {
    marginLeft: 10,
    fontSize: 16,
    color: '#00796b',
  },
});

export default PDFGenerator;