Skip to content

Commit

Permalink
fix: nusuk umrah hos-000 (#208)
Browse files Browse the repository at this point in the history
* fix: nusuk umrah hos-000

* v
  • Loading branch information
hajonsoft authored Feb 27, 2024
1 parent 6e62348 commit 178a033
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 234 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"codeline",
"mofa",
"Mutamer",
"Nusuk",
"travellers"
]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hajonsoft-eagle",
"version": "2.6.14",
"version": "2.6.15",
"description": "HAJonSoft node app to submit passengers to visa systems",
"main": "index.js",
"scripts": {
Expand Down
117 changes: 74 additions & 43 deletions play.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const axios = require('axios');
const { PDFDocument, StandardFonts } = require('pdf-lib');
const fs = require('fs');
const axios = require("axios");
const { PDFDocument, StandardFonts } = require("pdf-lib");
const fs = require("fs");

// const url = 'https://bsp-nusuk.haj.gov.sa/Home/DownloadInsuranceDocument/?MutamerMofa=105848936';

Expand Down Expand Up @@ -317,8 +317,6 @@ const fs = require('fs');
// }
// }



// const folder = path.join(__dirname, "../../..", 'Downloads/liberia', "photos")
// const files = fs.readdirSync(folder);
// for (const file of files) {
Expand All @@ -344,12 +342,12 @@ const fs = require('fs');
// // if (sc.children) {
// // fs.writeFileSync('ayman' + i + '.html', JSON.stringify(sc.children))
// // }

// // if (sc.content.includes("bobj.crv.writeWidget")) {
// // }
// }
// //

// //
// return bauView;

// }
Expand Down Expand Up @@ -380,39 +378,72 @@ const fs = require('fs');
// const data = importMofa(root)
// console.log('%cMyProject%cline:342%cmofas', 'color:#fff;background:#ee6f57;padding:3px;border-radius:2px', 'color:#fff;background:#1f3c88;padding:3px;border-radius:2px', 'color:#fff;background:rgb(237, 222, 139);padding:3px;border-radius:2px', data)

// const MAILGUN_API_KEY = 'pubkey-1dacae088983b8e14d45ea3e49a79c84';
// const DOMAIN = 'your-domain.com';

// const newEmailAddress = '[email protected]';

// const data = {
// priority: 0,
// description: `Forwarding email to ${newEmailAddress}`,
// expression: `match_recipient('${newEmailAddress}')`,
// action: `forward('[email protected]')`
// };

// axios({
// method: 'post',
// url: `https://api.mailgun.net/v3/${DOMAIN}/routes`,
// auth: {
// username: 'api',
// password: MAILGUN_API_KEY
// },
// data: data
// })
// .then(response => {
// console.log(response.data);
// })
// .catch(error => {
// console.log(error);
// });

const MAILGUN_API_KEY = 'pubkey-1dacae088983b8e14d45ea3e49a79c84';
const DOMAIN = 'your-domain.com';

const newEmailAddress = '[email protected]';

const data = {
priority: 0,
description: `Forwarding email to ${newEmailAddress}`,
expression: `match_recipient('${newEmailAddress}')`,
action: `forward('[email protected]')`
};

axios({
method: 'post',
url: `https://api.mailgun.net/v3/${DOMAIN}/routes`,
auth: {
username: 'api',
password: MAILGUN_API_KEY
},
data: data
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});








const sharp = require("sharp");

// Path to the input image
const imagePath = "input.jpg";
// Text to be added at the bottom
const textLine1 = "P<INDKHAN<<VASIM<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
const textLine2 = "Y5252725<2IND9601019M33113072068702785423<02";
const encodedTextLine1 = textLine1.replace(/</g, '&lt;')
const encodedTextLine2 = textLine2.replace(/</g, '&lt;');

async function makeImage() {
const metaData = await sharp(imagePath).metadata();
const height = Math.floor(metaData.height / 4);
// SVG markup with encoded text
const mrzImage = `
<svg width="${metaData.width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
<!-- Background rectangle -->
<rect fill="white" x="0" y="0" width="${metaData.width}" height="${height}" />
<text x="60" y="140" font-family="Ariel" font-size="50" fill="black">
${encodedTextLine1}
</text>
<text x="60" y="230" font-family="Ariel" font-size="50" fill="black">
${encodedTextLine2}
</text>
</svg>
`;

const mrzBuffer = Buffer.from(mrzImage);
await sharp(imagePath)
.composite([
{
input: mrzBuffer,
top: metaData.height - height, // Position at the bottom of the image
left: 0,
},
])
.png()
.toFile("output.png");
}

makeImage();
Loading

0 comments on commit 178a033

Please sign in to comment.