第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iText 7 - 重新生成使用 Adob??e 創(chuàng)建的條碼字段

iText 7 - 重新生成使用 Adob??e 創(chuàng)建的條碼字段

千萬里不及你 2023-05-17 16:52:56
我來找你是因為我有一個問題!我使用 Adobe Acrobat 在 acroform PDF 中創(chuàng)建了條碼。我可以將新值設(shè)置為 barCode 字段,但我無法使用新值生成新的“外觀”。我怎樣才能做到這一點 ?這就是我現(xiàn)在做的沒有成功......:PdfFormField field = fields.get("QRCODE");field.setValue(this.generateXMLDataMatrix(),false);form = form.setNeedAppearances(true);form.flattenFields();pdf.close();    所以現(xiàn)在,我仍然擁有在 Adobe Acrobat 中創(chuàng)建的默認外觀 :(謝謝你的幫助 !:)
查看完整描述

2 回答

?
慕桂英3389331

TA貢獻2036條經(jīng)驗 獲得超8個贊

您將必須手動生成字段外觀。這是一個如何為 QR 碼執(zhí)行此操作的示例:


PdfFormField field = fields.get("QRCODE");

// Get the annotation. If you might have multiple representations of the same field across the document the just iterate over all widgets

PdfWidgetAnnotation annotation = field.getWidgets().get(0);

// This class will help us draw the barcode

BarcodeQRCode qrCode = new BarcodeQRCode(this.generateXMLDataMatrix());

// Get the number of rectangles constituting the barcode

Rectangle size = qrCode.getBarcodeSize();

// Creating a new FormXObject that will become our apperance. Set the dimension(bbox) of the current appearance

PdfFormXObject newAppearance = new PdfFormXObject(annotation.getAppearanceObject(PdfName.N).getAsRectangle(PdfName.BBox));

// Helper class to draw on FormXObject

PdfCanvas barcodeCanvas = new PdfCanvas(newAppearance, pdfDocument);

// Calculating the side of the smaller rectangle in the barcode

float side = Math.min(annotation.getRectangle().toRectangle().getHeight() / size.getHeight(),

        annotation.getRectangle().toRectangle().getWidth() / size.getWidth());

// Draw the barcode on the XObject

qrCode.placeBarcode(barcodeCanvas, ColorConstants.BLACK, side);

// Set appearance to the newly generated one

annotation.setAppearance(PdfName.N, newAppearance.getPdfObject());


查看完整回答
反對 回復(fù) 2023-05-17
?
12345678_0001

TA貢獻1802條經(jīng)驗 獲得超5個贊

解決了!這就是我最終做到的:


    //Generate BarCodedataMatrix

    BarcodeDataMatrix dataMatrix = new BarcodeDataMatrix();

    //Add code to the BarCodedataMatrix

    dataMatrix.setCode(generateXMLDataMatrix());

    dataMatrix.setOptions(BarcodeDataMatrix.DM_AUTO);

    //Add dataMatrix to PDF

    //Create a canvas for the first page

    PdfCanvas canvas = new PdfCanvas(pdf.getFirstPage());

    //Create the PdfFormXObject based on the dataMatrix

    PdfFormXObject object = dataMatrix.createFormXObject(pdf);

    //Add the pdfFormXObject to the canvas at X,Y position

    canvas.addXObject(object,50,660);


查看完整回答
反對 回復(fù) 2023-05-17
  • 2 回答
  • 0 關(guān)注
  • 273 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號