PdfFileStamp not working on all pdf

@tefan57

We are afraid that we could not understand the issue clearly. Can you please share both incorrect and expected output PDFs for our reference so that we can further proceed to assist you accordingly? Also, please try using TextStamp class and see if it works for you.

Hi,

Sorry for being unclear.

The code snippet I attached works on pdf files created through Aspose, but fails to create a stamp on pdf files that contain images.

The pdf file I attached is an example of a pdf that does not work with the code I attached.

I will try TextStamp.

Regards,
Stefan

@tefan57

We tested the same code snippet with other files (generated by Aspose.PDF) and we still were not able to see any change in them. Can you please share the output file that shows the stamp added through above code snippet?

Hi,

See attached file.

The code snippet above was pulled from your example pages.

Is this code not expected to work?

Do you recommend using TextStamp instead?`

Regs,
Stefan

wordtest.pdf (105.6 KB)

Hi,

TextStamp is not working either:

Document pdfDocument = new Document(sourceName);
// 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(8.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);
        }
        
        // save output document
        pdfDocument.save(targetName);

wordTest2.pdf (308.3 KB)

Please advise.
This is a show stopper for us.

Regs,
Stefan

@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): PDFJAVA-42829

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.

@tefan57

We were able to reproduce the issue in our environment. We changed the values of X,Y coordinates to make sure that they are within the page boundaries. The code worked with our sample PDF file but it did not add stamp on your PDF. Therefore, we have logged the ticket shared above. We will inform you once its resolved.

We are sorry for the inconvenience.

Hi,

Thank you for the update.

This is for us a very serious issue. It is a show stopping bug.

Do you have any insight into the problem, and how long it will take to get it fixed?

Regards,
Stefan

@tefan57

We will surely investigate the issue on first come first serve basis as per the free support policies. Furthermore, your concerns have been recorded as well and we will consider them during ticket investigation. We will inform you as soon as we make some definite progress towards ticket resolution. Please spare us some time.

We are sorry for the inconvenience.

Hi,

Are there any updates on the situation?

My client, Swedish Police Force, who purchased the Aspose license find this issue very concerning.

They were consindering extending their license for use in several other projects, but are now uncertain if Aspose is a good fit.

I need to report back when you believe this issue might be fixed.

Please provide me with some feedback.

Regs,
Stefan

@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-54711

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.

@tefan57

The reason is dynamic XFA that generates pages dynamically, any static content can’t be applied or added here. But we can detect that form is dynamic XFA and convert it into standard AcroForm, then add stamp.

We also noticed that for current document some text fragments are converted incorrectly so we created the additional issue (PDFNET-54711) to solve that.

Hi,

FYI, I tried converting the XFA to AcroForm using the code below.
It had no effect.
The issue does not seem to be limited to XFA.

Regs,
Stefan

pdfDocument.getForm().setType(FormType.Standard);*
pdfDocument.removeMetadata();*
pdfDocument.flatten(); *
pdfDocument.save(targetName +"_fixed.pdf");*
pdfDocument = new Document(targetName +"_fixed.pdf");*

And by no effect I mean that I was not able to stamp the pdf that was converted to AcroForm either.
The actual conversion worked.

Regs,
Stefan

@tefan57

Would you kindly share the obtained PDF document in your environment after flattening it? Have you used the latest version?

We have same problem. On Some pdf stamp is not getting added.

@pgkulkarni

Can you please share the sample PDF document and the code snippet that you are using? We will test the scenario in our environment and address it accordingly.

Please find the sample document
D106082023153739.pdf (234.3 KB)

Following is the code snippet for adding stamp

                    Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filename);

                    PdfPageEditor pEdit = new PdfPageEditor();
                    pEdit.BindPdf(filename);

                    customPageNo = Convert.ToInt32(Math.Round(Convert.ToDouble(strlist[0])));
                    Aspose.Pdf.PageSize size = pEdit.GetPageSize(customPageNo);
                    xpos = eSignPDFHelper.GetXPosition(size.Width, Convert.ToInt32(Math.Round(Convert.ToDouble(strlist[1]))));
                    ypos = eSignPDFHelper.GetYPosition(size.Height, Convert.ToInt32(Math.Round(Convert.ToDouble(strlist[2]))));

                    Aspose.Pdf.ImageStamp imageStamp = new Aspose.Pdf.ImageStamp(downloadedMessageInfo + "\\" + 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);

@pgkulkarni

This code snippet contains some undefined and missing objects and we are unable to use it. Can you please share it with the hardcoded values of X and Y Indents with which you are facing the issue? We will test the scenario in our environment and address it accordingly. Also, it would be helpful if you can share the image file as well that is used to add image stamp.

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)