【无标题】文档转成二维码添加到公众号文章(Word、Excel、PPT、PDF等)

有公众号的小伙伴应该都知道,公众号文章中并不支持直接添加附件。小熊也有自己经营的公众号,因公众号运营需要,经常需要在公众号推文中添加附件给粉丝们下载,曾试过很多种方式:

① 阅读原文跳转文件

② 百度网盘分享文件

③ 将文件转成二维码

④ 文章中引用小程序

相信很多小伙伴都用过①、②的方式,也都知道体验并不是很好,操作麻烦不说,下载过程也不友好,对粉丝来说也是一种考验。今天小熊结合自己的使用经验,来介绍一下文件如何转成二维码放在公众号文章中给粉丝下载。第④点文章后面介绍。

其实操作很简单,只需要几步:

第一步

使用浏览器打开「文章附件」网站:https://wzfj.cc,将需要转换的文件上传到网站。

第二步

上传完成后,在文件列表中将多出一条文件记录,点击“二维码”一栏下的“查看”按钮,即可查看二维码。

第三步

把鼠标放在二维码图片上,右击鼠标,将图片保存到电脑或者手机(取决于使用什么设备),然后就可以放在公众号里面,提示用户长按二维码打开/下载文件了。

关于文章引用小程序的方式

其实就是在文章内容中添加附件小程序的方式,给公众添加附件。目前知道的人不多,但实际是比较好用的。添加到公众号文章内,就跟一个超链接一样,点击后可以直接跳转到小程序下载。在文章中是这样的:

添加后的小程序链接看起来就像是一个真正的下载链接。点开后是这样的:

点击“下载文件”,即可自动下载文件,下载完成后可以预览(支持Word、Excel、PPT和PDF,其他格式需要借助其他应用打开),也可以发送给自己,或者收藏到你的微信收藏夹。

操作也一样很简单,和上面的二维码生成步骤一样,把文件上传到网站后,将会生成一个直达链接,直接复制直达链接粘贴到公众号文章编辑器即可添加成功。感兴趣的可以去自行查阅网站内的教程。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个使用Java和iText库来批量添加二维码PDF文档的示例程序。 ```java import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Image; import com.itextpdf.layout.property.HorizontalAlignment; import com.itextpdf.layout.property.VerticalAlignment; import com.itextpdf.layout.property.UnitValue; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.geom.PageSize; import java.io.File; import java.io.IOException; import java.util.Scanner; import java.util.regex.Pattern; public class AddQRCodeToPDF { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); // 读取输入PDF文件路径和输出PDF文件路径 System.out.print("Enter input PDF file path: "); String inputPdfPath = scanner.nextLine(); System.out.print("Enter output PDF file path: "); String outputPdfPath = scanner.nextLine(); // 读取二维码文本 System.out.print("Enter QR code text: "); String qrCodeText = scanner.nextLine(); // 创建二维码图片 Image qrCodeImage = new Image(ImageDataFactory.create(QRCodeGenerator.generate(qrCodeText))) .setHorizontalAlignment(HorizontalAlignment.CENTER) .setVerticalAlignment(VerticalAlignment.MIDDLE); // 打开输入PDF文件和输出PDF文件 PdfDocument inputPdf = new PdfDocument(new PdfReader(inputPdfPath)); PdfDocument outputPdf = new PdfDocument(new PdfWriter(outputPdfPath)); // 创建文档对象 Document document = new Document(outputPdf, PageSize.A4); // 在每个页面底部中心添加二维码图片 for (int i = 1; i <= inputPdf.getNumberOfPages(); i++) { PdfPage page = inputPdf.getPage(i); Rectangle pageSize = page.getPageSize(); qrCodeImage.scaleToFit(UnitValue.createPercentValue(50)); qrCodeImage.setFixedPosition(pageSize.getWidth() / 2 - qrCodeImage.getImageScaledWidth() / 2, pageSize.getHeight() / 5, qrCodeImage.getImageScaledWidth()); document.add(new Image(page).setFixedPosition(i, 0, 0)); document.add(qrCodeImage); document.flush(); document.showTextAligned(QRCodeGenerator.getFont(), "Page " + i, 10, 10, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0); document.newPage(); } // 关闭文档对象和输入/输出PDF文件 document.close(); inputPdf.close(); outputPdf.close(); System.out.println("QR code added successfully."); } } ``` 此示例程序使用iText库读取输入PDF文件并将二维码图片添加到每个页面的底部中心。如果需要添加到其他位置,可以修改setFixedPosition方法的参数。注意,此示例程序使用QRCodeGenerator类来生成二维码图片,您需要自己实现该类。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值