Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Not creating pdf on order save
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo268la committed Apr 29, 2022
1 parent a5014f8 commit 5f57be0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
30 changes: 4 additions & 26 deletions restapi/InvoiceGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class InvoiceGenerator {

doc
//.image("./dede_logo.png", 50, 45, { width: 50 })
//.fillColor("#444444")
.fillColor("#444444")
.fontSize(10)
.text("DeDe", 200, 50, { align: "right" })
.text("Calle Valdes Salas 26", 200, 65, { align: "right" })
Expand All @@ -39,7 +39,7 @@ class InvoiceGenerator {
}

generateCustomerInformation(doc: any) {
doc./*fillColor("#444444").*/fontSize(20).text("Invoice", 50, 160);
doc.fillColor("#444444").fontSize(20).text("Invoice", 50, 160);

this.generateHr(doc, 185);

Expand Down Expand Up @@ -185,34 +185,12 @@ class InvoiceGenerator {
}

generate(f: any) {
/*this.generateHeaders(f);
f.moveDown();*/
this.generateHeaders(f);
f.moveDown();
this.generateCustomerInformation(f);
this.generateTable(f);
this.generateFooter(f);
return f;
/*
try {
let doc = new PDFGenerator();
const fileName = this.invoice.invoiceNumber + ".pdf";
// pipe to a writable stream which would save the result into the same directory
doc.pipe(
fs.createWriteStream(path.join(__dirname, "public", "pdf", fileName))
);
this.generateHeaders(f);
doc.moveDown();
this.generateCustomerInformation(f);
this.generateTable(f);
this.generateFooter(f);
doc.
// write out file
theOutput.end();
} catch (e) {
console.log(e);
}*/
}
}

Expand Down
2 changes: 0 additions & 2 deletions restapi/orders/OrderController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { RequestHandler } from "express";
import { productModel } from "../products/Product";
import { userModel } from "../users/User";
import { createPDF } from "../utils/PDFHelper";
import { verifyWebID } from "../utils/WebIDValidation";
import { orderModel } from "./Order";

Expand Down Expand Up @@ -63,7 +62,6 @@ export const createOrder: RequestHandler = async (req, res) => {
const order = new orderModel(req.body);
updateStock(order.products);
const orderSaved = await order.save();
createPDF(orderSaved.code);
res.json(orderSaved);
} catch (error) {
console.log(error)
Expand Down
4 changes: 2 additions & 2 deletions restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ app.get(["/*.pdf"], async function (req, res) {
};

const ig = new InvoiceGenerator(invoiceData);
doc.pipe(res);
doc = ig.generate(doc);
//doc.pipe(res);
ig.generate(doc).pipe(res);
doc.end();
}else{
res.sendFile(path.join(__dirname, "public", 'pdf', "not-found.pdf"));
Expand Down

0 comments on commit 5f57be0

Please sign in to comment.