![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Build for Web and Backend 💪
If this package helped you out please star us on Github!
Much appreciated!
Using npm:
$ npm install easypdf-io --save
Using yarn:
$ yarn add easypdf-io
Using unkpg CDN:
<script src="https://unpkg.com/easypdf-io/dist/easypdf-io.min.js"></script>
Html
<script src="https://unpkg.com/easypdf-io/dist/easypdf-io.min.js"></script>
CommonJS
var pdf = require('easypdf-io');
ES6
import pdf from 'easypdf-io';
# HTTPS POST
https://api.easypdf.io/v2/free/pdf
# POST Data
Format: JSON
Structure: {"data":{"html":""}} # Parent object must be 'data'
//Import the library into your project
var pdf = require('easypdf-io');
// Prepare your PDF content using HTML
var html = '<p>Hello world!</p>';
var data = {
// btoa === base64 encode
html: btoa(html), // Must be base64 encoded html. This example contains 'Hello World!' in base64
background: "https://public.easypdf-io.io/img/watermark-draft.jpg",
settings: {
// "margin-top": 25, // Default to 25
// "margin-right": 25, // Default to 25
// "margin-left": 25, // Default to 25
// "margin-bottom": 25, // Default to 25
// "format": "Letter" // Defaults to A4, options: A3, A4, A5, Legal, Letter, Tabloid
},
};
//Create your PDF! Easy!
pdf.create(data, function (result) {
// The response will contain a base64 encoded PDF file
// Using the below line we can decode the base64 and store the file locally
fs.writeFileSync("sample.pdf", result.pdf, 'base64');
});
Key | Value | Data Type |
---|---|---|
result.pdf | The PDF file as base64 string | String |
The background and url inputs accept either a URL or a base64 encoded file.
Supported file types:
const data = {
background: "https://public.easypdf.io/img/watermark_draft.jpg"
};
const data = {
//Note: Sample base64 string
//Please use the link below to convert your image to base64
background: "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
};
//Import fs to be able to read from the local file system
var fs = require("fs");
var pdf = require('easypdf-io');
//Use the code below to read your local file as a base64 string
const data = {
background: fs.readFileSync('images/background.png', 'base64')
};
Click here for an online tool to convert an image to base64
var fs = require('fs');
var pdf = require('easypdf-io');
var html = btoa('<p>Hello world!</p>');
const result = await pdf.create({html});
await fs.writeFileSync("sample.pdf", result.pdf, 'base64');
Using callback
var pdf = require('easypdf-io');
var html = btoa('<p>Hello world!</p>');
pdf.create({html}, function (result) {
pdf.download('sample.pdf', result.pdf);
// you can download like this as well:
// pdf.download();
// pdf.download('sample.pdf');
});
Using async/await
var pdf = require('easypdf-io');
var html = btoa('<p>Hello world!</p>');
const result = await pdf.create({html});
pdf.download('sample.pdf', result.pdf);
// you can download like this as well:
// pdf.download();
// pdf.download('sample.pdf');
html
<!-- Only include when rendering is required -->
<script src="https://unpkg.com/pdfjs-dist/build/pdf.min.js"></script>
<script src="https://unpkg.com/pdfjs-dist/build/pdf.worker.min.js"></script>
<!-- Include pdfjs version 2.3.200 for Internet Explorer compatibility, no worker required -->
<!-- <script src="https://unpkg.com/pdfjs-dist@2.3.200/build/pdf.min.js"></script> -->
<!-- The pdf will be rendered within this div -->
<div id="pdf"></div>
css (optional)
#pdf {
text-align: center;
}
#pdf canvas {
border: 1px solid black;
width: 95%;
}
js: Using Callback
var html = btoa('<p>Hello world!</p>');
var elementId = 'pdf';
pdf.create({html}, function (result) {
pdf.render(elementId, result.pdf, function () {
console.log('PDF rendered!');
});
});
js: Using async/await
var html = btoa('<p>Hello world!</p>');
const elementId = 'pdf';
const result = await pdf.create({html});
await pdf.render(elementId, result.pdf);
FAQs
Easily create beautiful pdf documents.
The npm package easypdf-io receives a total of 2 weekly downloads. As such, easypdf-io popularity was classified as not popular.
We found that easypdf-io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.