Use PDF and PowerPoint
Import PDF into the page
You can add PDFs to the page using the importPdf()
method of the addOnUISdk.app.document
object, which expects a Blob
object as an argument and a MediaAttribute
object with a title (mandatory) and author (optional) as the second.
PDF and PowerPoint imports will trigger a consent dialogue that asks the user to confirm the process; it's not possible to bypass it. As soon as the process starts, another dialogue will preview the PDF and track the operation progress.
Supported vector elements will be kept editable (e.g., shapes with rounded corners, text, etc.), and all pages will be imported.
Example
Copied to your clipboardimport addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";addOnUISdk.ready.then(async () => {try {const pdfUrl = "https://url/to/your/file.pdf";const pdf = await fetch(pdfUrl);const pdfBlob = await pdf.blob();await addOnUISdk.app.document.importPdf(pdfBlob, // 👈 Blob object{title: "Official Launch Party",author: "Adobe",});} catch (e) {console.error("Failed to add the PDF", e);}});
Please note that you can use fetch()
also to get PDFs that are local to the add-on; in this case, you can use paths relative to the add-on's root.
Copied to your clipboardimport addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";addOnUISdk.ready.then(async () => {try {// 👇 Local PDFconst pdfUrl = "./OfficialLaunchParty.pdf";const pdf = await fetch(pdfUrl);// ... same as before
Importing converted documents
If your add-on converts Word documents (.docx
) or Google Docs (.gdoc
) to PDF before importing, you can use the sourceMimeType
parameter to improve the user experience. When specified, the import consent dialog displays the message "Import a document" rather than the default "Import a PDF".
Copied to your clipboard// Import a PDF that was converted from a Word documentawait addOnUISdk.app.document.importPdf(convertedPdfBlob, {title: "Converted Document",sourceMimeType: "docx" // Shows "Import a document" in the dialog});
Import PowerPoint into the page
For PowerPoint files, the process is similar to the one for PDFs, but you need to use the importPowerPoint()
method instead. The method supports both .pptx
and .ppt
files, and shows the same consent and progress dialogues as seen above.
Copied to your clipboardimport addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";addOnUISdk.ready.then(async () => {try {const powerPointUrl = "https://url/to/your/file.pptx";// Or// const powerPointUrl = "./OfficialLaunchParty.pptx";const powerPoint = await fetch(powerPointUrl);const powerPointBlob = await powerPoint.blob();await addOnUISdk.app.document.importPowerPoint(powerPointBlob, // 👈 Blob object{title: "Official Launch Party",author: "Adobe",});} catch (e) {console.error("Failed to add the PDF", e);}});
FAQs
Q: How do I import PDF files?
A: Call addOnUISdk.app.document.importPdf(blob, attributes)
with PDF blob and MediaAttribute object.
Q: How do I import PowerPoint files?
A: Call addOnUISdk.app.document.importPowerPoint(blob, attributes)
with PowerPoint blob and MediaAttribute.
Q: What PowerPoint formats are supported?
A: Both .pptx and .ppt file formats are supported.
Q: Are MediaAttributes required for PDF/PowerPoint?
A: Yes, title is mandatory and author is optional in the MediaAttribute object.
Q: What is the sourceMimeType parameter for?
A: Use sourceMimeType
in MediaAttributes to improve UX when importing converted documents. It shows "Import a document" instead of "Import a PDF" in the consent dialog.
Q: When should I use sourceMimeType?
A: Use it when importing PDFs that were converted from other document types like Word (.docx) or Google Docs (.gdoc) to provide clearer messaging to users.
Q: What values does sourceMimeType accept?
A: Common values include "docx" for Word documents and "gdoc" for Google Docs. Use the original document format before PDF conversion.
Q: Will users see a consent dialogue?
A: Yes, PDF and PowerPoint imports trigger consent dialogues that users must confirm.
Q: Can I bypass the consent dialogue?
A: No, the consent dialogue cannot be bypassed for PDF and PowerPoint imports.
Q: Are vector elements preserved?
A: Yes, supported vector elements like shapes and text remain editable after import.
Q: How many pages are imported?
A: All pages from PDF and PowerPoint files are imported into the document.