Hi,

Can someone please help me on this. I am unable to view model tree contents.

Regards
Shubham

On Mon, Oct 23, 2017 at 4:19 PM, shubham jain <sjain...@gmail.com> wrote:

> Hi Users,
>
> I am trying to populate the modeltree in a pdf document by appending
> marked content identifiers in content stream of a pdfpage, but am unable to
> do so. Can someone please let me know what all needs to be done to enable
> modeltree feature in pdf.
>
> I have appended my sample code.
>
> pPage->GetObject()->GetDictionary().AddKey("StructParents",id1);
> PdfNamesTree *namestree = dev->getPdfDocument()->GetNamesTree();
> catalog = dev->getPdfDocument()->GetCatalog();
> PdfPainter painter;
> PdfRect pagesize = pPage->GetPageSize();
> double pageheight = pagesize.GetHeight();
>
> painter.MoveTo(400,200);
> painter.LineTo(400,500);
> painter.Stroke();
> PdfObject *contents = pPage->GetContentsForAppending();
> PdfStream *paintercanvas = contents->GetStream();
> paintercanvas->Append("/Component <</MCID 0>>");
> paintercanvas->Append("\nBDC\n");
> painter.DrawText(0,pageheight-8,"This is it");
> paintercanvas->Append("EMC\n");
>
> PdfObject *markinfo = vecobj->CreateObject();
> markinfo->GetDictionary().AddKey("Marked",PdfVariant(true));
> markinfo->GetDictionary().AddKey("UserProperties",PdfVariant(true));
>
> PdfObject *objr2 = vecobj->CreateObject("MCR");
> objr2->GetDictionary().AddKey("Type",PdfName("MCR"));
> objr2->GetDictionary().AddKey("Pg",pPage->GetObject()->Reference());
> objr2->GetDictionary().AddKey("MCID",id1);
>
> PdfObject *structelemdict = vecobj->CreateObject();
> PdfObject *structelemdict2 = vecobj->CreateObject();
>
> PdfArray parenttreearr;
> parenttreearr.push_back(id1);
> parenttreearr.push_back(structelemdict->Reference());
> PdfObject *parenttree = vecobj->CreateObject();
> parenttree->GetDictionary().AddKey("Nums",parenttreearr);
>
> PdfObject *dict1 = vecobj->CreateObject("StructTreeRoot");
> dict1->GetDictionary().AddKey("Type",PdfName("StructTreeRoot"));
> dict1->GetDictionary().AddKey("K",structelemdict->Reference());
> dict1->GetDictionary().AddKey("ParentTree",parenttree->Reference());
>
> structelemdict2->GetDictionary().AddKey("S",PdfName("Component"));
> structelemdict2->GetDictionary().AddKey("K",objr2->Reference());
> structelemdict2->GetDictionary().AddKey("P",structelemdict->Reference());
> structelemdict2->GetDictionary().AddKey("Pg",
> pPage->GetObject()->Reference());
>
> structelemdict->GetDictionary().AddKey("S",id1);
> structelemdict->GetDictionary().AddKey("K",structelemdict2->Reference());
> structelemdict->GetDictionary().AddKey("P",dict1->Reference());
>
> catalog->GetDictionary().AddKey("StructTreeRoot",dict1->Reference());
> catalog->GetDictionary().AddKey("MarkInfo",markinfo->Reference());
>
>
> Regards
> Shubham Jain
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to