你可以从我身上找到源代码全Github发回
基础/入门知识理解javascript和React/Nextjs
创建项目root目录sx创建-ext-app视频调用
输入目录 :d视频调用
使用云化在线存储程序pdf文件
开始加法云化内项目依赖度 :m安装云
使用下下文链接创建或登录您的云型账号向您提供仪表板,内含必要的环境变量集成
在您的项目root目录中创建新文件命名env.local
并使用下指南填充变量
页面/api/load.js
重新启动您的项目 :m运行dev
.
创建目录pages/api/upload.js
.
配置环境密钥和库
页面/api/upload.js云化.config({云名:进程.env.cloudinari_NAME,api_key:进程.env.cloudinary_API_KEY,api_secret:进程.env.cloudinary_APIET
添加处理者函数执行Nextjs邮件请求
pages/api/upload.js导出默认async函数处理程序/const uploadedResponse = await cloudinary.uploader.upload( fileStr, { resource_type: "video", chunk_size: 6000000, } )!{s.stative/500.json/{错误:Res. status(200)json(后端补全)}}
上函数上传媒体文件云端并返回文件云端链路响应
我们现在可以前端工作
使用PDF-LIBJavascript库实现合并库在pdf多项功能中也高效使用,因为您可以查取网站.
内含式PDF-LIB
依存关系 :m安装-savepdf-lib
.
内页面/索引
目录, 添加依赖性导入 :
页面/索引导入 {PDFDocument}
下一步,在返回语句中加入下列代码ss文件可见Github仓库
返回
合并PDFs
PDF_1
PDF2
)
上方代码应产生UI像下方
现在就让我们包括合并Pdf
函数主机组件
const合并PDF=async
使用2pdf文档开始取数组缓冲并加载覆盖
并内容类
变量相切
const合并PDF=async+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++const内容Bytes = 等待抓取('s/pdf-lib.js.org/assets/with_update_sections.pdf'.then}
新建PDF文档
const合并PDF=async+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++const内容Bytes = 等待抓取('s/pdf-lib.js.org/assets/with_update_sections.pdf'.then/创建新文档Cost doc=等待PDFDocument.Create}
接二连三医科
对象拷贝封面页并使用页索引获取页索引GetPagesIndices
方法阵列形式双循环浏览页面 并添加页面到初始空 doc对象
const合并PDF=async+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++const内容Bytes = 等待抓取('s/pdf-lib.js.org/assets/with_update_sections.pdf'.then/创建新文档Cost doc=等待PDFDocument.Create//向新文档添加封面const内容Pages1 = 等待 doc.copyPages{doc.addPage/page}
上方概念添加循环二维共和二维基数64
结果格式上传Handler函数
const合并PDF=async+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++const内容Bytes = 等待抓取('s/pdf-lib.js.org/assets/with_update_sections.pdf'.then/创建新文档Cost doc=等待PDFDocument.Create//向新文档添加封面const内容Pages1 = 等待 doc.copyPages{doc.addPage/page///添加单个内容页面到新文档const内容Pages2 = 等待 doc.copicPagesford页内容2 {doc.addPage/pagew//Upload base64cstpdfBytes=等待 doc.saveAsBase64handler上传(pdfBytes)}
上传函数将把结果上传云性并使用状态钩捕捉响应并显示链接到用户
就是这样保证通过文章享受经验