# Copy report pasteboard

**URL:** <https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [October 11, 2020, 6:39am UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576 "2020-10-11T06:39:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 11, 2020, 6:39am UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/1 "2020-10-11T06:39:32Z")

</div>

I want to copy the report to the pasteboard, then modify some attributes, and then paste it back, because too many of the same attributes need to be modified in batches. The following is the method I found, but it does not work

```auto
def addURLToClipboardObject(url):
	from java.awt import Toolkit
	from java.awt.datatransfer import DataFlavor, Transferable
	from java.io import ByteArrayInputStream
	from java.lang import String
	import re
	
	class MockReportMillClipboard(Transferable):
		RMDataFlavor = DataFlavor("application/reportmill", "ReportMill Shape Data")
		def __init__ (self, data):
			self.data = String(data).getBytes()
		
		def isDataFlavorSupported(self, flavor):
			return flavor == self.RMDataFlavor
		
		def getTransferData(self, flavor):
			if flavor == self.RMDataFlavor:
				return ByteArrayInputStream(self.data)
	        
	clip = Toolkit.getDefaultToolkit().getSystemClipboard()
	
	dataflavor = None
	for df in clip.getAvailableDataFlavors():
		if df.mimeType == 'application/x-java-serialized-object; class=java.lang.String':
			dataflavor = df
			break
	if df:
		data = clip.getData(dataflavor)
		regex = r"<text(.*)>"
		subst = r'<text\g<1> url="%s">' % url
		result = re.sub(regex, subst, data, re.MULTILINE)
		print "Added URL to clipboard object"
		clip.setContents(MockReportMillClipboard(result), None)

```

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 11, 2020, 6:40am UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/2 "2020-10-11T06:40:21Z")

</div>

> [@PDF report linking](http://forum.inductiveautomation.com/t/pdf-report-linking/18860/2):
>
> You completely nerd-sniped me with this topic - I definitely shouldn’t have spent as much time on this as I did. But, this is actually possible with the existing reporting module. We’ll definitely have to see about adding this capability in a better way. Basically, the workaround I came up with relies on the fact that objects in reporting can be copied to the clipboard and show up as XML representations of the underlying Java object. So, to use this (extremely janky) workaround: 0. Paste the s…

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 12, 2020, 12:50am UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/3 "2020-10-12T00:50:24Z")

</div>

hellow

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 12, 2020, 12:43pm UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/4 "2020-10-12T12:43:53Z")

</div>

> [@448719222](#):
>
> but it does not work

That's not much information about your problem. Paul's really good at this stuff, but I don't think he reads minds yet.

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 12, 2020, 1:04pm UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/5 "2020-10-12T13:04:51Z")

</div>

I want to copy the report and batch modify some of the same properties on other editors, such as adjusting the width to 5, selecting all, and replacing them instead of modifying them one by one. Paste the modified ones back, instead of modifying them one by one in the original report

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 12, 2020, 3:55pm UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/6 "2020-10-12T15:55:38Z")

</div>

The technique in the original post would need significant changes to work for ‘batch’ processing. You’re on your own 🙂

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 13, 2020, 1:31am UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/7 "2020-10-13T01:31:54Z")

</div>

Oh, is there anything to share

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 13, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/8 "2020-10-13T14:46:14Z")

</div>

```python
	dataflavor = None
	for df in clip.getAvailableDataFlavors():
		if df.mimeType == 'application/x-java-serialized-object; class=java.lang.String':
			dataflavor = df
			break
	if df:
		data = clip.getData(dataflavor)
		regex = r"<text(.*)>"
		subst = r'<text\g<1> url="%s">' % url
		result = re.sub(regex, subst, data, re.MULTILINE)
		print "Added URL to clipboard object"
		clip.setContents(MockReportMillClipboard(result), None)

```

The important piece is this. It does naive regex replacement to modify the XML representation you get out of reportmill. If you multi-select your elements and then paste into a text editor, you can see that same representation. You can parse and manipulate that tree accordingly, and then use the `MockReportMillClipboard` class to, as the name implies, mock the ‘real’ ReportMill [`Transferable`](https://docs.oracle.com/javase/7/docs/api/java/awt/datatransfer/Transferable.html) class - that way it will paste back into the reporting workspace as ‘real’ objects.

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [October 13, 2020, 3:04pm UTC](https://forum.inductiveautomation.com/t/copy-report-pasteboard/39576/9 "2020-10-13T15:04:56Z")

</div>

Thank you very much, you are so amazing
