Paulo and Leonard,
thank you very much. Now I'm investigating a more simple application: a
"counter" of nested levels. I think it should be easier to implement. I
have done some tests and it seems to work on my pdf test files.
I'd like to share some pieces of code. If you or other have time to read
them... I'm no sure if it the right approach to the problem. Can you check
it?
(C#)
PdfReader reader = new PdfReader(pdfFileName);
for (int p = 1; p <= reader.NumberOfPages; p++)
{
Console.WriteLine("Page: " + p);
PdfDictionary pageDict = reader.GetPageN(p);
PdfDictionary res = pageDict.Get(PdfName.RESOURCES) as
PdfDictionary;
if (res != null)
InternalDictCheck(res);
else
throw new ApplicationException("Unexpected situation");
}
reader.Close();
private void InternalDictCheck(PdfDictionary dict)
{
_currentLevel++;
if (_currentLevel > _maxLevel)
_maxLevel = _currentLevel;
Console.WriteLine(" CurrentLevel: " + _currentLevel);
PdfDictionary xobjDict = dict.Get(PdfName.XOBJECT) as
PdfDictionary;
if (xobjDict != null)
{
foreach (PdfName obj2Name in xobjDict.Keys)
{
Console.WriteLine(" obj2Name: " + obj2Name);
PRIndirectReference pirr = xobjDict.Get(obj2Name) as
PRIndirectReference;
PdfDictionary dict2 = pirr.Reader.GetPdfObject(
pirr.Number) as PdfDictionary;
PdfDictionary dict3 = dict2.Get(PdfName.RESOURCES) as
PdfDictionary;
if (dict3 != null)
InternalDictCheck(dict3);
}
}
_currentLevel--;
}
Output example:
[..snip..]
Page: 3
CurrentLevel: 1
obj2Name: /Xf6
CurrentLevel: 2
obj2Name: /Xf2
CurrentLevel: 3
obj2Name: /Xf2
CurrentLevel: 4
obj2Name: /Xf2
CurrentLevel: 5
obj2Name: /Xf2
CurrentLevel: 6
obj2Name: /Xf1
CurrentLevel: 6
obj2Name: /Xf1
CurrentLevel: 5
obj2Name: /Xf2
[..snip..]
Fabrizio
On 4/6/07, Paulo Soares <[EMAIL PROTECTED]> wrote:
It's complex but doable. You'll have to parse the child content to replace
the names that exist in the parent with unique names and change the
resources accordingly. In the parent you'll have to look for the Do and in
its place reset the graphic state but not the transform. You'll also have to
look at /BBox and /Matrix in the child to apply in the parent a clipping
path and a transformation.
Paulo
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/