当前位置:网站首页>Using nodejs and Tencent cloud API to identify invoices
Using nodejs and Tencent cloud API to identify invoices
2022-06-23 22:16:00 【Swing a knife North】
It's the end of the year again , It's really hard to collect invoices , I am a thrifty person , Where did you get so many invoices , But a friend gave me a compressed package , Open it up , I drop a mother ,200 Multiple invoices , Taxi invoice , Accounting requires that each invoice be renamed , The naming rule is invoice code - Invoice number - amount of money - full name , This is killing me , If you don't blind one by one , I have to be tired to death , But I am a chicken programmer , Vegetable chicken must think of using programs to complete repetitive work , The first thought is how to identify invoices , Here I have come up with two solutions , The first one is to use various cloud services to realize , After reviewing various cloud services , Discover that Tencent's cloud service identification invoice function supports nodejs, So we simply used Tencent cloud , This is his demo site :
https://cloud.tencent.com/act/event/ocrdemo The page is as follows , Click to start using , Opening service :
And then apply for a couple SecretId and SecretKey:
The entrance is :https://console.cloud.tencent.com/cam/capi
preservation secretID and secretKey.
Then open the interface test website :https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=DescribeZones&SignVersion= Pictured :
Then initialize the local project , install sdk package
npm install tencentcloud-sdk-nodejsnpm
The entry file code is as follows :
// Depends on tencentcloud-sdk-nodejs version 4.0.3 or higher
const tencentcloud = require("tencentcloud-sdk-nodejs");
const OcrClient = tencentcloud.ocr.v20181119.Client;
const fs = require('fs');
const path = require('path');
let pdfBase64 = fs.readFileSync('./pdf2/012002100311-54213119-39.9- Chen Liming .pdf',{encoding:'base64'});
// console.log(pdfBase64)
const clientConfig = {
credential: {
secretId: " Yours secretId",
secretKey: " Yours secretKey",
},
region: "ap-beijing",
profile: {
httpProfile: {
endpoint: "ocr.tencentcloudapi.com",
},
},
};
const client = new OcrClient(clientConfig);
const params = {
"ImageBase64": pdfBase64,
"IsPdf": true,
"PdfPageNumber": 1
};
client.VatInvoiceOCR(params).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);In the code, my subordinates read a pdf file , This document is an invoice :
Execute the code to read the contents of the invoice , as follows :
{
Angle: 0,
Items: [
{
AmountWithoutTax: '54.95',
LineNo: '1',
Name: '* Meat and meat products *betterme Fried chicken steak with black pepper in honey sauce 700g Healthy light food fitness chicken breast fitness meal fitness food low fat substitute meal low fat ',
Quantity: '1',
Spec: ' Fried chicken with honey sauce and black pepper flavor ',
TaxAmount: '4.95',
TaxRate: '9%',
Unit: ' bag ',
UnitPrice: '54.95'
},
{
AmountWithoutTax: '-18.35',
LineNo: '2',
Name: '* Meat and meat products *betterme Fried chicken steak with black pepper in honey sauce 700g Healthy light food fitness chicken breast fitness meal fitness food low fat substitute meal low fat ',
Quantity: '',
Spec: '',
TaxAmount: '-1.65',
TaxRate: '9%',
Unit: '',
UnitPrice: ''
}
],
PdfPageSize: 1,
RequestId: '7309a02f-3120-441f-afb8-1594a25ac0f7',
VatInvoiceInfos: [
{ Name: ' Invoice code ', Polygon: [Object], Value: '012002100311' },
{ Name: ' Invoice name ', Polygon: [Object], Value: ' Tianjin VAT electronic ordinary invoice ' },
{ Name: ' Invoice number ', Polygon: [Object], Value: 'No54213119' },
{ Name: ' Invoice date ', Polygon: [Object], Value: '2021 year 12 month 10 Japan ' },
{ Name: ' Machine number ', Polygon: [Object], Value: '661911908106' },
{ Name: ' Check code ', Polygon: [Object], Value: '69982725101317621468' },
{ Name: ' Name of purchaser ', Polygon: [Object], Value: ' Beijing Huayi Innovation Information Technology Co., Ltd ' },
{
Name: ' Password area 1',
Polygon: [Object],
Value: '/8*5<56/*19<8*/23>-/4/72+81'
},
{ Name: ' Purchaser identification number ', Polygon: [Object], Value: '91110108749364121L' },
{
Name: ' Password area 2',
Polygon: [Object],
Value: '1<51<34<8*554-5-*83+>74<606'
},
{
Name: ' Password area 3',
Polygon: [Object],
Value: '456<>*10*40*26838*443/+59<7'
},
{
Name: ' Password area 4',
Polygon: [Object],
Value: '2><30*73<3379*952+4-4*2*601'
},
{
Name: ' Goods or taxable services 、 The service name ',
Polygon: [Object],
Value: '* Meat and meat products *betterme Fried chicken steak with black pepper in honey sauce 700g Healthy light food fitness chicken breast fitness meal fitness food low fat substitute meal low fat '
},
{ Name: ' Specifications and models ', Polygon: [Object], Value: ' Fried chicken with honey sauce and black pepper flavor ' },
{ Name: ' Company ', Polygon: [Object], Value: ' bag ' },
{ Name: ' Number ', Polygon: [Object], Value: '1' },
{ Name: ' The unit price ', Polygon: [Object], Value: '54.95' },
{ Name: ' amount of money ', Polygon: [Object], Value: '54.95' },
{ Name: ' tax rate ', Polygon: [Object], Value: '9%' },
{ Name: ' Tax amount ', Polygon: [Object], Value: '4.95' },
{
Name: ' Goods or taxable services 、 The service name ',
Polygon: [Object],
Value: '* Meat and meat products *betterme Fried chicken steak with black pepper in honey sauce 700g Healthy light food fitness chicken breast fitness meal fitness food low fat substitute meal low fat '
},
{ Name: ' amount of money ', Polygon: [Object], Value: '-18.35' },
{ Name: ' tax rate ', Polygon: [Object], Value: '9%' },
{ Name: ' Tax amount ', Polygon: [Object], Value: '-1.65' },
{ Name: ' Total amount ', Polygon: [Object], Value: '¥36.60' },
{ Name: ' Total tax amount ', Polygon: [Object], Value: '¥3.30' },
{ Name: ' Total price and tax ( Capitalization )', Polygon: [Object], Value: ' Thirty nine yuan and ninety Jiao ' },
{ Name: ' Amount in figures ', Polygon: [Object], Value: '¥39.90' },
{ Name: ' Name of seller ', Polygon: [Object], Value: ' Tianjin Jingdong Daye Trading Co., Ltd ' },
{ Name: ' remarks ', Polygon: [Object], Value: ' The order number :234161485025' },
{ Name: ' Seller identification number ', Polygon: [Object], Value: '91120110MA06J3WLX8' },
{
Name: ' Seller's address 、 Telephone ',
Polygon: [Object],
Value: ' Huafeng Road, Huaming high tech Industrial Zone, Dongli District, Tianjin 6 Number A2 seat 4 floor 101 room 022-26629111'
},
{
Name: ' Account opening bank and account number of the seller ',
Polygon: [Object],
Value: ' Bank of China Limited Tianjin Binhai city square sub branch 280487613780'
},
{ Name: ' payee ', Polygon: [Object], Value: ' Wang Lu ' },
{ Name: ' To review ', Polygon: [Object], Value: ' Lee thought ' },
{ Name: ' Drawer ', Polygon: [Object], Value: ' Wang Mei ' },
{ Name: ' province ', Polygon: null, Value: ' tianjin ' },
{ Name: ' Is there a company seal ', Polygon: null, Value: '1' },
{ Name: ' Invoice type ', Polygon: null, Value: ' VAT electronic invoice ' },
{ Name: ' Invoice consumption type ', Polygon: null, Value: ' service ' },
{ Name: ' Service type ', Polygon: null, Value: '' },
{ Name: ' Buyer's address 、 Telephone ', Polygon: null, Value: '' },
{ Name: ' Buyer's Bank of deposit and account number ', Polygon: null, Value: '' },
{ Name: ' Print Invoice Code ', Polygon: null, Value: '' },
{ Name: ' Print invoice number ', Polygon: null, Value: '' },
{ Name: ' Joint times ', Polygon: null, Value: '' },
{ Name: ' Whether to substitute ', Polygon: null, Value: '' },
{ Name: ' Product oil mark ', Polygon: null, Value: '' },
{ Name: ' City ', Polygon: null, Value: '' },
{ Name: ' Toll sign ', Polygon: null, Value: '' },
{ Name: ' The date of passage ends ', Polygon: null, Value: '' },
{ Name: ' From the date of passage ', Polygon: null, Value: '' },
{ Name: ' Vehicle and vessel tax ', Polygon: null, Value: '' },
{ Name: ' license plate number ', Polygon: null, Value: '' },
{ Name: ' type ', Polygon: null, Value: '' }
]
}Tencent cloud gives away free resources ,
What needs to be noted here is , You need to change the payment mode to post payment :
Post payment settings ( It can only be changed once a month , The next day after the change 0 Point effective ) You have opened the post payment mode , When your resource package is exhausted, the additional calls will be paid later , Automatic monthly settlement . View the resource package stock .
The above is to experience the VAT invoice function of Tencent cloud character recognition , I hope it helped you .
边栏推荐
- What do you know about the 15 entry-level applets
- How to defend the security importance of API gateway
- How ppt creates a visual chart
- Benchclock: a benchmark for evaluating semantic analysis language models
- Environment construction of go language foundation
- 2021-12-19: find the missing numbers in all arrays. Give you an n
- The 11th Blue Bridge Cup
- Take you to understand the lazy loading of pictures
- How to do API gateway routing? What are the other functions of API gateway?
- ACL2022 | MVR:面向开放域检索的多视角文档表征
猜你喜欢

Error running PyUIC: Cannot start process, the working directory ‘-m PyQt5. uic. pyuic register. ui -o

ICML2022 | 基于对比学习的离线元强化学习的鲁棒任务表示

Icml2022 | robust task representation for off-line meta reinforcement learning based on contrastive learning

How to improve the content quality of short video, these four elements must be achieved

Intel openvino tool suite advanced course & experiment operation record and learning summary

ACL2022 | MVR:面向开放域检索的多视角文档表征

北大、加州伯克利大学等联合| Domain-Adaptive Text Classification with Structured Knowledge from Unlabeled Data(基于未标记数据的结构化知识的领域自适应文本分类)

从CVPR 2022看域泛化(Domain Generalization)最新研究进展

Teacher lihongyi from National Taiwan University - grade Descent 2

万字长文!一文搞懂InheritedWidget 局部刷新机制
随机推荐
How does the hybrid cloud realize the IP sec VPN cloud networking dedicated line to realize the interworking between the active and standby intranet?
How does the fortress remote login server operate? What is the application value of Fortress machine?
JWT implementation
Deep understanding of leakcanary
How to deploy the API gateway? Is it OK not to use the API gateway?
How to configure Nessus vulnerability scanning policy?
Recommend several idea plug-ins
Error message - Customizing incorrectly maintained – in transaction code ML81N
How to defend the security importance of API gateway
TMUX support, file transfer tool Trz / Tsz (trzsz) similar to RZ / SZ
How ppt creates a visual chart
How API gateway finds the role of microserver gateway in microservices
The "Star" industry in the small town is escorted by wechat cloud hosting
Introduction to scikit learn machine learning practice
Teacher lihongyi from National Taiwan University - grade Descent 2
How to build an API gateway and how to maintain an API gateway?
Bi SQL constraints
How do fortress computers log in to the server? What is the role of the fortress machine?
How to set the life cycle of API gateway
[log service CLS] one click to start the efficient operation and maintenance journey of Tencent E-Sign