MongoDB
 sql >> डेटाबेस >  >> NoSQL >> MongoDB

किसी भी एनपीएम पैकेज का उपयोग करके डेटाबेस से गतिशील छवि पथ के साथ पीडीएफ कैसे उत्पन्न और डाउनलोड करें

आप pdfkit नामक एक लोकप्रिय नोड मॉड्यूल का उपयोग कर सकते हैं . कृपया नीचे दिए गए प्रोग्राम को चलाएं और इसे जांचें। आपको pro.jpg . नाम की एक इमेज चाहिए उसी फ़ोल्डर में जिसमें आप स्क्रिप्ट चलाते हैं। यह एक output.pdf उत्पन्न करेगा फ़ाइल।

यहाँ उदाहरण है:

const PDFDocument = require('pdfkit');
const fs = require('fs');

// Create a document
const doc = new PDFDocument();

// Pipe its output somewhere, like to a file or HTTP response
// See below for browser usage
doc.pipe(fs.createWriteStream('output.pdf'));

// Add an image, constrain it to a given size, and center it vertically and horizontally
doc.image('pro.jpg', {
  fit: [250, 300],
  align: 'center',
  valign: 'center'
});

// Add another page
doc
  .addPage()
  .fontSize(25)
  .text('Here is some vector graphics...', 100, 100);

// Draw a triangle
doc
  .save()
  .moveTo(100, 150)
  .lineTo(100, 250)
  .lineTo(200, 250)
  .fill('#FF3300');

// Apply some transforms and render an SVG path with the 'even-odd' fill rule
doc
  .scale(0.6)
  .translate(470, -380)
  .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
  .fill('red', 'even-odd')
  .restore();

// Add some text with annotations
doc
  .addPage()
  .fillColor('blue')
  .text('Here is a link!', 100, 100)
  .underline(100, 100, 160, 27, { color: '#0000FF' })
  .link(100, 100, 160, 27, 'http://google.com/');

// Finalize PDF file
doc.end();



  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. MongoDB को लाइक के साथ कैसे क्वेरी करें

  2. MongoDB में दस्तावेज़ अपडेट करें

  3. जाँच करें कि क्या दस्तावेज़ es7 async/प्रतीक्षा का उपयोग करके मोंगोडब में मौजूद है

  4. मोंगोडब के साथ फजी सर्चिंग?

  5. सिद्धांत और MongoDB के साथ भंडारण सरणी