Is there any way to save edited pdf in server in pdf embed API

New Here ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

I am currently working on a Learning Management System and I have to attach this Embed API to my application based on PHP Core, but instead of downloading the pdf I want it to be saved on my server and not on the client's computer, is there any way to do it?

Views

171

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

Yes, that should be possible. Please refer to the public facing Embed APIs documentation for Save API here.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

LATEST

I've posted a functioning example on CodePen.

The functional part of the code is below. The content parameter is the PDF as a ByteArray. Convert the ByteArray into a Blob then add it to the FormData as you would any other file, then simply POST it to your server. The PHP side looks just like you uploaded a file.

To run the demo, go to the CodePen, add a comment, then Save the file. The file will get sent to my server and then zipped; this is just to make it clear that the normal save function was replaced. You'll see the UI change to a message that will let you download the zipped file. Open the zip and you should see your commented PDF.

adobeDCView.registerCallback(
    AdobeDC.View.Enum.CallbackType.SAVE_API,
    function (metaData, content, options) {
        var uint8Array = new Uint8Array(content);
        var blob = new Blob([uint8Array], { type: 'application/pdf' });
        formData = new FormData();
        var pdfFilename = urlToPDF.split("/").slice(-1)[0];
        pdfFilename = pdfFilename.split(".")[0] + "-" + uuidv4() + ".pdf";
        formData.append('pdfFile', blob, pdfFilename);

        var zipFileName = pdfFilename.replace(".pdf", ".zip");

        fetch("https://practicalpdf.com/code-pens/reflect/", {
            method: 'POST',
            body: formData,
        })
            .then(
                function (response) {
                    if (response.status == 200) {
                        updateSaveUI(zipFileName);
                    }
                }
            )

        return new Promise((resolve, reject) => {
            resolve({
                code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
                data: {
                    metaData: { fileName: urlToPDF.split("/").slice(-1)[0] }
                }
            });
        });
    },
    saveOptions
);

  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines