Google Docs to PDF (custom script to exclude embedded URL links in gDoc)?

Hello all,

Can anyone provide some tips on how I can create a script to scan a gDoc and remove all embedded URL links.

I am building release notes where each issue has a link to the jira issue number in order to help release notes contributors. However, when I am ready to publish this document to a PDF, I do not want the end users to see the embedded links (they would go nowhere anyway).

Currently, Google doesn't include any options for Save As [to PDF] so I was thinking of writing a script that would:
1) Temporarily find and remove all embedded URLs links (this is the primary goal - the rest is nice to have)
2) Print to PDF
3) Revert/return all the links

Although I am familiar with programming in a few languages (including basic JavaScript), I have never built a Google Script. Is what I am trying to accomplish, even possible?

Currently, I am reviewing the API here: https://developers.google.com/apps-script/overview

Any help is appreciated.

Thank you,
Shawn
LVL 4
S ConnellyTechnical WriterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

S ConnellyTechnical WriterAuthor Commented:
Found this one reference but I cannot get this to work:

stackoverflow.com/questions/26729517/google-apps-script-how-to-remove-a-link-from-a-document

I appreciate any help. Thank you.
0
S ConnellyTechnical WriterAuthor Commented:
Hmmm.... no help? :(

Experimenting a bit more, ideally what I want the script to automatically do, is the following:

1) Make a copy of master document
2) Search and remove all links within the body of document (but ignore one specific URL)
3) If link font attributes remain (blue / underlined text), search and remove them.
4) Save As PDF

Can this even be accomplished with a Google script?

Thank you
0
Randy DownsOWNERCommented:
It doesn't look like there is way to do this directly but you could export the file to Word and then remove the links from the Word document with VBA. The same page has VBA to remove links from all open documents.

Sub KillTheHyperlinks() 
' -----------------------------------------------
' Removes all hyperlinks from the document:
' Text to display is left intact
' -----------------------------------------------
With ThisDocument 
' Loop while there are hyperlinks afoot!
While .Hyperlinks.Count > 0 
.Hyperlinks(1).Delete 
Wend 
End With 
' Shut this off, don't need anymore popping up
Application.Options.AutoFormatAsYouTypeReplaceHyperlinks = False 
End Sub

Open in new window

0
S ConnellyTechnical WriterAuthor Commented:
BTW, as a follow-up (really sorry for the delay), I eventually came up with a new way of doing this... that is, by adding my links within comments like this, /* web link */. Then I wrote a gScript to remove all incidences with and within the comments.

If anyone is interested in viewing the gScript source, just reply here.

Can the abandoned 'post' be lifted? I'm back now. :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
S ConnellyTechnical WriterAuthor Commented:
Randy, I am sharing the award with you b/c, at least, you tried to help. Ty.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Google Apps

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.