I need to parse PDF documents written in multi-column layout containing articles. Specifically, I need to extract articles, article headers, images, tables, lists, font styles, and then create a custom single-column html for each PDF while maintaining the structure and the order of the articles.

I have tried pdfbox but did not have much luck due to lack of documentation.

I am looking for a PDF parser library with well and self explanatory API documentation. Can you please make a recommendation?

  • Unfortunately, there is no concept articles, article headers, tables, lists or font styles (bold/italic/superscript) in the PDF format. All there is are; characters, words, images, and vector paths. Unless the PDF happens to be well Tagged, but well Tagged PDF files are essentially non-existent. Why is converting a multi-column PDF to single column HTML important for you? – Ryan Apr 19 '18 at 15:35
  • Correct, such concept does not exist. My goal is to introduce this concept. I tried to use the PdfBox library for parsing but their APIs are not clear and I have no understanding of their document object model. – OSGI Java Apr 19 '18 at 16:02
  • If there is a library that is well documented, then I can use it to extract articles and all other components (unlikely a trivial task). The resulting HTML would become part of another HTML document so that is why the conversion to single column is important. – OSGI Java Apr 19 '18 at 16:03
  • Are you looking for a "general" solution that should handle any PDF, or are you dealing with certain collection, or source, of files that have a consistent structure? – Ryan Apr 20 '18 at 5:00
  • @Ryan The structure of PDF documents is not completely consistent so I am looking for a general solution. – OSGI Java Apr 20 '18 at 12:17

Consider using the LEADTOOLS PDF Library. You can find online documentation for the PDF classes in the toolkit included with code examples for most classes.

Disclaimer: I am an employee of the toolkit’s vendor

The PDFDocument class can be used to parse text items (characters), images, rectangles and hyperlinks, annotations, form fields, digital signatures as well as the fonts used in these items.

The .NET code to parse some objects from a PDF this would look like the following:

using (PDFDocument document = new PDFDocument(pdfFileName)) 
   PDFParsePagesOptions options = PDFParsePagesOptions.All;
   document.ParsePages(options, 1, -1); 

   foreach (PDFDocumentPage page in document.Pages) 
      IList<PDFFont> fonts = page.Fonts; 
      IList<PDFObject> objects = page.Objects; //text (characters), images or rectangles  
      IList<PDFHyperlink> hyperlinks = page.Hyperlinks; 

You can extract detailed text information using Docotic.Pdf library. I am co-author of this library. Here is the basic C# sample:

using (var pdf = new PdfDocument("your_document.pdf"))
    PdfPage page = pdf.Pages[0];
    foreach (PdfTextData data in page.GetWords())
            $"{{\n" +
            $"  text: '{data.Text}',\n" +
            $"  bounds: {data.Bounds},\n" +
            $"  font name: '{data.Font.Name}',\n" +
            $"  font size: {data.FontSize},\n" +
            $"  transformation matrix: {data.TransformationMatrix},\n" +
            $"  rendering mode: '{data.RenderingMode}',\n" +
            $"  brush: {data.Brush},\n" +
            $"  pen: {data.Pen}\n" +

You can also extract text chunks with other objects like images and vector paths. Read Extract text from PDF in C# for more detail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.