I'm using iTextsharp library for generating pdf and merging pdf with document. But could not write barcode in pdf. I'm getting an error
access to the path is denied
But i've checked permission for the folder in server, all permission is given including write permission, this same code works perfectly previously, but not recently. But while checking in locally its working perfectly. Is this because using Itextsharp. Help me out guys.
code for Generating Barcode
iTextSharp.text.pdf.BarcodePDF417 pdf417 = new iTextSharp.text.pdf.BarcodePDF417();
pdf417.CodeRows = 60;
pdf417.CodeColumns = 60;
pdf417.YHeight = 1;
pdf417.SetText(tmpSourceString);
System.Drawing.Image im = pdf417.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);
MemoryStream ms = new MemoryStream();
im.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
return ms.ToArray();
System.Drawing.Bitmap newbitmap = new System.Drawing.Bitmap(returnImage);
newbitmap.Save(fileUploadLoc + file_name, ImageFormat.Jpeg);
file_name_new = officer + "_" + "digital_barcode1.Jpeg";
var bmp = Bitmap.FromFile(fileUploadLoc + file_name);
var newImage = new Bitmap(bmp.Width, bmp.Height + 15);
var gr = Graphics.FromImage(newImage);
gr.DrawImageUnscaled(bmp, 0, 0);
gr.DrawString(signed, SystemFonts.CaptionFont, Brushes.White,
new RectangleF(0, bmp.Height, bmp.Width, 0));
Code for merging barcode with pdf
using (Stream inputPdfStream = new FileStream(file_path + file_name_doc, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream(fileUploadLoc + file_name_new, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(fileUploadLoc + file_temp, FileMode.Append, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
PdfReader.unethicalreading = true;
var stamper = new PdfStamper(reader, outputPdfStream);
int numberOfPages = reader.NumberOfPages;
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
int pages = get_pageCcount(file_path + file_name_doc);
for (int i = 1; i <= pages; i++)
{
var pdfContentByte = stamper.GetOverContent(i);
image.SetAbsolutePosition(1, 0);
pdfContentByte.AddImage(image);
}
stamper.Close();
inputImageStream.Close();
File.Delete(file_path + file_name_doc);
File.Move(fileUploadLoc + file_temp, file_path + file_name_doc);
Yes, it is called programming. LOTS of programming - basically you need to use the .NET system libraries to generate the graphics for the barcode. Then you manipulate a file to put it in - like your library does now.
At the end, you WRITE a library for this if you do not use one. There is nothing in .NET that does it out of the box. Most would consider it NOT to be worth their time - because it takes a LOT of work for something you can get for a relatively small amount.
Note that I answer the ONE question you ask - for which your code is irrelevant. You ask whether it can be done without a library, and yes.