Automate Creation of Serial Numbers In An Existing PDF Template

Automate Creation of Serial Numbers In An Existing PDF Template

We received a request from a client, to automate the creation of Serial Numbers inside a PDF file.
The PDF was a A3+ format and was designed in such a way to be used by a professional printer.
The serial number would start from 100,001 and would end to 150,000. The serial number needed to be printed under an exiting logo image.
The PDF template had to stay intact as it’s dimensions were set for the specific printer, which would print and then cut the logo and the serial number as a label.
We received a one page template in PDF format which we wrote in it and then duplicate it to create the final PDF.

We used C# and iTextSharp Library.

See below for a screenshot of the last page of the PDF. Page number was 447. The PDF was close to 8MB and it took less than 10 seconds to be created. 

Automate Creation of Serial Numbers In An Existing PDF Template

We used library version 5.5.*

See below for a part of the code on how to write on the existing PDF:

					using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Drawing;

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;


                    for (int Rowi = 0; Rowi < 8; Rowi++)
                        for (int Columni = 0; Columni < 14; Columni++)
                            text = String.Format("{0:n0}", startCounter).Replace(NumberFormatInfo.CurrentInfo.NumberGroupSeparator, " ");
                            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, ArrX[Columni], ArrY[Rowi], 0);
                            if (startCounter > endCounter) break;


If you have a similar need for automating a large number of documents, please use our Contacts Form, we would love to help!

Check our free app that automates the creation of QR Codes: Synergy QR Code Maker

latest posts

GPT-3 vs GPT-4 improvements differences

GPT-4 builds upon the success of its predecessor, GPT-3, by offering several improvements in various aspects. While both models are based on the Transformer architecture, GPT-4 has several advancements over...

Ransomware severs 1,000 ships from on-shore servers

A Norwegian company specializing in maritime risk management faced a ransomware attack on January 7th 2023 that caused its ShipManager software to go offline, resulting in 1,000 ships losing their...

How important is to keep data backups isolated from malware.

Keeping regular backups of your data is essential in today's digital age. There are many reasons why data backups are important, including: Data Loss Prevention: Accidents happen, and hard drives...

Hyper-V How to Fix Virtual machine could not be started because the hypervisor is not running

After a client's power failure where the UPS failed to properly shutdown the Hyper-V Server, VMs were not able to start. See below for the error we got every time...