Changing a PDF author programmatically - python

In my office we have about 1000 PDFs that have arbitrary title and author information. My bosses had a spreadsheet created with the PDFs filename and an appropriate title and appropriate author information.
I would like to find a programmatic way to move the data from the Excel sheet to the PDF attributes?
My preferred language is Python so I looked for a Python library to do this, each library I looked at had the author and title fields as read-only.
If Python doesn't have a library that works I am okay using VBA, VB.NET, JavaScript... I will take this as an opportunity to learn a new language.

If you want to learn java you can use the Apache PDFBox
Here is an implementation example.

Use Action Wizard in Acrobat X Pro.
Create New Action.
Setup Start With, and Save To step.
Set checkbox Overwrite existing files.
Select Content. Select Add Document Description.
Left mouse click in option. Uncheck Autor checkbox Leave As Is and enter new Autor name.
Press Save button, set name action Your Action Name.
Run Action:
File- Action Wizard - Your Action Name.
I test it - work).

Related

Adding custom link(run javascript) to PDF files with 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.

How to click on a button based on the presence of some text, in Selenium using Python?

I have a test case where I am supposed to create an export doc to verify that the functionality is working fine. For every export doc, I am explicitly providing the doc title, as can be seen in the screenshot. Since the scripts will be running on a regular basis, before creating the doc, I want to check whether a doc with the same name already exists or not - and if it exists, delete it and then proceed with the creation part.
The export page is structured to list down latest created docs on the top. Its fine for me to just click on the first delete button encountered but to make it more robust, I am seeking to actually look for a doc with the required title and then click on the corresponding Delete button.
I am unable to think through an optimal approach as to how to click the Delete button when the doc is found (multiple docs with the same name may/ may not be present)
Any help on this is highly appreciated. Thank you!

Remember elements text clicked of names in Selenium?

As an example lets say I wanted to record all bios of users on SO.
Lets say I loaded up: How to click an element in Selenium WebDriver using JavaScript
I clicked all users: .user-details a (11 of them)
I wrote Extracted text -> to a csv.
driver.get(‘Version compatibility of Firefox and the latest Selenium IDE (2.9.1.1-signed)’)
I read from csv the users.
user: Ripon Al Wasim [Is present again, do not click him] ??? How can this be achieved. As its text.
Is something like this accomplish-able or is this a limitation of selenium python?
You could click all of them, but lets say you had to scrape 200 pages and common name Bob popped up 430 times. I feel like it is unnecessary to click his name. Is something like this possible with Selenium?
I feel like I'm missing something and this is achievable but I am unaware how.
You could compare the text of text file and print(elem.get_attribute("href")) -> write that to a file and compare them. If elements were present, delete them but this is text. You could (maybe) put the text in an excel file. I'm not entirely sure if this is possible but you could write the css elements individually beside the text in the excel. And Delete rows where there are matched strings. And then get Selenium to load that up into Webdriver.
I'm not entirely convinced even this would work.
Is there a sane way of clicking css but ignoring names in a text file you have already clicked.
There's nothing special here with Selenium. That is your tool for interacting with the browser. It is your program that needs to decide how to do that interaction, and what you do with the information from it.
It sounds like you want to build a database of users, so why not use a database? something like SQLite or PostgreSQL might work nicely for you.
Among the user details, store the name as it appears in the link (assuming it will be unique for each user), and index that name. when scraping your page, pull that link text, then use SQL statements to search if the record exists by that name, if not, then click the link and add a new record.

Using Python To Access E-mail (Lotus Notes)

Basically, I need to write a Python script that can download all of the attachment files in an e-mail, and then organize them based on their name. I am new to using Python to interact with other applications, so I was wondering if you had any pointers regarding this, mainly how to create a link to Lotus Notes (API)?
You can do this in LotusScript as an export of data. This could be an agent that walks down a view in Notes, selects a document, document attachments could be put into a directory. Then with those objects in the directory(ies) you can run any script you like like a shell script or whatever.
With LotusScript you can grab out meta data or other meaningful text for your directory name. Detach the objects you want from richtext then move to the next document. The view that you travel down will effect the type of documents that you are working with.

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.

Categories