• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

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

3.5K

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.

Votes

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
Community Expert ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

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
);

  

Votes

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
New Here ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

@Joel_Geraci Excellent example, you almost solved my problem. I am a teacher and I want to use this method to collect student work back to my server. However I need a little more help. This code did not work when I used my server URL and figured out I may need a PHP code or something like that. I have no idea about PHP and whatever I tried did not work...Can you please guide or point me in the right direction...Sorry, I might have uploaded some student worksheets to your server while trying 🙂

Votes

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
Community Beginner ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied

 Hello Joel_Geraci,

 

I followed your instructions to create a preview of a pdf with the possibility of inserting annotations.
Everything works fine.
How I can save these annotations to the database.


Can you help me, please?


Thank you

Votes

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
Community Expert ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied

Do you want to save just the annotations to a database or the entire new PDF with the annotations to a database?

Votes

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
Community Beginner ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

LATEST

 Hello Joel_Geraci,

i need to save the  entire new PDF with the annotations to a database. Is it possible?

Thanks 

Votes

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
Resources