Exemplo n.º 1
0
        private static void ExportImage(PdfDictionary xObject, BinaryFileSaver filesaver)
        {
            foreach (var elem in xObject.Elements)
            {
                if (elem.Key == "/Filter")
                {
                    var      z   = elem;
                    PdfArray x   = elem.Value as PdfArray;
                    var      qah = x.First().ToString();

                    if (qah == "/DCTDecode")
                    {
                        filesaver(xObject.Stream.Value);
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string pdffilenname = args[0];

            BinaryFileSaver filenamegenerator =
                (new FileSaver(
                     Path.Combine(
                         Path.GetDirectoryName(pdffilenname),
                         Path.GetFileNameWithoutExtension(pdffilenname)),
                     ".jpg")
                ).Save;

            TextFileSaver textfilesaver =
                (new TextFileSave(
                     Path.Combine(
                         Path.GetDirectoryName(pdffilenname),
                         Path.GetFileNameWithoutExtension(pdffilenname) + ".txt")))
                .SaveToBuffer;

            ExtractStuffFromPdf(pdffilenname, filenamegenerator, textfilesaver);
        }
Exemplo n.º 3
0
        static void ExtractStuffFromPdf(string pdffile, BinaryFileSaver filenamegenerator, TextFileSaver textsave)
        {
            foreach (var page in PdfReader.Open(pdffile).Pages)
            {
                textsave(ExtractText(page));

                ICollection <PdfItem> items =
                    page.Elements.GetDictionary("/Resources")?
                    .Elements.GetDictionary("/XObject")
                    .Elements.Values;

                foreach (PdfItem item in items)
                {
                    PdfDictionary xObject = (item as PdfReference)?.Value as PdfDictionary;
                    if (xObject != null && xObject.Elements.GetString("/Subtype") == "/Image")
                    {
                        ExportImage(xObject, filenamegenerator);
                    }
                }
            }

            textsave(null);
        }
Exemplo n.º 4
0
 public void SaveFile()
 {
     BinaryFileSaver.SaveFile(m_UnderlyingFile);
     AreAnyChangedUnsaved = false;
 }