Automate the creation and manipulation of PDFs using PDF Services API
Last update: Fri Jan 26 2024 00:00:00 GMT+0000 (Coordinated Universal Time)
- Topics:
- Developer Tools
CREATED FOR:
- Experienced
- Developer
Adobe’s PDF Services API lets developers create, combine, export, OCR and extract data from PDFs through powerful and flexible cloud-based APIs. In this session, you will learn how you can get started using Adobe PDF Services API to integrate document experiences into your apps. Also you will learn to use the free Adobe PDF Embed API to transform PDF viewing experience on the web using UI controls and derive user analytics out of PDF.
Transcript
Hello, everyone. Thank you for joining today’s session. My name is Sudhanshu. And I work as a strategic business development manager. And I’ve been with Adobe for seven years. So today, I’m going to talk about how to automate and you know, the creation and manipulation of PDFs using PDF services API. Now, PDF is very close to our day to day routine, right? Whatever we do, like when we wake up in the morning, like we consume a lot of media, right? We start, you know, every one of us watch something on the mobile device or consuming some media, watching advertisement, right? So we end up touching Adobe technology somewhere or other. And that’s when, you know, we don’t even realize, you know, we are actually using and consuming those technologies. And it’s changing our lives, especially the way COVID has impacted, you know, everyone, especially in terms of how we used to operate earlier and now how we are operating with the new model. So digital transformation has become a necessity to all of us. So it is really important to understand the technologies that we have that can be leveraged, right? And one of the technologies that I’m going to talk about today is PDF services API and PDF embed API. Now, this is the agenda, right? So in the interest of time, like we, I’ll talk about the PDF services API for five minutes, and then we’ll jump into PDF embed API. And then we’ll, I’ll show you how to access those API, right? So once you want to get your hands dirty, and how to get those credentials, how to call those APIs, I’ll show you all that. And then in the end, I will show you a quick demo. So the takeaway from this session is you would have an understanding of PDF services and PDF embed API, where and how they can be used and how you can access them. Right? Now, PDF services API, I’m sure you’d have used Acrobat DC or you know, you would have tried playing with a PDF file, right? So, I mean, one of the things that I personally, I experience it on a daily basis is, you know, some of the PDFs that are of huge size, you know, and I if I want to share it with different stakeholders, I may want to reduce its size, or I want to perform different works and different kinds of operations on a PDF document, right? And how to do that. So there is a very easy way of handling all those complex processes, using PDF services API. It can be divided in three parts, as you see on this slide, you know, we can create a PDF, we can optimize and we can organize the pages. So you can consider that as a kind of a workflow or, you know, stages. We always start with create some creation, right? So we are going to create something, let’s assume if you have HTML document, or even if you have a Word document, you might want, you know, to convert that into a PDF document. And probably, let’s say if you have multiple PDF documents, you would want to combine them into a single document, or probably, you would want to split a PDF document in multiple parts, right? Or maybe, you know, you would want to export it. So we have an API to do that. And then once it is, we are done with all these things, and you might want to optimize this experience, right? Because when we talk about enterprise applications and the PDFs that are being used, right, I mean, some of the PDFs are huge size, right? It could be in gigabytes, or even let’s say, even if a PDF is of size 20 megabyte, it’s still, you know, on the higher side. And then if you want to, let’s say, display or render that PDF, right, then you need to optimize it. So that’s where the optimization comes into picture. Like you can linearize that PDF. Linearization means like if you have a PDF, if you want to render that PDF, let’s say on a web page, then you would give an end user a good experience, you know, you will not wait for the PDF to get loaded, you know, on your client system. You would want at least the first page to show up quickly. And then rest of the pages, you know, can get loaded, you know. So that’s linearization. And then you can compress the PDF, you can protect the PDF, right, and you can organize, right? So we have all these verbs. Now, when you can do it very easily for Micro and then you can go to start free trial. And then it will ask you to log in if you’re not logged in, I’m already logged in. So it is not asking me to log in. And then you can click on the log in button. And then you can go to the log in button. And then you can go to the log in button. And then you can go to the log in button. And then you can go to the log in button. And then you can go to the log in button. And then you can go to the log in button. And then you can go to the log in button. Now, if you have an existing credential, you can always go to this tab, this guy, go to IUP console and manage your existing credentials. But if you don’t have one, then you would want to create a new one, then you need to go to get started. And then once you do there, it will, well, it is asking me to log in. So I’ll go ahead and provide my credentials. And then here, you can select either PDF or mid-APL, or PDF services API, right? So here, I’m interested in in fact, both of them. So I’ll probably create medium services API first, and then I’ll move on to PDF and mid API, right? So in the interest of time, I’m not going to go further along with it, right? So but this is how you need to do this. For a PDF services API, you need to just give it a clinicians name, its description, and then you can personalize the code sample. Like if your background, if you come from a Java background, you can use the code sample. From a Java background, you can use java.net, node Python, so you have that flexibility available. Likewise, you can do the same for PDF embed API, right here. So you can give it a name, right? And then you need to provide an application domain. Now, this is really important if you’re a developer, and if you want to try this on your local system, right? So let’s say if you have a local server running on your system, right? And if you’re trying to consume this client side API, so PDF embed is a client side API. Now, this is important to understand. So there is a thin line between all the APIs that are available under Document Cloud, right? So PDF embed is the only API that is client side. The rest of the APIs are server side, right? So you have a rest endpoint, just consume those API. There is a certain set of protocols that you need to follow, probably create a request, and then consume the API, and you’ll get a response back. Now, one thing to keep in mind is all these APIs are transactional. When I talk about the PDF services API, what it means is we do not store customer data, right? We process your request, and then we return the file back to you, and we are done, right? So this was an important concept. So I just wanted to make you aware of it. Now, for PDF embed API, coming back to this, you need to provide a domain here, right? Now, let’s say if you’re going to try locally, and if you’re using any IDE like Eclipse or any other, let’s say you’re using Java technology or any other technology. So you would want to have the domain whitelisted here. That is the local host. And then once you do that, this link will get enabled, create credential, and it will give you a credential ID. So let me quickly show you this. Let’s say developer event. I’ll give it a name and domain will be local host. I’ll create credentials, right? Now it is processing my request, and it will return back a client ID. Now, this is what you need to start using PDF embed API, right? Likewise, you can do the similar thing with PDF services API, but the PDF services API is slightly different because it is server side, right? As I said, remember, PDF embed API is client side API, and remaining rest of all APIs are server side, right? So you need to go through the JWT process to get the access to those APIs. So I will talk about it shortly. Now, as I said, it is create and optimize. These two are really important steps. What are the things that we can do? I’ll show you that exciting stuff from my code base. Oh, I’m opening my clips, right? So let me zoom in a little bit. So what I’m going to do is, so this is the configured PDF services API right here. And then I’ll expand this, right? Now, let’s say if I want to display a PDF on the web browser, right? So how do we go about it, right? I mean, personally, I experience this problem on a daily basis. When you try to open a PDF file on a web browser, rather than displaying that file on the web browser, it will ask you to download. And that’s not a good experience, right? So this is one of the biggest problems that this API is going to solve for. And most of our customers or even partners, they rely on some third party libraries to manipulate PDF, to render a PDF on a website. Well, up to some extent, you know, this may bring some success. But those technologies are legacy based technologies, right? They’re not upgraded and you might come across some security issues, you know, with those APIs. And the PDF that you’re creating using those third party libraries may not index the PDF, right? So that will hamper the performance when you want to perform such on this PDF, right? And then as a developer, let’s say if you want to make modifications to a PDF file, you know, you need to go back to the code base and start writing those algorithms towards, you know, changes. And you need to, so every time you make, you need to bring some changes to your process, you need to do some hard coding, or you need to, you know, make changes to the code, which is not a good experience as a developer, because it is going to increase the development time, maintenance and everything, right? So to solve for all those problems, we have the PDF embed API, right? It’s actually more than just, you know, again, looking at a PDF file, it gives you the complete control, right? You have the flavor of analytics, right? You can enter the PDF on the browser with all the controls, like you can decide who can download the PDF and who cannot, right? So you can put all those restrictions. So without wasting any time, let me show you. So I’ll start with a quick demo of PDF embed API. Now this is just a simulator, right? I’ll show you from my code that is running locally, right? So just on the right pane, it is like a browser, right? And I’m displaying a PDF right here. This is, I mean, it’s hard to distinguish whether this is a PDF or a web page, right? And that is the beauty of this API. And you have different modes available. This is the full window. And that is a size container. There is a, you know, inline mode, then there is a lightbox, right, for different use cases, right? So it is device agnostic. It does not matter whether you’re trying to enter a PDF on a computer or on an iPad or on a small screen mobile device, you know, it will adopt itself according to the PDF content. And that is the intelligence that Adobe brings in, you know, in this, in the API. As I said, it’s just more than entering a PDF document. It is actually a lot of intelligence, you know, that has gone into it. And then you must be wondering how to use that. Let’s say if you have an application running on your local system, how to use this? Well, very simple. Just few lines of code. You click here, I’ll show you, generate a code. I mean, this is what you need. Just simply plug in this code to your client application and you’re done. All you need is the credential, right? And I showed you how to create a credential. Once you have the credential, then you can very easily do that. And as I said, you know, you have full control, like you can customize it. Let’s say here, you have a print and download options. I mean, you can take it away like this. Now you don’t have that. And you can do all these things, you know, on your own. So let me show you like that. So I’m running this on my system. And then what I’ve done is, let me show you, start with a local. Let’s say if you have a local file on your system that you want to render on a web browser. And when you say local, you know, that PDF file can reside in a database in binary format, right? Or it is lying somewhere on the third party system, like let’s say Amazon, like an S3 bucket. So it does not matter in what format you have that PDF, whether it is the actual physical copy of the PDF on your local system, or it is in binary format, right? You can render that PDF very beautifully on a web browser. So let’s say I’ll give you an example. If you are storing the PDF file in SQL database in binary format, then you can simply retrieve that and pass it as a promise in your code. That’s it. I’ll show you how it is done. So this is the JS file that you need to include, right? And then that’s how you feed in your client ID, right? And I showed you how to create that. Now, once you have that client ID, right? And then if you want to display a file, fetch a file from your local system, and then display it. So I’m running this locally. I’ll show you how it works, right? So this is choose a PDF file, right? Now I’ll select a PDF. Let’s say I’ll select this guy. I’ll hit open. Now it is showing a PDF file that is stored on my local system, and it is the rendering on this web browser, right? And then I have all these controls that I can, you know, I can, if needed, I can remove, take off, you know, all these things from here with all the annotations, everything. And as I said, the best part is we also have the, you know, the flavor of analytics. So there are certain events that gets triggered that you can actually capture and use it to bring intelligence to your application. So let’s say if you want to use a chatbot, right? So you can utilize the events and data and personalize the user’s experience who are visiting your website. Right? So let me show you how that event work, right? So I’ll quickly show you. So I’ll use the console of my Firefox. Now if I scroll down, you know, to different pages, and if you look at this, you know, these are the events that are getting triggered. So there is a page view event. I’m on page number three. And if I keep scrolling down, right, it will take me to different pages. Now if I go and look at the console, it is page number seven. Now if I try to, let’s say, print a PDF, right, like this, it will show me this document print command. I mean, there is an event that got captured. And then if I try to download a PDF, right, it is also going to capture that. So whatever user is, you know, doing on that PDF file, you can capture all those events and process those events and bring intelligence and personalize experience for the user. And that’s how you get connected with the users who are visiting your website. This is going to be super helpful in expanding your business because if you present something to an end user that’s matching up the flavor, that’s exactly what you need. And likewise, it’s not, you know, PDF embed API has way more features than this. Like, I’ll show you. So there is a thing, you know, by default, PDF embed API, the PDF that you’re displaying under the browser, those are not available for searching. If you search them on Google, you will not find them because by default, they are not referred, you know, to the DOM of that HTML page, right? But you have control over it. You can actually refer that direct link, you know, to the DOM of that HTML page to make them available, you know, so that you can also search those PDF files, right? So this is like auto link. Like, once I called this API, this has called this link and it is displaying this PDF. Likewise, I can, you know, use different PDFs and show them on the web browser. Likewise, I’ll show you another interesting thing, right? So I can actually perform good operations on a PDF in terms of, let’s say, annotations. So let me show you. So here, if you look at this, like right here, I have, you know, I can change the color like this. This is interesting, isn’t it? I mean, this is a great feature. And then if I want, I can remove this, like this. And then I can also personalize, you know, this experience. Like, it is John Smith, I can create my own profile. And then it will start saying, Sudhanshu Singh. And then I can download this PDF after getting all the comments and that can be distributed, right? So it is very similar to, you know, when we talk about create, collaborate and execute, right? So you can create a PDF file, add all the comments and everything. And then you can collaborate with your different stakeholders, with your colleagues, right? And then you can virtually work on that PDF file, share it with each other. And then once you have a final version of that PDF created, you know, that can be executed on the web browser. Now, this is how to render a PDF file with full control on a web browser. But what about creating that PDF? Let’s say if you have a Word document, how to convert that into a PDF file. Let’s say if you have a PDF, a scanned PDF, right? Then you cannot search, perform search on a scanned PDF, right? If you try to do control F, it will not let you do that. So you need to perform the OCR operation. So what if you want to make a PDF file? So we have PDF services API to handle that. And as I said, this is important, you know, so I’ll repeat it one more time. So PDF embed is a client side API and PDF services, you know, is a server side API. So let me show you that now. This is really interesting. So I’ll go to my code for PDF services API. So I’ll go to my code for PDF services API. So I’ll go to my code for PDF services SDK, right? So what I’m going to do is these are the different options that are available to me. I can combine a PDF, I can compress. Let me zoom in a little bit, right? So that it is easy for you, right? So I can perform all these operations. So these are different words that are available. Now, let me show you those here since I talked about it. So let me show you first a document that I’m going to use for this OCR. Now, this is the input file that I’m going to use, right? Now, it says scan document, right? Now, if I try to search anything on this document, I’ll not be able to do that because this is not searchable. So let me show you. If I do control F here, then let’s say there is a keyword in this document outline, right? If I try to search that outline, if I hit enter, it will say this is a scan PDF and cannot be searched. So I need to run text recognition, right? To make it searchable. Now, how to do that? So there is an endpoint. I’ll show you. All right, so let me come out of this page. And then what I’m going to do is there is an endpoint for OCR. So what I’m going to do is I’ll simply run this file. So I’m picking this OCR input file in my code. And then now I’m expecting the output in this folder, right? So let me remove this. All right. So let’s see OCR PDF. Now it is processing. So it is intelligent enough, you know, and to read the content, unlock the PDF file, and then it will make it searchable, right? So OCR means you’re making that PDF searchable. And then I should have the output any moment now. So it was quick, right? Now, if I try to open this OCR output, and now if I try to do control F, and if I search for outline, it will take me right there. So quite easy, right? I’m going to make a PDF document searchable. Just an endpoint, right? If you have a scanned copy of invoices, right? So where this can be used, I mean, you must be wondering. So let’s say if you have a legacy based system, ERP system or any system where you have some scanned documents and you know, tons of documents, like let’s say invoices. Let’s take an example of invoices, right? So if you have a scanned copy of invoices, and if you want to make them searchable so that you can actually perform search in those invoices and look for some keywords, right, and bring some intelligence, then you can run OCR, and then simply add your logic to search for the data, the content that you’re looking for. And there is an API to do that. All right, so in the interest of time, let me show you another cool API that is the compress, right? So likewise, you know, I can run it simply, I’ll right click, this is my Java code. And by the way, it doesn’t have to be Java, right? You can develop your application in any technology, like Java, Node, PHP, Python, there is no limitation. It’s an API. This ecosystem is now turning into an API driven completely, right? So if there is an API available, it means regardless of what technology you use, I mean, you just need to develop a client that should be capable of posting a request, right? Or maybe if you’re using callback, or even, you know, kind of webhook, then it should be capable of accepting a get and post request, right? So as long as you have a client application that can make a HTTP call to a rest endpoint, you’re good. So let me run this compressive PDF file. So I’m expecting this output to land here. And then what it will do is it is going to reduce the size of the PDF document, right? And let me show you the PDF that I used to compress. And by the way, you know, when I use this compress API, it is going to reduce the size of the PDF without compromising on, you know, its quality. So that is the best part of it. So let me see, I’ll show you. This is the compressed PDF output like this. If you look at this, you know, it’s still beautiful. I mean, you have those images, tables, everything intact. It did not hamper its quality at all. And this is the input document. Let me show you the input document as well. All right, so there you go. So this is the output document after compress. And now if I open this side by side, can you see this, it’s hard to make a difference. I mean, from our naked eyes, we cannot distinguish whether it’s the compressed PDF or the original one of, you know, of a bigger size. If I scroll down a little bit, if you look at this image, right, just see, I’ll switch toggle between these two PDF. This is the input one and this is the output one. No difference at all, even in the quality of the image, right? Now just imagine the kind of use cases that we can handle with this compressed PDF. If you’re into content writing, if you’re creating and managing a lot of PDF documents, some of the PDFs are going to be of huge size. And you need storage to store those PDF documents. And the storage, I mean, I won’t say it’s very costly, but still it will come at a certain cost, right? So you can reduce that investment, you can reduce that cost by using the compress API. So before storing the PDF, you just need to compress its size and that’s your done. Likewise, you can perform all these operations. You can create a PDF, right? You can create a PDF from Word document, Word document from an HTML, from a PPD, right? So let me show you a PPD one, for example. I have a PPD file and then what I’m going to do is I’ll quickly run my code. And then it is actually creating, converting a PPD into a PDF document, right? And this is a PPD by the way, let me show you. Right? And then I’ll show you the output. Now it is processing, it should get completed any moment. There you go. So this is the output file, and it is in a PDF format. So let me open this, I’ll show you. So this is a PDF that got converted. So PowerPoint presentation, you know, we just turned up into a PDF file like this, right? So likewise, you can use all these words and operations that are part of PDF services API. And it’s not limited to just creating a PDF. As I said, you can optimize a PDF, right? So you can export a PDF, you can extract PDF, you can insert pages, you can linearize, right? I mean, as I said, if you have a huge size PDF, and if you want to render that on a web document, right? So let’s say, we talked about PDF service and PDF embed API. And if you want to use both of these API conjunction, then you can do that beautifully. Let’s take an example of if you have a huge PDF, huge size PDF, then it might take some time to load on the web page, right? So you can call this linearize this endpoint, then what will happen is it is going to optimize that PDF. And then once you try to render that PDF on a web page using the PDF embed API, then it will load the first page of the PDF, very quickly with a very good turnaround time. And then I guess some of the pages will get loaded in background, right? So to an end user, it will give a really good impression because it is going to create into a good user experience because you just loaded a huge size PDF on the web browser without taking much of a time, right? So these were the two API that I wanted to bounce off. And these are great technologies, please try them out. And you can go to Adobe.io to understand more about them, right? You can simply go to Adobe.io and create a credential and get along with it. So that’s all I wanted to cover today. We are right on time. Thank you for joining my session.
Additional Resources
recommendation-more-help
3c5a5de1-aef4-4536-8764-ec20371a5186