Home ABCPdf or iTextSharp, get elements positions and sizes from an existing PDF file
Reply: 0

ABCPdf or iTextSharp, get elements positions and sizes from an existing PDF file

jibhey
1#
jibhey Published in 2017-12-07 15:37:09Z

I try to develop an exe tu compare to pdf files. i need to get all differences between a master pdf and a generated one, like images or texts position and size, text content, and as much data as possibles.

here is my test with iTextSharp to try to get data that i need :

  Document doc = new Document();
    PdfReader reader = new PdfReader(@"C:\tmp\PDFFlattener\Input\Interior_30087_068x1XWX6516_M_210x297_FLA_68_1_5873301420.pdf");

    for (int page = 1; page <= reader.NumberOfPages; page++)
    {
        var currentPage = reader.GetPageN(page);

        PdfDictionary pageDico = currentPage.GetAsDict(PdfName.RESOURCES);
        PdfDictionary objectDico = pageDico.GetAsDict(PdfName.XOBJECT);
        foreach (var item in objectDico)
        {

            PdfName imgRef = item.Key;
            PRStream stream = (PRStream)objectDico.GetAsStream(imgRef);
            PdfName subType = stream.GetAsName(PdfName.SUBTYPE);
            PdfName coords = stream.GetAsName(PdfName.COORDS);
            PdfName width = stream.GetAsName(PdfName.WIDTH);
            PdfName xyz = stream.GetAsName(PdfName.XYZ);
        }
    }

all PdfNames except SUBTYPE return a null value.

Is it possible to do get X and Y position of an xObject ? I've tryed with ABCPdf also, but i have the same result.

thanks for reading,

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310961 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO