Develop a Web Application that Modifies PDF Documents

Oracle Visual Builder provides tools and templates that let you build web applications that can use external JavaScript libraries to create, update and download PDF Documents.

App users consume, modify, and generate PDF documents in many contexts and for various purposes. Often, an uploaded PDF document must be read by an application and the content of this document altered accordingly. Some common changes that an application should be able to perform on a PDF might include:
  • Adding a new text.
  • Drawing a rectangle around a part of document.
  • Splitting the PDF in different pages.
  • Inserting an image.
In some cases, a new PDF document needs to be created from scratch and populated with information generated by the application.

This solution provides you the necessary guidance to implement PDF modification functionality on your web and mobile Visual Builder applications. It describes how to develop a one-page web application with which a user can upload or create a new PDF file, modify this document with a custom text, and then display the document on the main page of the application. If necessary, the application will also allow users to download the file to their local client repository.

The GitHub repository (SampleVBCSModifyingPDFApplication) contains the source code for an Oracle Visual Builder web application that can be used as an example of such an implementation. You can access this repository from the "Explore More" section of this playbook.

Before You Begin

Developers can use Oracle’s Low Code Visual Builder to create web or mobile applications that can handle PDF files to perform such tasks as:

  • Creating a PDF file.
  • Modifying a PDF content (for example, adding or removing pages, text, images).
  • Merging different PDF document into one or split a multipage PDF document.
The application can then generate a PDF document that can be:
  • Displayed on the application UI.
  • Downloaded by the user of the application.
  • Stored on a bucket.
  • Sent to other OCI services for further processing (for example, OCI Document Understanding service).
When Oracle Visual Builder is the development platform for this kind of operation, you'll need to import an external library to produce and to update the PDF document. Therefore, before you begin, you need to assess the available JavaScript libraries and determine if their APIs can meet your application requirements.

This solution uses the PDF-LIB API to create a new PDF document and to modify existing PDF documents.


This architecture diagram shows a common way to develop and integrate a web application implemented and deployed by Oracle Visual Builder.

Description of webapp-vb-arch.png follows
Description of the illustration webapp-vb-arch.png

Oracle Visual Builder allows you to develop applications that can communicate with the back-end storage service. Use it to create the pages that render your application's interface, create the service connections that connect to REST services, and define build configurations so that Oracle Visual Builder's build services can create Android, iOS, Progressive, and basic web apps.

