Hi Team,
I am using vb.net code which you have provided on below link and trying to give page number to PDF which has 15000 pages.
But this gives me out of memory error.
please help me to overcome this.
I am using latest aspose.pdf dll.
Stamping with Aspose.PDF using C#|Aspose.PDF for .NET
how can I save the file in incremental mode like after each 1000 page I want to save.
Please reply me as this is very urgent issue for me.
rajsingh85007:
Hi Team,I am using vb.net code which you have provided on below link and trying to give page number to PDF which has 15000 pages.
But this gives me out of memory error.
please help me to overcome this.
I am using latest aspose.pdf dll.
Aspose.Pdf for .NET manipulates the PDF file and save the resultant document at once. However as a workaround, you may consider creating a temporary PDF file of 1000 pages, perform the manipulation (add text stamp) and save the output. You can repeat the same process for required number of times and then concatenate the resultant files. For further details, please visitrajsingh85007:
how can I save the file in incremental mode like after each 1000 page I want to save.
We are sorry for this inconvenience.
I will send pdf soon but how can I add page stamp and then concatenate? support I have two pdf one is of 1000 page and other is of 800 page. when I merge these two I want to show page 1 of 1800, page 2 of 1800 and so on. how to get total number of pages from two separate pdf?
File attached.
Hi Rajsingh,
Well, in case you need to concatenate PDF files and need to add a Stamp object according to the concatenated file, you need to first load the individual PDF files, get page count information as it will give the total number of pages that will be part of the resultant/merged file. Then you can stamp the page number information and then merge the PDF files. In order to get the page count, you may try using the following code line.
C#
// load source PDF file
Document doc = new Document("c:/pdftest/1.pdf");
// get total page count information
Console.WriteLine("Total pages in PDF = " + doc.Pages.Count);
please send me the vb.net code for the full procedure for my requirement.
Can you please respond to my query ASAP?
Hi Rajsingh,
Please try using the following code snippet to accomplish your requirement.
[VB.NET]
' instantiate Document Object
Dim doc As Document = New Document("c:/pdftest/1.pdf")
Dim doc2 As Document = New Document("c:/pdftest/ChartsandGraphs.pdf")
' concatenate the page of PDF documents
doc.Pages.Add(doc2.Pages)
' create page number stamp
Dim pageNumberStamp As New PageNumberStamp()
' whether the stamp is background
pageNumberStamp.Background = False
pageNumberStamp.Format = "Page # of " & doc.Pages.Count
pageNumberStamp.BottomMargin = 10
pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Center
pageNumberStamp.StartingNumber = 1
' set text properties
pageNumberStamp.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial")
pageNumberStamp.TextState.FontSize = 14.0F
pageNumberStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold
pageNumberStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Italic
pageNumberStamp.TextState.ForegroundColor = Color.Aqua
Dim page_counter As Integer = 1
For Each page As Page In doc.Pages
' add stamp to particular page
doc.Pages(page_counter).AddStamp(pageNumberStamp)
page_counter += 1
Next
doc.Save("c:/pdftest/StampAdded.pdf")
Thank for this but when we do doc.Pages.Add(doc2.Pages) it will again have issue of out of memory.
Hi Rajsingh,
I have created small files and now i want to give stamp like pdf 1 has got 1000 page and pdf 2 got 800.i have also got total number of pages count as 1800 in variable.now when i am giving stamp to individual file first file is getting 1 of 1800, 2 of 1800 and so on.but 2nd file is also getting 1 of 1800 , 2 of 1800 and so on.but i want to give second file as 1001 of 1800,1002 of 1800 and so on.meaning i want to pass value of # for the below syntax whichi should increment.
pageNumberStamp.Format = "Page # of " & i
rajsingh85007:
I have created small files and now i want to give stamp like pdf 1 has got 1000 page and pdf 2 got 800.i have also got total number of pages count as 1800 in variable.now when i am giving stamp to individual file first file is getting 1 of 1800, 2 of 1800 and so on.but 2nd file is also getting 1 of 1800 , 2 of 1800 and so on.but i want to give second file as 1001 of 1800,1002 of 1800 and so on.meaning i want to pass value of # for the below syntax whichi should increment.
pageNumberStamp.Format = "Page # of " & i
With 6000 page file which is of size 31 mb i am getting out of memory error.i cannot further break this file. also i am unable to attach this file over here.please let me know how to send that file so that you can replicate this issue.
In my below code i get out of memory when i try to add stamp for page 630.
doc10 = New Document"\\ysiinvgs3Reports70rel\Demo\temp\OG\MINTRA_42430010_0.pdf")
For Each page As Page In doc10.Pages
pageNumberStamp.Format = "Page" & total_page_counter & " of " & i
doc10.Pages(page_counter).AddStamp(pageNumberStamp)
page_counter += 1
Next
doc10.Save("\\ysiinvgs3\Reports70rel\Demo\temp\OG\MINTRA_424300010_S.pdf")
please help me in solve this issue as its very urgent now.
Hi Rajsingh,
Here is the file.
https://drive.google.com/file/d/0B0VMx4LFjvKoRHk0eDhEWWJac0U/edit?usp=sharing
please take it and let me know ASAP as this is super urgent.
rajsingh85007:
Here is the file. https://drive.google.com/file/d/0B0VMx4LFjvKoRHk0eDhEWWJac0U/edit?usp=sharingplease take it and let me know ASAP as this is super urgent.
I have given access of file.
please investigate and let me know ASAP.
Hi Rajsingh,
Thanks for granting the permissions. I have tested the scenario using the following code snippet with the latest release of Aspose.Pdf for .NET 9.5.0 and I am unable to notice any problem when using a Visual Studio 2010 project with the target platform as .NET Framework 4.0, running over a Windows 7 (x64) machine. My system configurations are Intel Core i5, 2.5 Ghz with 4 GB of RAM.
Can you please try using the latest release version and see if it resolves your problem? For your reference, I have also attached the resultant PDF generated on my end. Please access the file over this link.
[VB.NET]
'instantiate Document Object
Dim doc As Document = New Document("c:/pdftest/AAMINTRA_42430011_0.pdf")
'Dim doc2 As Document = New Document("c:/pdftest/ChartsandGraphs.pdf")
' concatenate the page of PDF documents
'doc.Pages.Add(doc2.Pages)
'create page number stamp
Dim pageNumberStamp As New PageNumberStamp()
'whether the stamp is background
pageNumberStamp.Background = False
pageNumberStamp.Format = "Page # of " & doc.Pages.Count
pageNumberStamp.BottomMargin = 10
pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Center
pageNumberStamp.StartingNumber = 1
'set text properties
pageNumberStamp.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial")
pageNumberStamp.TextState.FontSize = 14.0F
pageNumberStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold
pageNumberStamp.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Italic
pageNumberStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Aqua
'Dim page_counter As Integer = 1'
' For Each page As Page In doc.Pages
' 'add stamp to particular page
' doc.Pages(page_counter).AddStamp(pageNumberStamp)
' page_counter += 1'
' Next'
doc.Save("c:/pdftest/AAMINTRA_42430011_0_StampAdded.pdf")
Can you try with framework 2 target platform as I am having that.
Hi Rajsingh,