VOOZH about

URL: https://ironpdf.com/python/blog/python-help/deepstream-io/

⇱ deepstream io (How it Works for Developers)


Skip to footer content
  1. IronPDF for Python
  2. IronPDF for Python Blog
  3. Python Help
  4. deepstream io
PYTHON HELP

deepstream io (How it Works for Developers)

A real-time server is designed to respond to data instantly, making it instantly responsive to every user interaction or system event. Unlike conventional request-response servers that introduce delays, real-time [servers](https://en.wikipedia.org/wiki/Server_(computing) use technologies and protocols to ensure continuous information exchange and instantaneous updates. It's because a real-time server is critical to several applications requiring live communications: messaging systems, online gaming, financial trading platforms, and collaborative tools. In this article, we are going to learn how to use the open real-time server deepstream and IronPDF to generate PDFs.

deepstream.io is a scalable, real-time server for data synchronization and many-to-many messaging. It can handle data with ease and keep many clients synchronized with really low latency, supporting binary data transfer. deepstream.io is designed to be put behind other load balancing and balancers and offers an efficient way to sync data and keep resource files up to date, which makes it perfectly suited for applications updating data in real-time and in search of a scalable server solution.

πŸ‘ deepstream io (How it Works for Developers): Figure 1 - deepstream.io

deepstream.io implementation by developers can easily allow live updates, collaborative applications, and interactive experiences in real-time, without starting from scratch. It has been architected for high loads and efficient scaling, making it the software of choice for high-concurrency applications. deepstream.io is flexible and may turn out to be the perfect addition to your stack in multiple different ways. It provides a complete solution to allow users to create real-time, responsive, and interactive web and mobile apps.

To create a new Node.js directory enter the following commands in the console:

mkdir deepstream-project
cd deepstream-project
npm init -y
mkdir deepstream-project
cd deepstream-project
npm init -y
SHELL

Install deepstream.io Package

First of all, you need to install deepstream.io. You can either use NPM to install it or download the binaries from the official website.

npm install @deepstream/server
npm install @deepstream/server
SHELL

Basic Configuration of deepstream.io

const { Deepstream } = require('@deepstream/server');

// Create a new Deepstream server instance
const server = new Deepstream({});

// Start the server to listen for client connections
server.start();
const { Deepstream } = require('@deepstream/server');

// Create a new Deepstream server instance
const server = new Deepstream({});

// Start the server to listen for client connections
server.start();
JAVASCRIPT

The code snippet above demonstrates how to set up and start a deepstream.io server using the @deepstream/server package in Node.js. It first imports the Deepstream class from the package, then creates a new instance. By calling server.start(), the server is started and is ready to accept incoming connections for handling real-time data binding, messaging, or presence backend services.

Connecting Deepstream with Client

const { DeepstreamClient } = require('@deepstream/client');

// Connect to a local deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server without credentials (suitable for servers without authentication)
client.login(null);
const { DeepstreamClient } = require('@deepstream/client');

// Connect to a local deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server without credentials (suitable for servers without authentication)
client.login(null);
JAVASCRIPT

The code above demonstrates how to connect to deepstream using the @deepstream/client library. This script imports the DeepstreamClient class, creates an instance, and connects it to a deepstream server running locally on IP address 127.0.0.1 on port 6020. It logs in without credentials, which is sufficient if the server does not use authentication or if it's used for test cases. This setup initializes a client capable of real-time data synchronization and communication.

Once the connection with the server node is established, a message similar to the one below will appear in the server console.

πŸ‘ deepstream io (How it Works for Developers): Figure 2 - Console Message

Using Listener with deepstream.io

Below is a sample code which can be used to create listeners, one of the core concepts of deepstream.

const { DeepstreamClient } = require("@deepstream/client");

// Connect to the Deepstream server
const client = new DeepstreamClient("127.0.0.1:6020");

// Log in to the server
client.login(null, (success, clientData) => {
 if (success) {
 const event = client.event;
 // Publish a custom event
 event.publish("custom-event", { message: "Hello, Deepstream!" });
 }
});
const { DeepstreamClient } = require("@deepstream/client");

// Connect to the Deepstream server
const client = new DeepstreamClient("127.0.0.1:6020");

// Log in to the server
client.login(null, (success, clientData) => {
 if (success) {
 const event = client.event;
 // Publish a custom event
 event.publish("custom-event", { message: "Hello, Deepstream!" });
 }
});
JAVASCRIPT

In the above code, the client logs into a deepstream server hosted on 127.0.0.1:6020 using the @deepstream/client library. Upon successful authentication, it publishes a custom event named "custom-event" with a payload { message: "Hello, Deepstream!" }.

Introducing IronPDF

Use IronPDF, an incredibly strong Node.js package, to create, edit, convert, and edit PDF documents. It is a tool used in the majority of programming-based processes on PDFs, and backend processes such as modifying pre-existing PDFs and converting HTML into PDFs. In applications where the dynamic creation and handling of PDFs are necessary, IronPDF becomes very helpful. It provides a user-friendly and flexible manner in which to generate quality PDF documents.

πŸ‘ deepstream io (How it Works for Developers): Figure 3 - IronPDF

Install IronPDF package

Use npm to download and install packages that enable Node.js IronPDF capability.

npm install @ironsoftware/ironpdf
npm install @ironsoftware/ironpdf
SHELL

PDF Generation Function

Create a function that uses IronPDF to generate PDFs:

const IronPdf = require('@ironsoftware/ironpdf');
const { PdfDocument } = IronPdf;

// Set IronPDF configuration, replacing 'YOUR_LICENSE_KEY' with your actual license key
const config = IronPdf.IronPdfGlobalConfig;
config.setConfig({ licenseKey: 'YOUR_LICENSE_KEY' });

async function generatePDF(title, content) {
 try {
 // Generate PDF from HTML content
 const pdf = await PdfDocument.fromHtml(`<html><body><h1>${title}</h1><p>${content}</p></body></html>`);
 return await pdf.saveAsBuffer();
 } catch (error) {
 console.error('Error generating PDF:', error);
 throw error;
 }
}

module.exports = generatePDF;
const IronPdf = require('@ironsoftware/ironpdf');
const { PdfDocument } = IronPdf;

// Set IronPDF configuration, replacing 'YOUR_LICENSE_KEY' with your actual license key
const config = IronPdf.IronPdfGlobalConfig;
config.setConfig({ licenseKey: 'YOUR_LICENSE_KEY' });

async function generatePDF(title, content) {
 try {
 // Generate PDF from HTML content
 const pdf = await PdfDocument.fromHtml(`<html><body><h1>${title}</h1><p>${content}</p></body></html>`);
 return await pdf.saveAsBuffer();
 } catch (error) {
 console.error('Error generating PDF:', error);
 throw error;
 }
}

module.exports = generatePDF;
JAVASCRIPT

Set Up the Deepstream Client

Write a JavaScript script that will listen for data in real-time and generate PDFs based on that data:

const { DeepstreamClient } = require('@deepstream/client');
const generatePDF = require('./generatePdf'); // Path to your PDF generation function

// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server
client.login(null, async (success) => {
 if (success) {
 console.log('Deepstream connected successfully');
 // Listen for a custom event to trigger PDF generation
 const event = client.event;
 event.subscribe('generate-pdf', async (data) => {
 const { title, content } = data;
 if (!title || !content) {
 console.error('Missing title or content for PDF generation');
 return;
 }
 try {
 // Generate the PDF
 const pdfBuffer = await generatePDF(title, content);
 // Handle the PDF buffer (e.g., save to file, send over network)
 console.log('PDF generated successfully');
 // Example: Save PDF to a file (optional)
 const fs = require('fs');
 fs.writeFileSync('generated.pdf', pdfBuffer);
 } catch (error) {
 console.error('Error generating PDF:', error);
 }
 });
 } else {
 console.error('Failed to connect to Deepstream');
 }
});
const { DeepstreamClient } = require('@deepstream/client');
const generatePDF = require('./generatePdf'); // Path to your PDF generation function

// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server
client.login(null, async (success) => {
 if (success) {
 console.log('Deepstream connected successfully');
 // Listen for a custom event to trigger PDF generation
 const event = client.event;
 event.subscribe('generate-pdf', async (data) => {
 const { title, content } = data;
 if (!title || !content) {
 console.error('Missing title or content for PDF generation');
 return;
 }
 try {
 // Generate the PDF
 const pdfBuffer = await generatePDF(title, content);
 // Handle the PDF buffer (e.g., save to file, send over network)
 console.log('PDF generated successfully');
 // Example: Save PDF to a file (optional)
 const fs = require('fs');
 fs.writeFileSync('generated.pdf', pdfBuffer);
 } catch (error) {
 console.error('Error generating PDF:', error);
 }
 });
 } else {
 console.error('Failed to connect to Deepstream');
 }
});
JAVASCRIPT

Publishing Events to Trigger PDF Generation

Events can be published to trigger PDF generation from another JavaScript file or part of your application:

const { DeepstreamClient } = require('@deepstream/client');

// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server
client.login(null, () => {
 const event = client.event;
 // Publish a custom event with title and content
 event.publish('generate-pdf', {
 title: 'Sample PDF Title',
 content: 'This is the content of the PDF document.'
 });
});
const { DeepstreamClient } = require('@deepstream/client');

// Connect to the Deepstream server
const client = new DeepstreamClient('127.0.0.1:6020');

// Log in to the server
client.login(null, () => {
 const event = client.event;
 // Publish a custom event with title and content
 event.publish('generate-pdf', {
 title: 'Sample PDF Title',
 content: 'This is the content of the PDF document.'
 });
});
JAVASCRIPT

Deepstream.io is implemented by listening to real-time events that will trigger the PDF generation. The generatePDF function creates a PDF document based on data from Deepstream.io events using IronPDF. The DeepstreamClient subscribes to these events, and whenever relevant events are published, it calls the PDF generation function. Such integration allows the dynamic generation of PDFs in real-time based on event occurrences, requests, or data changes.

πŸ‘ deepstream io (How it Works for Developers): Figure 4 - PDF Output

Licensing

For the code to compile and function without a watermark, a licensing key is required. Developers who would like a trial license can register here. Obtaining one does not need presenting a credit card. All you have to do to sign up for a free trial is enter your email address.

Conclusion

One of the strongest real-time data handling and dynamic document generation solutions is achieved through a combination of deepstream.io and IronPDF. deepstream.io synchronizes changes and records all events in real-time, thus it can react right away to any change in data. IronPDF provides a robust mechanism for creating professional documents on the fly. This integration will enable your applications to automatically create and process PDF documents not only when live data changes but also whenever a user interacts with your application.

Whether it's report generation, invoices, or any other document type, deepstream.io integrated with IronPDF enables workflow simplification, responsive document creation, and keeps your application lean and current with real-time information. This pairing works best for agile, data-driven, and responsive applications that demand real-time document generation and management support.

The libraries provided by Iron Software enable us to create programs quickly and easily for a variety of operating systems, browsers, and platforms, including Windows, Android, MAC, Linux, etc.

Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More

Related Articles

Updated

imageio python (How it Works for Developers)

we will look into how Imageio can be used to read and write images, later we will also look into IronPDF from Iron Software to generate PDF documents

Read More

Updated

igraph python (How it Works for Developers)

In this article, we use igraph to show how you can generate network graphs and print them into a PDF file using the flexible and reliable IronPDF library.

Read More

Install with pip
Version: 2026.6
 pip install ironpdf
  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Download Module
Version: 2026.6
Download Now
Manually install into your project
  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.6-py37-none-win_amd64.whi
Licenses from $749

Have a question? Get in touch with our development team.

Now you've installed with PyPi
Your browser is now downloading IronPDF

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support

Thank You

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:
πŸ‘ badge_greencheck_in_yellowcircle
The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Have a question? Get in touch with our development team.
No credit card or account creation required
Now you've installed with PyPi
Your browser is now downloading IronPDF

Next step: Start free 30-day Trial

No credit card required

  • Test in a live environment
  • Fully-functional product
  • 24/5 technical support
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
Talk to Sales Team

Book a No-obligation Consult

How we can help:
  • Consult on your workflow & pain points
  • See how other companies solve their .NET document needs
  • All your questions answered to make sure you have all the information you need. (No commitment whatsoever.)
  • Get a tailored quote for your project's needs
Get Your No-Obligation Consult

Complete the form below or email sales@ironsoftware.com

Your details will always be kept confidential.

Trusted by Millions of Engineers Worldwide
Book Free Live Demo

Book a 30-minute, personal demo.

No contract, no card details, no commitments.

Here's what to expect:
  • A live demo of our product and its key features
  • Get project specific feature recommendations
  • All your questions are answered to make sure you have all the information you need.
    (No commitment whatsoever.)
CHOOSE TIME
YOUR INFO
Book your free Live Demo

Trusted by Millions of Engineers Worldwide

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me