This post was updated on .
The process cannot access the file ' .pdf' because it is being used by another process
I am getting the above error in finally block .
public static void IncreaseTopMargin(string inputFile, int numOfLinesToIncrease)
int increaseMargin = (numOfLinesToIncrease * 10);
string tempFile = inputFile;
//We are getting the complete path and extention of the file(inputfile), so i have commented the below four lines
/* string tempFile = Path.GetDirectoryName(inputFile);
tempFile = tempFile + @"\" + Path.GetFileNameWithoutExtension(inputFile) + Guid.NewGuid() + Path.GetExtension(inputFile);
inputFile = tempFile;*/
PdfReader reader = new PdfReader(inputFile);
int n = reader.NumberOfPages;
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(inputFile, FileMode.Create));
PdfContentByte directcontent = writer.DirectContent;
for (int i = 1; i <= n; i++)
page = writer.GetImportedPage(reader, i);
image = Image.GetInstance(page);
image.ScaleAbsolute(PageSize.A4.Width - 25, PageSize.A4.Height - increaseMargin);
//image.ScaleAbsolute(PageSize.A4.Width-72, PageSize.A4.Height - 72);
catch (System.Exception ex)
I am not getting what the problem . Plese Help
The error is not related to iTextSharp.
Solution: close the PdfReader before calling File.Delete.
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
itextsharp-questions mailing list
In reply to this post by Santoshpdf
This is the only form I have found and I need some help type quick This is killing me. I've redone my project because the previous one was babbling about assembly version conflicts so I said screw it and started programming it again. Now, I'm being plagued by this same exact error. Here is part of my code that was working previously and now is bombing left and right. Can someone please help me? This is in vb 2010 here is the code:
For b As Integer = 0 To lboxconv.Items.Count - 1
'//GRAB THE EXTENSION WE ARE ADDING
Dim extension = Microsoft.VisualBasic.Right(b, 3)
'//PROCESS THIS REQUEST
'//PROCESS THIS AS PDF FILE
Dim doc As New Document()
Dim File_Type As String
File_Type = Replace(lboxconv.Items(b), ".png", ".pdf", vbTextCompare)
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream(File_Type, FileMode.Create))
Dim imgpath As String = lboxconv.Items(b)
Dim png As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(imgpath)
png.Alignment = Element.ALIGN_CENTER
For ax = 0 To 10
I have also added an event to delete the old pdf files which it still creates the problem. If i use an on error resume next function what happens is that it will copy into the existing PDF file (as it used to) and it will only create 15 bytes of the file and then move on to the next one. Can anyone PLEASE help me with this problem?
|Free forum by Nabble||Edit this page|