PdfBox 1.8'den 2.0.0'a yeni geçtim ve oldukça önemli farklılıklar var. Mevcut bir pdf sayfası üzerine bir metin yazmadan önce drawString kullandım. 2.0.0 çizim dizesinde kullanımdan kaldırılmıştır ancak showText bir blok metinde çalışmaz.PdfBox 2.0.0 bir sayfada verilen yazıyı yazınız
1.8 My kod:
contentStream.beginText()
contentStream.moveTextPositionByAmount(250, 665)
contentStream.drawString("1 2 3 4 5 6 7 8 9 1 0")
contentStream.endText()
Kodum 2.0
PDDocument newPdf=null
newPdf=PDDocument.load(sourcePdfFile)
PDPage firstPage=newPdf.getPage(0)
PDPageContentStream contentStream = new PDPageContentStream(newPdf, firstPage, PDPageContentStream.AppendMode.APPEND,true,true)
contentStream.setFont(pdfFont, fontSize)
contentStream.beginText()
contentStream.lineTo(200,685)
contentStream.showText("John")
contentStream.endText()
yılında Ama çalışıyor gelmez ...
Herkes Metin olarak yazabilirsiniz konusunda bir fikri yok Bir satır çizmek için 1.8
Ne iki satırı eklemek istiyorsanız? Örneğin. contentStream.newLineAtOffset (200.685); contentStream.showText ("John"); contentStream.newLineAtOffset (200.785); contentStream.showText ("Doe")? BeginText() ve endText() yapmak için her zaman var mı? –
Hayır, –
yapmanıza gerek yok Bu şekilde yapıyorum, çalışmıyor: contentStream.beginText() contentStream.newLineAtOffset (200,685); contentStream.showText ("John") contentStream.newLineAtOffset (250, 665); contentStream.showText ("1 2 3 4 5 6 7 8 9 1 0") contentStream.endText() –