Yes, using the latest version.
full function:
public static boolean JBS_AddTextSignature(String text,String sourceName, String targetName)
{
try
{
Document pdfDocument = new Document(sourceName);
pdfDocument.getForm().setType(FormType.Standard);
pdfDocument.removeMetadata();
pdfDocument.flatten();
pdfDocument.save(targetName +"_fixed.pdf");
pdfDocument = new Document(targetName +"_fixed.pdf");
// create text stamp
TextStamp textStamp = new TextStamp(text);
// set whether stamp is background
textStamp.setBackground(true);
// set origin
textStamp.setXIndent(600);
textStamp.setYIndent(48);
// rotate stamp
textStamp.setRotate(Rotation.on90);
// set text properties
textStamp.getTextState().setFont(FontRepository.findFont("Arial"));
textStamp.getTextState().setFontSize(12.0F);
for (int Page_counter = 1; Page_counter <= pdfDocument.getPages().size(); Page_counter++) {
// add stamp to all pages of PDF file
pdfDocument.getPages().get_Item(Page_counter).addStamp(textStamp);
System.out.println("Added");
}
// save output document
pdfDocument.save(targetName);
return true;
}
catch(Exception e)
{
return false;
}
}<a class="attachment" href="/uploads/default/79372">wordTest2.pdf_fixed.pdf</a> (111.5 KB)
wordTest2.pdf_fixed.pdf (111.5 KB)
This is the flattened pdf, that still will not accept textstamp
@tefan57
Thanks for providing the requested information. We have updated the ticket accordingly and will perform investigation from this perspective. We will update you once we have some investigation results. Please spare us some time. We apologize for the inconvenience.
We have 9 page pdf document which already attached as sample document and we are trying stamping image on every page which is not visible
Please pfa sample stamping image sample image.png (420 Bytes)
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filename);
PdfPageEditor pEdit = new PdfPageEditor();
pEdit.BindPdf(filename);
customPageNo = 1;//2,3,4
Aspose.Pdf.PageSize size = pEdit.GetPageSize(customPageNo);
xpos = 467;//466,451,413
ypos = 41;//22,40,381
Aspose.Pdf.ImageStamp imageStamp = new Aspose.Pdf.ImageStamp(fle.Name);
imageStamp.Rotate = Aspose.Pdf.Rotation.None;
imageStamp.Background = true;
imageStamp.XIndent = xpos;
imageStamp.YIndent = Convert.ToInt32(ypos);
pdfDocument.Pages[customPageNo].AddStamp(imageStamp);
pdfDocument.Save(filename);
@tefan57
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-54805
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi,
Has there been any progress on this matter?
As previously this bug is a complete show stopper for us.
If there is not fix we will need to terminate the use of Aspose.
The client is the largest pulic authority in Sweden.
Regs,
Stefan
@tefan57
The following code is able to add stamp using PdfFileStamp. This is our output (Förfrågan (1).output_23_6__Standard.pdf)
com.aspose.pdf.facades.PdfFileStamp fileStamp = new com.aspose.pdf.facades.PdfFileStamp();
// Open Document
fileStamp.bindPdf(dataDir + "Förfrågan (1).pdf");
Form form = fileStamp.getDocument().getForm();
System.out.println(form.getType());
if (form.getType()==FormType.Dynamic){
form.setType(FormType.Standard);
}
// Create stamp
com.aspose.pdf.facades.Stamp stamp = new com.aspose.pdf.facades.Stamp();
stamp.setStampId(1); //draft watermark has id = 1, used by JBS_RemoveDraftWatermark
stamp.bindLogo(new com.aspose.pdf.facades.FormattedText("This is sample", java.awt.Color.BLACK, null, com.aspose.pdf.facades.FontStyle.Helvetica, com.aspose.pdf.facades.EncodingType.Winansi, true, 8));
stamp.setOrigin(10, 400); // stamp.setOrigin(600, 48); <= Customer is using this value
stamp.setRotation(90.0F);
stamp.setBackground(false);
// Add stamp to PDF file
fileStamp.addStamp(stamp);
// Save updated PDF file
fileStamp.save(dataDir + "Förfrågan (1).output_23_6__Standard.pdf");
// Close fileStamp
fileStamp.close();
The reason why you can’t see a TextStamp using your code in JBS_AddTextSignature method, that you are trying to set a stamp out of page boundaries. Actual page size has width 595 pixels, but textStamp.setXIndent(600). The stamp is placed but it is where as shown on the screenshot (Screenshot_.png)
This is result when XIndent is 500 - stamp is visible (Förfrågan (1).pdf_23_6__out_XIndent(500).pdf)
Förfrågan (1).pdf_23_6__out_XIndent(500) (1).pdf (185.8 KB)
Screenshot_.png (139.8 KB)
Förfrågan (1).pdf_23_6__out_XIndent(500) (1).pdf (185.8 KB)