java pdfbox,使用PDFBox从Java编辑PDF

I am currently getting a page from a PDF and then trying to edit that particular page.

When i do the edit it is not saving within the PDF itself.

This is my code could someone please help.

PDPage page = (PDPage) allPages.get(f);

System.out.println(page);

PDRectangle pageSize = page.findMediaBox();

float stringWidth = font.getStringWidth( "AAA" );

float centeredPosition = (pageSize.getWidth() - (stringWidth*fontSize)/1000f)/2f;

PDPageContentStream contentStream = new PDPageContentStream(pdoc,page,true,false);

contentStream.beginText();

contentStream.setFont( font, fontSize );

//contentStream.addLine(700, 700, 700, 1000);

contentStream.moveTextPositionByAmount(0 , 0);

contentStream.drawString( "AAA" );

contentStream.endText();

contentStream.close();

pdoc.save("C:/1/1.pdf");

pdoc.close();

解决方案

The code is with which I am doing this is correct.

The problem is not the code but the way the pdfs are being generated are at a Version 1.2.

I would need to be able know what I can do to alter PDFs that are one V 1.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值