Exploring the process of transforming a dynamic PDF into a static PDF using PHP or NodeJS

Issue

I am looking for a PHP/NodeJS API that can convert editable PDF files to non-editable PDFs online. Our client application requires the user to download PDF files that cannot be modified using software like Foxit Reader or Adobe.

We are currently using PDF-LIB, but it does not provide a solution for creating non-editable PDFs through an API to set access privileges. I have searched extensively but have not found any suitable API. We are avoiding pdf-flatten as we need all content to remain selectable. Any assistance would be greatly appreciated.

List of libraries that were tested and did not achieve desired results:

  1. bpampuch/pdfmake - issue: unable to load existing pdf files
  2. PDF-LIB - issue: lack of support for permissions
  3. nrhirani/node-qpdf - issue: file restrictions not functioning properly

Answer №1

To prevent any further editing of your PDF, you may want to consider flattening it.

  • If you only need the form fields to be flattened, you can try utilizing the PDF-LIB tool on GitHub

  • For flattening the entire PDF document, you might find the pdf-flatten package helpful for Node.js

Answer №2

After conducting extensive research and testing various libraries in PHP/Node, I was unable to find a suitable one to proceed with. This led me to the decision of creating my own API using C# and Java

Solution: We send the PDF URL through the API, which then downloads the file and applies multiple permissions based on the dataset.

Library: The library we opted for is ASPOSE

// These can be true/false
config.IsPrint = true;

// Document is allowed to be changed.
config.IsModify = false;

// Annotation is allowed.
config.IsAnnot = true;

// Form filling is allowed.
config.IsFillForm = true;

// Content extraction is allowed.
config.IsExtract = true;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating dropdown menu selection after successful form submission validation

I'm currently working on a PHP sign up/registration form that retains and resubmits user input if validation fails. Although I have successfully implemented text boxes, password inputs, and radio buttons, I am encountering some challenges with the dro ...

A foreign key constraint violation occurred during a sequelize transaction when inserting or updating a record in the table

Within a transaction, an update query is being executed. The error message "insert or update on table "comp_submissions" violates foreign key constraint "comp_submissions_comp_id_fkey"" suggests that the comp is not added into the datab ...

How do I find the child elements within a parent node?

I am currently utilizing a jquery plugin that has rendered the following HTML layout in the browser: <html> <body> <div class="mce-container-body"> ... <input type="text" id="textedit01"> ... </di ...

Passing a JSON object between pages in Next.js using props during programmatic navigation

In my Next.js project, I have two pages. On the first page, the user fills out a form to create a post. The information is stored in a large JSON object, which needs to be passed to the second page for the user to preview the post before finalizing it. Wi ...

What is the reason for npm and yarn to download multiple versions of jquery?

For the purpose of investigating how package managers like npm, yarn, and cnpm work in Node.js, I conducted an experiment. During the test, I came across two packages: jquery-dreamstream and jquery.tree. Both of them have a dependency solely on jquery wit ...

Obtain the computed style by utilizing setTimeout for effective functionality

I want to retrieve the calculated style (background-color) of a span element. Here's my HTML code, consisting of two label elements, each containing an input and a span: <label> <input type="radio" name="numbers" value="01" checked/> ...

Using React Material UI icon within an auto complete feature

https://i.stack.imgur.com/W3CmF.png I am struggling to incorporate the target icon into the autoComplete component. After reviewing the documentation, I have been unable to find a solution. In TextInput, a similar outcome can be achieved by implementing ...

What is the best way to eliminate double quotes from multiple variables that combine to form a single string when exporting array variables to a csv file?

$fetchData = "SELECT * FROM members"; if (!$outputResult = mysqli_query($connection, $fetchData)) { exit(mysqli_error($connection)); } $usersList = array(); if (mysqli_num_rows($outputResult) > 0) { while ($rowsFetched = mysqli_fetch_assoc( ...

Guide on utilizing the print feature in C# Selenium with Chrome driver

On my website, there is a print option that I want to activate. <a href="https://crim.brib.pk/RenderReport_Version2.aspx??Product_Id=MjgwMQ%3d%3d-J2XNpfmNU8Q%3d&amp;RUID=MTEwMDI0NTAwMTU%3d-rBg0P40kyho%3d&amp;FinalResult=T#" onclick="AlertandPr ...

Issue with state change in Component (React with Redux)

I am another person facing a similar issue. I have been unable to identify the error in my code yet. I suspect it has something to do with mutation, but despite trying almost everything, I am at a loss. My component does not update when I add new items to ...

Guide to summing the values in an input box with TypeScript

https://i.stack.imgur.com/ezzVQ.png I am trying to calculate the total value of apple, orange, and mango and display it. Below is the code I have attempted: <div class="row col-12 " ngModelGroup="cntMap"> <div class="form-group col-6"> ...

Using Jquery and css to toggle and display active menu when clicked

I am trying to create a jQuery dropdown menu similar to the Facebook notification menu. However, I am encountering an issue with the JavaScript code. Here is my JSFiddle example. The problem arises when I click on the menu; it opens with an icon, similar ...

Verify that the select field has been chosen using Protractor

Currently, I am in the process of developing a test that places importance on whether a select field has already been populated. it('should automatically select a field if it hasn't been selected previously', function() { var usersField = ...

"The debate over using 'stringly typed' functions, having numerous redundant functions, or utilizing TypeScript's string enums continues to divide the programming

I have a specific object structure that contains information about countries and their respective cities: const geo = { europe: { germany: ['berlin', 'hamburg', 'cologne'], france: ['toulouse', ' ...

Discovering the keycode for the GO button in JavascriptDiscovering the keycode

Can anyone help me figure out how to find the keycode for the GO button using Javascript in an Android browser? ...

Can you list out the directives that are responsible for generating child scopes in AngularJS?

I recently discovered that when using ng-if, it actually creates a child scope, leading to some confusion on my end. I'm curious about the reasons or benefits behind ng-if's scope creation. Can you also tell me which other built-in directives cre ...

Authorize a user through Loopback using REST as the data source

I am currently working with a UserModel that is based on the USER model and uses a REST datasource. "UserModel": { "dataSource": "mock", "public": true } Data Source Configuration "mock": { "name": "mock", "baseURL": "http://localhost:3000/", "connector ...

Is there a way to send a variable to the alert function using $.ajax()?

I need assistance with confirming the deletion of a record. When the user clicks on the button, it should send the value 'Yes' to a $_POST request in PHP for deleting the record. However, instead of working as expected, it is showing me the JavaS ...

Steps for Filling a List Box (combo box) with Data from a Multi-Dimensional Array

As a student learning JavaScript, I have an assignment due tonight and am facing challenges with populating a List Box (combo box) from a Multi-Dimensional Array. After working on the code multiple times, I managed to create a multi-dimensional array that ...

The custom post type feature in Wordpress is completely transforming the URLs for various types of posts, pages, and content

I have created a custom post type named 'Services' in my WordPress theme by adding the following code to my functions.php file. // Register Services Post Type function services_custom_post_type() { $labels = array( 'name' ...