How to Maintain Code Colors when Exporting to PDF using PDF.co and Zapier

If you’re looking for a tool to maintain the code colors when exporting to PDF. Well, you can use the PDF.co API to export code snippets or entire documents into PDF format while maintaining the original code colors to ensure readability and visual appeal.

PDF.co Web API is a comprehensive PDF processing tool that offers a wide range of functionalities for working with PDF documents, including text extraction, image extraction, barcode generation, form filling, and much more. With PDF.co, you can modify PDFs with ease, making it a useful tool for many businesses and developers.

With the combination of PDF.co and Zapier, you can easily export code snippets or entire documents into PDF format while maintaining the code colors, making your PDFs not only functional but also visually pleasing.

In this tutorial, we’ll guide you through the process of setting up a Zap in Zapier to integrate with PDF.co and ensure that your exported PDFs maintain the code colors, making them visually appealing and easy to read. Let’s get started and learn how you can maintain the code colors when exporting into PDF.

  1. Make a Zap
  2. Add PDF.co Action
  3. Connect PDF.co Account
  4. Setup PDF.co Action
  5. Test Action
  6. Test Result
  7. Output

We will use the sample HTML file below containing code with color and then export it to PDF while maintaining the original color format.

Sample HTML File
Sample HTML File

Kindly follow the simple step-by-step guide below:

Step 1: Make a Zap

  • Let’s start by logging into your Zapier account and clicking on the Create Zap button.

Step 2: Add PDF.co Action

  • Next, let’s proceed to the action step and select the PDF.co app from the list of the available applications.

Add PDF.co Action

Step 3: Connect PDF.co Account

  • Now, connect your PDF.co account to Zapier by adding the API Key. You can obtain the API Key in your PDF.co dashboard.

Connect PDF.co Account

Step 4: Setup PDF.co Action

Let’s set up the PDF.co Action.

  • First, select Link to a webpage for Input Type.
  • Next, enter the direct URL of your HTML file. If you’re using a file instead of a URL, you can use the PDF.co File Storage to convert your HTML file to a URL. We recommend using PDF.co File Storage instead of other cloud storage apps because some cloud storage may change the file format, especially when dealing with HTML files. You can refer to this demo on how to upload your HTML file and get the URL.
  • Then, specify a name for your generated output PDF file.

  Setup PDF.co Action

Step 5: Test Action

  • After setting up the configuration, click on the test action button to see the result.

Test Action

Step 6: Test Result

  • Great! The test was successful and exported the HTML file containing the code with colors to PDF. Kindly copy the URL and paste it into your browser to view the output.

Test Result

Step 7: Output

  • Here is the PDF output that demonstrates a successful export of an HTML file with code that maintains the original code colors.
Exported to PDF Output
Exported to PDF Output

PDF.co File Storage Demo

PDF.co File Storage Demo
PDF.co File Storage Demo

In this tutorial, you learned how to maintain the code colors when exporting to PDF using PDF.co and Zapier. You also learned how to use the PDF.co File Storage to convert the HTML file to URL.