Vibe Coding: Crafting Effective AI Prompts for Custom Win2PDF Plug-ins

Vibe coding is a novel approach to software development that leverages artificial intelligence (AI) to generate code based on desired functionality or “vibe.” It allows developers to express their intentions in a more abstract and intuitive way, rather than writing explicit, line-by-line instructions. This methodology is particularly useful for creating Win2PDF Plug-Ins, enabling faster development and innovative solutions for specific customer applications.

Vibe coding utilizes AI models trained on vast amounts of code and natural language. Developers provide high-level descriptions of what they want the Plug-In to achieve, and the AI interprets these descriptions to generate the corresponding code. Since Win2PDF has extensive online documentation with syntax descriptions and code examples, most AI programs can already generate Win2PDF Plug-Ins.

And while creating a custom Win2PDF Plug-In with the help of AI can be powerful, its success relies heavily on the quality and specificity of your prompts. We’ve been experimenting with a variety of different AI chatbots to see how they can handle generating code for Win2PDF Plug-Ins, and the results can vary widely depending on how the prompts are structured. We’ve tried this with Google Gemini, Microsoft Copilot, OpenAI ChatGPT, GitHub Copilot, Anthropic Claude, and others.

Chatbots can create Win2PDF Plug-Ins

Based on our experience, here are some tips to help you write successful AI prompts.

Be Specific and Detailed

The more details you provide, the better the AI can understand your requirements. Avoid vague statements and instead, describe exactly what you want the Plug-In to do. For example:

Instead of: “Make a Win2PDF Plug-In for PDF watermarks.

Try: “Create a Win2PDF Plug-In in C# that adds a custom watermark file to all pages of a PDF document except for the first page. Name the new file with the same name as the input file, but add “_watermarked” to the file name.

Break Down Complex Tasks

If your Plug-In needs to perform multiple functions, break them down into separate prompts. This makes it easier for the AI to understand each part and generate the corresponding code. For example:

Instead of: “Write a PDF Plug-In to extract pages in different files with watermarks.

Try:

  • “Write a Win2PDF Plug-In in C# to export pages 2-4 and 5-6 in separate files and add a watermark to both. “
  • “Use the Win2PDF command line “extractpages” and Win2PDF command line “watermark” commands.”
  • “The watermark should use the existing “confidential.pdf” file as the watermark.”

Specify the Programming Language

