import {useApi} from '~/composables/useApi' export const usePdfPrinter = () => { const api = useApi() const receptionStore = useReceptionStore() const currentReception = receptionStore.current const printPdf = async (url: string): Promise => { if (!import.meta.client) { return } const blob = await api.getBlob(url) const blobUrl = URL.createObjectURL(blob) const a = document.createElement('a'); a.href = url; // nom du fichier à changer par les infos du store pinia a.download = `${currentReception.identificationNumber}_${currentReception.supplier.name}_${currentReception.licensePlate}`; document.body.appendChild(a); a.click(); a.remove(); window.open(blobUrl, '_blank', 'noopener,noreferrer') setTimeout(() => URL.revokeObjectURL(blobUrl), 60000) } return { printPdf } }