Adding custom link(run javascript) to PDF files with Python - python

I want to add custom links with run a particular javascript code to PDF files. The reason is that, I want to show these PDF's in an Android application and when these links are clicked, I want to open another view depending on which link is clicked. What I'm referring as 'custom links' is available when editing with Adobe. Is there a solution for Python to achieve this?
Note: There is a function in PyPdf2 - addLink - but it only allows adding links to view other pages of the document.

Related

How to open dynamic links in new tab with web py framework?

I tried web.seeother("link"), but this does not open it in a new tab. Now I can generate a link with a _blank tag, but then the user has to click on the link separately that is separate button for generating the link and another button to follow that link. I want to perform both with a single click. A server side method to do this would be best.
I am using the web.py framework.
As the document says web.seeother() is used for redirecting a user to another page. So a more clear way for asking your question is: "how to make web.seeother() open a link in a new tab"?
As I have observed the documents, There is no way to do that on server-side.
Not a web.py issue. Cannot be done from server-side by any python or non-python framework, must be done in the Client.
From the client, you can set target="_blank" in the HTML, or use javascript with something like window.open(url). Javascript will allow you to set size and position of second window.

Python write web scraper to get pdf files without several logins

How can I download all the pdf (or specific extension files like .tif or .pdf) from a webpage that requires login. I dont want to log in everytime for every pdf so I cant use link generation and pushing to browser scheme
The solution was simple: just posting it for others may have the same question
mydriver.get("https://username:password#www.somewebsite.com/somelink")

Can selenium be used to highlight sections of a web page?

Can I have any highlight kind of things using Python 2.7? Say when my script clicking on the submit button,feeding data into the text field or selecting values from the drop-down field, just to highlight on that element to make sure to the script runner that his/her script doing what he/she wants.
EDIT
I am using selenium-webdriver with python to automate some web based work on a third party application.
Thanks
This is something you need to do with javascript, not python.
[NOTE: I'm leaving this answer for historical purposes but readers should note that the original question has changed from concerning itself with Python to concerning itself with Selenium]
Assuming you're talking about a browser based application being served from a Python back-end server (and it's just a guess since there's no information in your post):
If you are constructing a response in your Python back-end, wrap the stuff that you want to highlight in a <span> tag and set a class on the span tag. Then, in your CSS define that class with whatever highlighting properties you want to use.
However, if you want to accomplish this highlighting in an already-loaded browser page without generating new HTML on the back end and returning that to the browser, then Python (on the server) has no knowledge of or ability to affect the web page in browser. You must accomplish this using Javascript or a Javascript library or framework in the browser.

How to modify the url in plone so that we don't get the same page if it is modified?

After using atreal.richfile.preview in plone, we get the preview of a pdf file with the url like : http://localhost:8090/plone/sample.pdf/view. If we delete part of the url i.e "/view", and enter the url: http://localhost:8090/plone/sample.pdf in the browser, it still can be viewed and the pdf becomes printable or can be copied. How can I modify the url so that it will not display the pdf in the new window if the url of the same is modified? Using plone 4.1. Which template and what code needs to be added/ edited. Please guide
In the example above, sample.pdf is presumably a File created in Plone. In this case, the URL without /view will render the file for download, and the URL with /view will render a Plone page with a link to download it. This is standard behaviour.
It isn't really possible to stop people from downloading the PDF. You can modify the File FTI in portal_types (go to portal_types/File in the ZMI and change the method aliases tab). If you change the "(Default)" alias to be the same as the "view" one, it will behave the same. Note that this will affect all files.
Martin

How do you make a PDF searchable with text in the sidebar?

I'm looking to create some PDF's from Python.
I've noticed that some pdf's have sidebar text that allows you to see the context of occurrences of search terms.
e.g. search for "dictionary"
View in Sidebar:
Page 10 Assigning a value to an existing dictionary key simply replaces the old value with a new one.
How is that done?
Is there anyway to convert existing PDFs to render this sidebar text?
If you use Reportlab to generate your pdfs, then there are facilities in the library to bookmark as you want. Checkout the bookmarkPage method on page 54 of the documentation.
I believe what you're referring to are bookmarks. The first hit on Google indicates that you can put them in by hand with Acrobat Pro.
The DocBook XSL templates when used with Apache FOP
The PyQt gui toolkit has support for creating PDF's. See for example: Printing Rich Text with Qt

Categories