Skip to main content

Overview

The PDF Generator service allows you to create PDF presentations on any topic. This is useful for:
  • Generating educational presentation slides
  • Creating topic-specific presentations
  • Producing multilingual presentations
  • Building quick presentation outlines

Create PDF Presentation

Generate a new PDF presentation on a specific topic.
import StudyfetchSDK from '@studyfetch/sdk';

const client = new StudyfetchSDK({
  apiKey: 'your-api-key',
  baseURL: 'https://studyfetchapi.com',
});

const pdfResponse = await client.v1.pdfGenerator.create({
  topic: 'Biology Chapter 1 Summary',
  numberOfSlides: 10,
  locale: 'en'
});

console.log('PDF created:', pdfResponse.presentation?._id);
console.log('Success:', pdfResponse.success);

Get All PDFs

Retrieve a list of all generated PDFs.
const pdfs = await client.v1.pdfGenerator.getAll();

pdfs.forEach(pdf => {
  console.log(`${pdf.topic} - ${pdf.createdAt}`);
  console.log(`ID: ${pdf._id}`);
  console.log(`Slides: ${pdf.numberOfSlides}`);
});

Get PDF by ID

Retrieve details of a specific PDF presentation.
const pdfId = 'pdf_123abc';
const pdf = await client.v1.pdfGenerator.getById({
  id: pdfId
});

console.log('Topic:', pdf.topic);
console.log('Created:', pdf.createdAt);
console.log('ID:', pdf._id);
console.log('Slides:', pdf.numberOfSlides);
console.log('Locale:', pdf.locale);

Delete PDF

Delete a PDF presentation.
const pdfId = 'pdf_123abc';
const response = await client.v1.pdfGenerator.delete({
  id: pdfId
});

console.log('PDF deleted:', response.success);

Complete Example

Here’s a complete example that creates a PDF presentation and retrieves its details:
import StudyfetchSDK from '@studyfetch/sdk';
import fs from 'fs';
import https from 'https';

async function createAndCheckPdf() {
  const client = new StudyfetchSDK({
    apiKey: process.env.STUDYFETCH_API_KEY,
    baseURL: 'https://studyfetchapi.com',
  });

  // 1. Create PDF presentation
  const pdfResponse = await client.v1.pdfGenerator.create({
    topic: 'Complete Biology Study Guide',
    numberOfSlides: 15,
    locale: 'en'
  });

  console.log('PDF created:', pdfResponse.presentation?._id);
  console.log('Success:', pdfResponse.success);

  // 2. Check the created presentation
  if (pdfResponse.presentation) {
    const pdf = await client.v1.pdfGenerator.getById({ 
      id: pdfResponse.presentation._id 
    });
    
    console.log('Presentation details:');
    console.log('- Topic:', pdf.topic);
    console.log('- Slides:', pdf.numberOfSlides);
    console.log('- Locale:', pdf.locale);
  }
}

createAndCheckPdf();
I