Skip to main content
Share Your Experience: Take the 2024 Developer Survey
14 votes

Classifying image by file extension within a PDF creator

Naturally, you can use a dictionary to map extensions to file types: "jpg" -> ImageFileType.Jpeg "jpeg" -> ImageFileType.Jpeg "...
janos's user avatar
  • 111k
14 votes

Open encrypted PDF file by trying passwords from a word list

Looking at the documentation of PdfFileReader.decrypt It states that it return 0 if the file fails or 1 if it succeeds. You can also use isEncrypted to check if the file was encrypted in the first ...
ratchet freak's user avatar
11 votes
Accepted

Python script to extract text from PDF with images

I don't see a good reason why this should be a class. You only have two things in your state, self.text, which you could pass as an argument, and ...
Graipher's user avatar
  • 41k
10 votes
Accepted

Speed up search function for PDFs

where did the time go? Thank you for including measurements. Ordering the profiler output by call count is uninteresting. What you care about is time spent, and the output makes it pretty clear that ...
J_H's user avatar
  • 27.6k
8 votes
Accepted

PDF script tool to convert documents to PDF and add fields and scripts

...
Mathieu Guindon's user avatar
8 votes
Accepted

A Python script to plot data and save to PDF

coding style Your code is almost pep-8 compliant. There are a few spaces missing after comma's, but all in all this is not too bad. I myself use black to take care of this formatting for me. some of ...
Maarten Fabré's user avatar
7 votes
Accepted

PDF processing by PDFBox app jar

You should use with..as to open a file to make sure it is closed again, even if your program is interrupted: ...
Graipher's user avatar
  • 41k
7 votes

Writing PDF files in C#

Given that the PdfWriter holds a reference to an IDisposable resource (the Stream), it's ...
RobH's user avatar
  • 17k
7 votes
Accepted

Class to generate a pdf invoice

Data classes Since you are using the classes as immutable data containers, it would be possible to significantly cut down the amount of code you have to write to create all of them using ...
AlexV's user avatar
  • 7,260
6 votes

PDF script tool to convert documents to PDF and add fields and scripts

internal async Task ProcessPdfs( IProgress progress, Field field = null, Script script = null) { await Task.Run(() => This method looks ...
RubberDuck's user avatar
  • 30.8k
6 votes
Accepted

PDF page & word count, recursive searching of directory tree, output to excel

Performance The problem was there were a large number of PDF files (over 1000) which were scattered over a drive. This is the perfect scenario for a parallel application. Spin up a few workers and ...
Reinderien's user avatar
  • 62.1k
5 votes
Accepted

Attempting an OOP approach for PDF Paranoia - Automate the Boring Stuff CH 15

Object oriented code means that you have objects, and methods for interacting with those objects, you can then very easily reuse / compose those objects to do different things. In this case you've ...
OnceAndFutureKing's user avatar
4 votes
Accepted

PDF conversion and time stamp tool

You have a bug in this "setter". ...
RubberDuck's user avatar
  • 30.8k
4 votes

Extract Pages from PDF based on search in python

You could try profiling but the code is simple enough that I think you're spending most of the time in PyPDF2 code. Two options: You can preprocess your PDF files to store their text somewhere, which ...
Quentin Pradet's user avatar
4 votes
Accepted

Get bibtex entries from metadata of PDF files

Always double-quote variables if they might contain spaces These commands will fail if the variables contain spaces: cd $FOLDER # ... echo >> $BIBTEX_FILE ...
janos's user avatar
  • 111k
4 votes
Accepted

Small program to download wikipedia articles to pdf

Here are some stylistic and code style points: fix the variable naming - in Python, there is a lower_case_with_underscores variable naming style (PEP8 reference) ...
alecxe's user avatar
  • 17.3k
4 votes
Accepted

PDF Script Tool - adds JavaScripts to PDF files

It's time to get through separation of concerns. Whatever you are trying to do with your PDFs, your form is not the place to do it. At the very least you should move the functionality to a different ...
Bruno Costa's user avatar
  • 5,566
4 votes

Python3 - Determing if a PDF is scanned or "searchable"

How about the PDF metadata check on '/Resources' ?! I believe for any text in a PDF (electronic document) there are more chances of having a font, especially the ...
ExtractTable.com's user avatar
4 votes

Brute force search for pdf password in python

Your code will never actually test any password, since password is not a valid argument for open(). Thusly every call to it, ...
Richard Neumann's user avatar
3 votes
Accepted

Extract images from a PDF or ZIP file

"Egyptian" brackets is uncommon practice for C#. You should place an opening brace on separate line. I suggest to use Dictionary every time you deal with mapping: ...
Maxim's user avatar
  • 2,542
3 votes

Makefile for building classwork from markdown files and LaTeX

I have a similar script. So from my experiences I would: build the pdfs through latexmk sometimes it needs more runs of pdflatex. I found it too hard to get right in plain make. have directories ...
bdecaf's user avatar
  • 402
3 votes

Changing PDF annotation with JavaScript code to jump to page into regular to Go To Page action

More improvable things for (int i = 1; i <= reader.NumberOfPages; i++) Try to use a constant in cases like this because it's not obvious why you start ...
t3chb0t's user avatar
  • 44.3k
3 votes
Accepted

Changing PDF annotation with JavaScript code to jump to page into regular to Go To Page action

Good things You are using the using statement to properly dispose objects which are implementing IDisposable. You are using ...
Heslacher's user avatar
  • 50.4k
3 votes

Classifying image by file extension within a PDF creator

Enum.TryParse I couldn't find the definition of ImageFileType but if this is your own type then you can parse the extensions directly as an enum. You just need to ...
t3chb0t's user avatar
  • 44.3k
3 votes
Accepted

Implementing a PDF generator that converts classes into PDFs

Just a few notes about the second part in your EDIT. ...
t3chb0t's user avatar
  • 44.3k
3 votes

Implementing a PDF generator that converts classes into PDFs

You can consider not to call GC.SuppressFinalize by trying to use the "using" statement instead. ...
Baskar Rao's user avatar
3 votes
Accepted

MySQL/CUPS PDF printer for STAR TSP100 ECO

I would put the configuration of user, password, host, etc into a dictionary. This allows you to load this dictionary from a file, if you don't want to have the password in the code. It makes it also ...
Graipher's user avatar
  • 41k
3 votes

PDF script tool to convert documents to PDF and add fields and scripts

One thing that I am certain that everyone is thinking the first time they look at this code is that you have too many summary comments. ...
Malachi's user avatar
  • 28.6k
3 votes
Accepted

PDF Stamper Method to Add Field and Script to PDF File

There is an excessive amount of new line after parameter delimiter(,) and assignment operator(=). At the same time, there is no ...
Xiaoy312's user avatar
  • 3,136

Only top scored, non community-wiki answers of a minimum length are eligible