Forum Discussion

fayrehouse's avatar
fayrehouse
Frequent Contributor
12 years ago

Can anyone help translate C# to Jscript for use within TC?

Hi All,



I've added a DLL to the CLR bridge, and am now trying to translate some sample code written in C# into jScript for use within TC. But I'm a bit stuck.



Original C# snippet:




  const int pageNumber = 1;


            PdfReader pdf = new PdfReader(pdfFile);


            PdfDictionary pg = pdf.GetPageN(pageNumber);


            PdfDictionary res = (PdfDictionary)PdfReader.GetPdfObject(pg.Get(PdfName.RESOURCES));


            PdfDictionary xobj = (PdfDictionary)PdfReader.GetPdfObject(res.Get(PdfName.XOBJECT));


            



What I have so far:




var pdfFile = "c:\\myfile.pdf";


var pageNum = 1;


var pdf = dotNET.iTextSharp_text_pdf.PdfReader(pdfFile)


var pg = dotNET.iTextSharp_text_pdf.PdfDictionary(pageNum)


var res = ????

var xobj = ????




so basically, I'm stuck on the last 2 lines of the C#. I can tell you that pdfName is a class within the iTextSharp_text_pdf namespace, with 3 constructor overloads. and (amongst others) the above statics RESOURCES and XOBJECT. 



Can anyone offer guidance?! :)



Thanks :)



Steve





1 Reply

  • fayrehouse's avatar
    fayrehouse
    Frequent Contributor
    Got there in the end - Hopefully this might help someone in the future:




      var res = dotNET.iTextSharp_text_pdf.PdfReader.GetPdfObject(pg.Get(dotNET.iTextSharp_text_pdf.PdfName.RESOURCES))


      var xobj = dotNET.iTextSharp_text_pdf.PdfReader.GetPdfObject(res.Get(dotNET.iTextSharp_text_pdf.PdfName.XOBJECT))