|
-
Feb 2nd, 2010, 02:32 AM
#1
Thread Starter
Fanatic Member
PDF Page Label(iTexSharp).
When creating a PDF document we can set PDF Page labels using iTexsharp (Sample below),
SetPageLabel
But its possible to set Page Label for already created PDF document.
Visual Studio.net 2010
If this post is useful, rate it

-
Feb 2nd, 2010, 09:39 AM
#2
Re: PDF Page Label(iTexSharp).
You cannot change the existing pdf file directly. However, what you can do is to create a new pdf file from the existing one using the iTextSharp.text.pdf.PdfStamper class and then access the pdfwriter object of the stamper to set page label. Once finish, you can delete the original and rename the new pdf the same as the original.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 3rd, 2010, 05:35 AM
#3
Thread Starter
Fanatic Member
Re: PDF Page Label(iTexSharp).
Thanks stanav, i did the same only..
i created a copy using SmartPDF and set the page label. Working fine.
Is it possible to change the "Producer name" of the PDF?
Visual Studio.net 2010
If this post is useful, rate it

-
Feb 3rd, 2010, 10:52 AM
#4
Re: PDF Page Label(iTexSharp).
If you're using iTextSharp, you can try by inheriting the iTextSharp.text.Document class and shadow or overload the AddProducer() method. You may also try to write a method and call it instead of calling the AddProducer method... Something like this:
Code:
Public Function AddProducerName(ByVal doc As iTextSharp.text.Document, ByVal name As String) As Boolean
Return doc.Add(New iTextSharp.text.Meta(iTextSharp.text.Element.PRODUCER, name))
End Function
Assume you have a iTextSharp.text.Document object doc, instead of doing this:
Code:
Dim success as boolean = doc.AddProducer()
You do this:
Code:
Dim success as boolean = AddProducerName(doc, "whatever name you want to give it here")
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2010, 06:35 AM
#5
Thread Starter
Fanatic Member
Re: PDF Page Label(iTexSharp).
hmmm tried,bur not yet got the OutPut...Could you pls tell where am wrong?
Pls forgive the code is in c#.
Code:
String sPDF = @"...\Desktop\Temp-Delete\From\Temp.pdf";
String sOutPdf = @"...\Desktop\Temp-Delete\From\Label1.pdf";
iTextSharp.text.pdf.PdfReader oTemp = new iTextSharp.text.pdf.PdfReader(sPDF);
Document document = new Document(oTemp.GetPageSizeWithRotation(1));
PdfImportedPage importedPage = null;
PdfSmartCopy pdfWriter = null;
pdfWriter = new PdfSmartCopy(document, new System.IO.FileStream(sOutPdf, FileMode.Create));
pdfWriter.PdfVersion = oTemp.PdfVersion;
document.AddTitle("SamplePDF");
document.AddAuthor("XXXXX");
document.AddCreator("XXXXXXX");
document.AddKeywords("First testing program for checking the metada in pdf");
document.AddSubject("XXXXX");
document.AddHeader("XXXXXX", "XXXXXX");
document.Add(new Meta(Element.PRODUCER, "Adobe"));
document.Open();
for (int i = 1; i <= oTemp.NumberOfPages; i++)
{
importedPage = pdfWriter.GetImportedPage(oTemp, i);
pdfWriter.AddPage(importedPage);
}
PdfPageLabels oLabel = new PdfPageLabels();
oLabel.AddPageLabel(1, PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
pdfWriter.PageLabels = oLabel;
pdfWriter.Close();
document.Close();
Visual Studio.net 2010
If this post is useful, rate it

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|