Frequently Asked Question:
How to add barcode to each page of the pdf in the single document?
Question
I want to add barcode to each page of the pdf in the single document which is having more than one page.
Answer
To add a barcode to each page of a PDF you need to use the PageCount function to determine the number of pages in the PDF and then loop through each page and draw your barcode. Here is some sample code written in JScript:
// Load your PDF
QP.LoadFromFile("example.pdf");
// Set the origin for the co-ordinates to be
// the top left corner of the page.
QP.SetOrigin(1);
// Draw three different barcodes on each
// page in the PDF.
for (i = 1; i <= QP.PageCount(); i++)
{
/// Select the page to draw the barcodes on
QP.SelectPage(i);
// Draw the barcodes
QP.DrawBarCode(25, 25, 150, 100, "MyBarcode256", 1, 0);
QP.DrawBarCode(225, 50, 100, 600, "MyBarcode257/RC", 1, 0);
QP.DrawBarCode(350, 50, 200, 150, "MyBarcode258", 3, 0);
}
// Save the new file to the output folder
QP.SaveToFile("PDF_with_Barcodes.pdf");