If you have a preference for a specific programming language (e.g., VB.NET, C#, Powershell), mention it in your prompt. This will help the AI generate code that is compatible with your existing setup.

Example: “Generate a program using C# that extracts text from the last page of the PDF and saves it to a text file using Win2PDF.

Provide Context and Examples

Give the AI context about the existing Win2PDF environment and provide examples of the desired output. This can help the AI understand your needs better.

Example: “Write a Powershell program that will save the first page of a PDF file as a JPG image with a user-definable resolution. It should use the following command syntax: “win2pdfd.exe pdf2jpg “sourcepdf” “destjpg” pagenumber xresolution yresolution”, where the xresolution and yresolution are set to be 200. The output JPG files should be the same name as the input file name, but with a “_page1.jpg” added to the input file name.

Iterate and Refine

Don’t expect perfect results from the first prompt. Review the generated code and provide feedback to the AI. You may need to refine your prompts and ask for modifications several times to achieve the desired outcome.

Example: “The generated code is close, but the encryption is not using AES-256. Please modify the code to use AES-256 encryption instead of the current algorithm.

Also, to improve results, tailor your prompts for the AI you are working with. For Github Copilot, for example, browse to the Win2PDF.Samples repository before asking it to generate a Plug-In. Github Copilot will use the Win2PDF.Samples repository to produce better code that is more likely to work as expected.

If a generated Plug-In doesn’t work, try copying the Win2PDF documentation into the prompt and ask it again. For example:

Instead of: “Write a Win2PDF Plug-In in Windows Powershell that takes a single parameter with an input PDF and exports pages 2-4 and 5-6 in separate files and adds a watermark to both.”

Try: “Write a Win2PDF Plug-In in Windows Powershell that takes a single parameter with an input PDF and exports pages 2-4 and 5-6 in separate files and adds a watermark to both. The new files should be placed in the same folder as the source file. Use the Win2PDF command line win2pdfd.exe “extractpages” and Win2PDF command line “watermark” commands . The watermark should use the existing “confidential.pdf” file as the watermark. The documentation for the watermark command is: win2pdfd.exe watermark “sourcefile” “watermarkfile” “destfile” mode excludepre excludepost Where: “mode” is either “watermark”, “background”, “watermarklink”, or “backgroundlink” If mode is “watermark” or ““watermarklink”, the watermarkfile PDF is overlaid on top of all existing graphics on the page. If mode is “background” or “backgroundlink”, the watermarkfile PDF is placed underneath all existing graphics on the page. If the watermark file has click-able links, you can use the “watermarklink” or “backgroundlink” variation to keep these links active in the final PDF file. “excludepre” is the number of pages from the beginning of the document to skip applying the watermark. Set to 0 apply watermarkfile to all pages including the first page. Set to a negative value to include the watermark to the absolute value of the number of pages from the beginning of the document. “excludepost” is the number of pages from the end of the document to skip applying the watermark. Set to 0 to apply the watermarkfile to all pages including the last page. Set to a negative value to include the watermark to the absolute value of the number of pages from the end of the document. The documentation for the “extractpages” command is: win2pdfd.exe extractpages “sourcefile” startpage endpage “destfile” Extract pages from “sourcefile” starting at “startpage” to “endpage”, and save extracted pages in “destfile”. Any file names that contain spaces must be enclosed with quotation marks. The “sourcefile” can be a local file path, or an web address (URL) to an existing PDF. Returns 0 on success, and a Windows system error code on failure. If “sourcefile” and “destfile” are the same file, the file is modified in place. Any file names that contain spaces must be enclosed with quotation marks. The “sourcefile” can be a local file path, or an web address (URL) to an existing PDF. Returns 0 on success, and a Windows system error code on failure.”

While that looks complicated, it’s essentially the same prompt WITH copied documentation on how to use each of the commands we know the Plug-In will need to use, and the steps the Plug-In will need to perform. AI will understand this better than you or I, and the results are much improved.

Test Thoroughly

Always test the generated Plug-In thoroughly to ensure it works as expected. Pay attention to error handling and edge cases. Using AI to generate code is still not fool-proof, and in our experiments the code results frequently need to be tweaked to make them work as desired. Over time and with the rate of AI advancement, we expect this to be less of a problem in the future.

By following these tips, you can effectively communicate your needs to the AI and create custom Win2PDF Plug-Ins that meet your specific requirements.

If AI can’t get you the results you need, contact us with your specific requests and customizations for Win2PDF.

How to Save a Web Page as a PDF

In our last post, we showed how a web page could be saved as a PDF file. However, the method outlined in that post was ONLY available to Apple iPhone or iPad users using iOS 13 or later, so it significantly limited its usefulness, especially for desktop PC users or users of other phones or devices like Android or Chrome.

Well, good news! We have just introduced a new feature on our web site called HTML to PDF. If you’re navigating from the main win2pdf.com home page, it is located under FEATURES as shown below with the blue arrow.

HTML to PDF is a free web service and it allows you to enter in the web site address (URL) of any public web site and click Submit. Once submitted, the web page will automatically be converted to a PDF file directly from your browser. You do not need to download or install any software on your computer to create the PDF file.

For example, suppose you want to save an article about how to carve a Thanksgiving turkey. Find the article you want to save online, copy the web page address, and then paste it into the HTML to PDF web page.

After you click Submit, the web page will be converted to a PDF file and returned to your web browser. If you have Adobe Reader installed as your default PDF viewer, it will open automatically and you’ll see the PDF file on your screen, where you can save it, edit it, or do anything you want with it.

For security reasons, this feature currently only works with web pages that are public and do NOT require a user login (like email, online banking, etc.) If you need to convert a secure page, you can download and install Win2PDF and print the web page to the Win2PDF printer.

This is part of a new set of capabilities that we are developing for Win2PDF. If you are a company or a software developer interested in an HTML to PDF API (where the PDF is generated as a cloud-based service as opposed to being installed as a local software component), let us know and we can provide more details.

In the meantime, give it a try and let us know if you have any questions. It may be a useful tool to share with friends or families this Thanksgiving… and it’s free.