This architecture contains these components:
  • Visual Builder Cloud Service

    Oracle Visual Builder Cloud Service is a cloud-based software development Platform as a Service (PaaS) and a hosted environment for your application development infrastructure. It provides an open-source standards-based solution to develop, collaborate on, and deploy applications within Oracle Cloud. It also offers an integrated Visual development environment with agile collaborative development, version control, and continuous delivery automation. Enrich applications with engaging custom UI and it is an extendable platform through standard JavaScript, HTML, CSS and REST.

  • Visual Builder Studio
    Oracle Visual Builder Studio (VB Studio) is a robust application development platform that helps your team effectively plan and manage your work throughout all stages of the application development lifecycle: design, build, test, and deploy. With Oracle Visual Builder Studio you get:
    • Built-in repositories for hosting code in Git and for hosting binaries, such as Maven dependencies.
    • A continuous integration service so you can automate your build and test systems.
    • A continuous delivery service that tightly integrates with Oracle Cloud Applications.
    • A rich visual designer integrated with source control (Git) so that developers can manage changes, apply version control best practices, and collaborate with their teammates to develop applications.
    • The ability to build and display different flavors of the UI to meet the needs of discrete users of certain Oracle Cloud Applications (those built with VB Studio and Oracle JavaScript Extension Toolkit (Oracle JET)), also within a Git framework.
    • Agile boards and an issue tracking system for tracking sprints, tasks, defects, and features.
    Oracle Visual Builder Studio lets you easily deploy their applications to their preferred target, whether it’s a staging or production instance of Oracle Cloud Applications or an Oracle Cloud Infrastructure (OCI) service instance.
  • VMs (Virtual Machines build executors)

    VM build executors are OCI VM compute instances dedicated to run builds of jobs your organization’s members define in VB Studio projects. A VM executor is always associated with a build executor template. When your organization's members create jobs, they simply associate the appropriate executor template with the job. When the job's build triggers, VB Studio runs the build on a VM executor that's associated with the executor template. A VM executor starts automatically when a build of a job that references its executor template triggers, and changes its state accordingly. Remember, a VM executor costs you only when it is active, runs a build, or is preparing itself to run a build.

  • Docker Containers (Build executor and Images)
    A Docker image defines the operating system and software packages your org's members need to run builds on a Docker executor. You can either import a Docker image from an external Docker registry, such as DockerHub, or create it from a build executor template. Unlike a VM executor, a Docker executor is not directly associated with any specific VM. When your organization's members create jobs, they simply associate a Docker image as a build template with the job. When the job's build triggers, VB Studio runs the build on any Docker deployment VM. Some key points to remember about Docker images:
    • When you create an image from a build executor template, VB Studio creates a new Docker image by installing the software configured in that template. When you create an image from a registry, VB Studio pulls the image from the registry, adds a build agent, and creates a new image.
    • You can specify the maximum number of executors that can be created from the image.
    • You can create as many Docker images as you require, as long as the Management VM has enough space.
  • Functions

    Oracle Cloud Infrastructure Functions is a fully managed, multi-tenant, highly scalable, on-demand, Functions-as-a-Service platform. It is built on enterprise-grade Oracle Cloud Infrastructure and powered by the Fn Project open source engine. The serverless and elastic architecture of OCI Functions means there's no infrastructure administration or software administration for you to perform. OCI Functions, you can write code in Java, Python, Node, Go, Ruby, and C# (and for advanced use cases, bring your own Dockerfile, and Graal VM). You can then deploy your code, call it directly or trigger it in response to events, and get billed only for the resources consumed during the execution. You can access OCI Functions using the Console, a CLI, and a REST API. You can invoke the functions you deploy to OCI Functions using the CLI or by making signed HTTP requests. OCI Functions is integrated with Oracle Cloud Infrastructure Identity and Access Management (IAM), which provides easy authentication with native Oracle Cloud Infrastructure identity functionality.

  • Events

    Actions that you perform on Oracle Visual Builder Studio instances emit events. You can use the Oracle Cloud Console to define rules that trigger a specific action when an event occurs. Oracle Cloud Infrastructure Events enables you to create automation based on the state changes of resources throughout your tenancy. Use Events to allow your development teams to automatically respond when a resource changes its state. For example, you might define a rule that sends a notification to administrators when someone either creates, deletes, or updates an instance.

  • Project

    A project is a collection of VB Studio features. You can use a project to host source code files, track issues, collaborate on code, build, and deploy your applications. A project can host multiple Git repositories. Each Git repository can have multiple branches and hundreds of code files. You can create a merge request for each branch of the Git repository and ask reviewers to review the code. You can create and configure multiple build jobs to generate different project artifacts that you can deploy to Oracle Cloud or your on-premise web server.

  • Git repository

    A Source Code Management (SCM) and distributed version control tool to host source code files.

  • Code review and Merge request

    A method to merge a Git repository branch with another branch. Before merging the branches, team members can review differences between files of both branches and provide their feedback.

  • Continuous Integration (CI) and Continuous Delivery (CD) pipelines

    Continuous integration is a set of practices that allow development teams to implement small code changes and push the code to version control repositories, such as Git, frequently. Continuous delivery is a practice that enable developers to produce software in short cycles.

  • Virtual cloud network (VCN) Cloud Services

    A VCN is a customizable, software-defined network that you set up in an Oracle Cloud Infrastructure region. Like traditional data center networks, VCNs give you complete control over your network environment. A VCN can have multiple non-overlapping CIDR blocks that you can change after you create the VCN. You can segment a VCN into subnets, which can be scoped to a region or to an availability domain. Each subnet consists of a contiguous range of addresses that don't overlap with the other subnets in the VCN. You can change the size of a subnet after creation. A subnet can be public or private.

  • Data Repositories (with Oracle Autonomous Transaction Processing)

    Oracle Autonomous Transaction Processing is a self-driving, self-securing, self-repairing database service that is optimized for transaction processing workloads. You do not need to configure or manage any hardware, or install any software. Oracle Cloud Infrastructure handles creating the database, as well as backing up, patching, upgrading, and tuning the database.

  • Identity Cloud Services (IdCS)

    Oracle Identity Cloud Service provides an innovative, fully integrated service that delivers all the core identity and access management capabilities through a multi-tenant Cloud platform.

  • Audit

    The OCI Audit service automatically records calls to all supported OCI public API endpoints as log events.

  • Object storage

    Object storage provides quick access to large amounts of structured and unstructured data of any content type, including database backups, analytic data, and rich content such as images and videos. You can safely and securely store and then retrieve data directly from the internet or from within the cloud platform. You can seamlessly scale storage without experiencing any degradation in performance or service reliability. Use standard storage for "hot" storage that you need to access quickly, immediately, and frequently. Use archive storage for "cold" storage that you retain for long periods of time and seldom or rarely access.

Steps for Building Applications with Oracle Visual Builder

These are the basic steps to follow when developing applications with Oracle Visual Builder:

  1. Create an instance of Visual Builder service (if there is not already one created) from the stand-alone Visual Builder service or new integration instance (if there is not already one created) from the Oracle Integration Cloud (OIC).
  2. Create a new Visual Builder application.
  3. Create a new web application in Oracle Visual Builder.
  4. Create the pages and an overall user interface that exposes controls, such as buttons to upload files, create new PDF docuenmts, and download updated documents.
  5. Create the variables and constants to host the extracted or included information to and from the PDF document.
  6. Import the necessary external resources and libraries
  7. Develop the required JavaScript code to:
    • Upload a file from the local system.
    • Modify the uploaded PDF file with the entered text.
    • Create a new PDF document.
    • Download the PDF file.
  8. Test the application with the appropriate user and document.
  9. Stage and publish the web application.

About Required Services and Roles

This solution requires Oracle Visual Builder service along with these additional services and respective roles:

Service Name: Role Required to
Oracle Cloud Infrastructure: Administrator Manage mobile users, roles, and realms.
Oracle Visual Builder: The Visual Builder Developer predefined role that maps to the ServiceDeveloper application-layer predefined role. To create, manage, secure, and publish web and mobile applications.

See Learn how to get Oracle Cloud services for Oracle Solutions to get the cloud services you need.