• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Apply a stamp on every page on random position and with a slight rotation

Community Beginner ,
Aug 11, 2018 Aug 11, 2018

Copy link to clipboard

Copied

Hello!

I have a 2000 document, which needs to be signed manually (u know with a PEN).

So I scanned my signature, I vectorized the scanned signature and I added that file to Adobe Acrobat.

I can see my signature in the "Comment Section" - "Add stamp" - "Dynamic" - My Signature.

My question: Can I add this stamp on my 2000 pdf document in a single click, with a slight rotation (+- 20degrees) and a random location  (a given location to which I add +- 1 inch <up-down-right-left>)?

The pages are all the same format.

I have Adobe Acrobat X

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Aug 13, 2018 Aug 13, 2018

Ok, in order to achieve my question I used C# and iTextSharp framework.

This is the code. The code is writen in Visual Studio and you need to add a reference to itextsharp.dll to the project.

Doc1.pdf is the source PDF in which I would like to add the stamps.

JD.wmf and DPI.wmf are my images that I use as stamps

Result.pdf is the result pdf with applied stamps.

using iTextSharp.text;

using iTextSharp.text.pdf;

using System;

using System.IO;

namespace ConsoleApplication

{

    class MyCl1

    {

        static

...

Votes

Translate

Translate
Community Beginner ,
Aug 11, 2018 Aug 11, 2018

Copy link to clipboard

Copied

I found the "Batch Stamp Utility" from here: Batch Stamp Utility - idtPlans LLC

A very nice tool.  I put the javascript file in notepad and I found the code which I would like to tweak a little:

if (StampTool.strGRP1 == "AAll") {

var pg = 0;

var nmb = this.numPages;

for (i = 0; i < nmb; i++) {

//here i would like to rotate and change the coordinates of the selected annotation before applying it

// could u tell me how could I do that or show where should I look to find more information about this

oProps.page = pg;

this.addAnnot(oProps);

var pg = pg + 1;

} st.destroy(); }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 11, 2018 Aug 11, 2018

Copy link to clipboard

Copied

A stamp annotation has a rect property and a rotate property. You'd use these to control the placement of the stamp on a page. More information on these two properties is in the Acrobat JavaScript reference, but if you need help, post again. Here's a good tutorial that will probably be useful: https://acrobatusers.com/tutorials/auto_placement_annotations

I mention this tutorial since it's possible that not every page has the same rotation, so you should be prepared for that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 12, 2018 Aug 12, 2018

Copy link to clipboard

Copied

After losing 1-2 hours to understand how can I create a HelloWorld application using Javascript in Adobe, I realized that the PDF business is too big not to be used with Java or C#.

So I found a more elegant (and easier for me) solution to my problem, without JAvascript. Tomorrow I will post the solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 13, 2018 Aug 13, 2018

Copy link to clipboard

Copied

LATEST

Ok, in order to achieve my question I used C# and iTextSharp framework.

This is the code. The code is writen in Visual Studio and you need to add a reference to itextsharp.dll to the project.

Doc1.pdf is the source PDF in which I would like to add the stamps.

JD.wmf and DPI.wmf are my images that I use as stamps

Result.pdf is the result pdf with applied stamps.

using iTextSharp.text;

using iTextSharp.text.pdf;

using System;

using System.IO;

namespace ConsoleApplication

{

    class MyCl1

    {

        static Random random1 = new Random();

        public static void Main()

        {

            using (Stream inputPdfStream = new FileStream("e:\\Doc1.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))

            using (Stream inputImageStream = new FileStream("e:\\JD.wmf", FileMode.Open, FileAccess.Read, FileShare.Read))

            using (Stream inputImageStream2 = new FileStream("e:\\DPI.wmf", FileMode.Open, FileAccess.Read, FileShare.Read))

            using (Stream outputPdfStream = new FileStream("e:\\result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))

            {

                var reader = new PdfReader(inputPdfStream);

                var stamper = new PdfStamper(reader, outputPdfStream);

                int numberOfPages = reader.NumberOfPages;

                Image jD = Image.GetInstance(inputImageStream);

                Image dPI = Image.GetInstance(inputImageStream2);

                float fJD, fDPI;

                for (int i = 1; i <= numberOfPages; i++)

                {

                    var pdfContentByte = stamper.GetOverContent(i);

                    fJD = rand1(370,425);

                    fDPI = rand1(15, 50);

                    jD.SetAbsolutePosition(fJD, fDPI);

                    jD.RotationDegrees = rand1(-20,20);

                    dPI.SetAbsolutePosition(fJD, fDPI);

                    dPI.RotationDegrees = rand1(-20, 20);

                    pdfContentByte.AddImage(jD);

                    pdfContentByte.AddImage(dPI);

                }

                stamper.Close();

                System.Diagnostics.Process.Start("e:\\result.pdf");

            }

        }

        public static float rand1(double minNumber, double maxNumber)

        {

            return (float) (random1.NextDouble() * (maxNumber - minNumber) + minNumber);

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines