1

I have this feature on my web app that allows you to convert files (any format) to pdf and is allowed for viewing.

I'm already able to do that. My problem is when I convert source code files such as .java or .js it is read like an ordinary text file with no highlighting when converted to pdf.

I want to be able to retain syntax highlight of those file when it is converted to pdf as well. Is there any way in doing this?

2
  • superuser.com/questions/601198/… Commented Jul 11, 2017 at 2:18
  • Thanks for the suggestion.. But i believe these are all html and xhtml files so it has corresponding stylesheets attached to it which can be manipulated by APIs out there. Does that logic go with .java and .cs or .js files as well which are treated just like text files only? Commented Jul 11, 2017 at 2:52

1 Answer 1

4

Short Answer: No, there is no way to keep the syntax highlighting from source code file to PDF.

Long Answer: The syntax highlighting is a feature of your IDE, it's not part of your source file itself so there is no way to keep it. However, you can create your own syntax highlighting before converting in to PDF.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the fast reply.. Can you expound on creating my own syntax highlighting before converting it to PDF?
It may be possible to keep syntax highlighting, depending on your IDE. Try copying code from Eclipse to Word.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.