Skip to main content

Posts

Set Font Color in Word Documents with Java: 3 Ways

  Coloring text programmatically comes up more than you'd expect once you're generating or post-processing Word files from Java — flagging changed clauses in a contract, marking up review comments, or just making a generated report easier to skim. There's more than one way to do it, and which one you reach for depends on whether you're coloring a whole paragraph, a specific run of text, or every occurrence of a keyword across the document. Here's how each one works, and a couple of things that aren't obvious until you hit them. Setup The examples below use Spire.Doc for Java. With Maven, add the dependency to pom.xml : <repositories> <repository> <id> com.e-iceblue </id> <name> e-iceblue </name> <url> https://repo.e-iceblue.com/nexus/content/groups/public/ </url> </repository> </repositories> <dependencies> <dependency> <groupId> e-...

Delete, Reorder, Rotate, and Crop PDF Pages in Java

  Page-level PDF editing — removing extra pages, reordering pages, fixing pages with the wrong orientation, or cropping out unwanted margins — comes up pretty often in day-to-day development. It sounds simple, but once you actually write the code, index shifting and coordinate system direction are the kind of details that trip people up. This post walks through the implementation for each of these operations with Java code examples. Setup The library used here is Spire.PDF for Java. If you're using Maven, add the following to your pom.xml : <repositories> <repository> <id> com.e-iceblue </id> <name> e-iceblue </name> <url> https://repo.e-iceblue.com/nexus/content/groups/public/ </url> </repository> </repositories> <dependencies> <dependency> <groupId> e-iceblue </groupId> <artifactId> spire.pdf </artifactId> <vers...