How to set up a Raspberry Pi to act as a printer and save printed files? - raspberry-pi

I need to set up a Raspberry Pi as a printer. When something is printed to the Raspberry it should save the file, so that I can work with it.
The plan is, to use it instead of the printer to save paper.
EDIT:
It will be printed from a cash register - it should replace the printer. And I want to read the file with an application to save the informations into my database.

Related

How to save and load a RoomPlan scan to use as a "test" scan

I'm working on a RoomPlan app. I've successfully managed to capture, save and load scans using NSKeyedArchiver. However, for apps run on the simulator or on devices without a LiDAR Scanner, I do not have any scans saved on that device so I cannot test the functionality. I want to "fill" my app with a test scan or two to be able to test my app on those devices.
The core problem here is that I can't figure out how to "capture" objects in Swift and save them hardcoded in the app instead of in NSKeyedArchiver, which is local to every device.
You are doing this:
RoomScan --(via NSKeyedArchiver/Encodable)--> Data --(save)--> UserDefaults
UserDefaults --(read)--> Data --(via NSUnarchiver/Decodable)--> RoomScan
So, what I suggest:
Scan a room, then convert it as Data, save it if needed.
Intercept that Data either by forcing a reading, or before saving into UserDefaults.
Choose the solution you find easier/quicker for you for the "intercept":
Convert the Data into HexString (see How to convert Data to hex string in swift), print it into Console, copy the output or save maybe that content into a Data file, and send it via AirDrop/Mail.
Create a new file into your project, and read it when needed (simulator, etc). Depending on the solution chosen since the writing might differ, the reading also might differ.

Weird symbols in the file

Trying to install a driver, and need to edit the payload. However, payload is in weird symbols.
Example:
3ÛJgñÂê>‚B.Éîgv.N.
Any idea how to change it to something i can actually edit?
Actual file was installed from the linked site. USB MIDI Driver (10.7).pkg

How can I shrink an image of an SD card to fit a smaller card?

I've been slowly building a home automation framework (Python and SQL) on a Raspberry Pi. I'm really happy with it and am trying to deploy it on a few other Pi's around the house.
I've used win32diskimager to create a .img archive of the SD card and have (on a few occasions when I stuffed things up) been able to restore to the same card.
The problem is that (illustrative numbers only) my current "8GB" SD card is 7.88GB, but the new SD cards I've purchased are 7.86GB. The image is 7.88, so it refuses to write to the 7.86GB card (even though about half of that image is just blank space).
Can I resize my image? Tried using "truncate" in nix but (for some reason) vital data is stored at the end, or there's a checksum, because lopping off a few hundred mb was enough to corrupt the file and prevent mounting / writing.
Happy to take alternate solutions for SD card cloning too. I have access to OSX / Ubuntu / W8.1, but Windows is preferred because that's where I've got the img at the moment.
Appreciate any tips!
Sam
A bit late but I found a setup that works:
Run the SD card inside a raspberry and use
sudo apt-get install -y gparted
sudo gparted
To edit its partitions. Look for the main partition, unmount it and resize it to the desired size. I haven't confirmed whether it matters but I made sure the relevant data is "on the left" and the unallocated data on the right.
There's a more detailed guide on how to do this here:
https://learn.adafruit.com/resizing-raspberry-pi-boot-partition/edit-partitions
If you can't do this for whatever reason, an alternative is setting up a fresh SD card with a new installation of say Raspbian lite and removing the option to expand into remaining space of the SD card from cmdline.txt (in my case this was the last option in the list) BEFORE running the new installation in a Raspberry pi. Then you can set up the Pi the way you like inside a smaller partition.
Once you have shrunk the needed partitions you can easily make a small image:
In Windows, you can use Win32DiskImager to make the image, while making sure "Read Only Allocated Partitions" is checked, giving you an image that - surprise surprise - omitted the unallocated data.

how to copy the contents of sd card to another

I have sd card, I installed ubuntu on it in order to use it in beagleboard.
Is there a program to copy the entire contents of the sd card to another one??!!
I basically want to copy the operating system to the other sd card.
As far as I am concerned, you need to "install" it again on another SD card. You can copy certain files but the Os just cannot be "copied" like that. The solution is to take the -iso image of the OS and reinstall it to another SD.
EDITED:
I've been looking deeper and maybe the Win32DiskImager program that is normally used to install image files to SD cards, could also "clone" your SD card. Try to download it, and as soon as you open it you have a "read" option, that would provide you a solution.Cloning the SD card is simple. Just follow these steps:P
Extracted from: http://lifehacker.com/how-to-clone-your-raspberry-pi-sd-card-for-super-easy-r-1261113524
Follow these steps to clone the SD card:
Get everything set up just the way you want it on your Raspberry Pi, whatever you're using it for. Then shut down the Pi and remove the
SD card. Insert the SD card into your computer.
Start up Win32DiskImager, a program that you probably have from when you first set up your Pi. (If you're on OS X or Linux, you'll
have to use the dd command as described here instead of these steps).
In the "Image File" box, enter the path of your soon-to-be image file. For example, I put mine in C:\Users\Whitson\images\myraspbmc.img
Under the "Device" box, select your SD card.
Click the "Read" button to create the image file from your card.
When it's done creating the image file, you can eject your SD card and put it back in your Raspberry Pi. Keep that IMG file in a safe
place.

Openoffice Writer macro that uploads current file to a web service on save

I want to know if this is doable and get some hints about how to achieve this.
I guess at least it would need a confirmation dialog to run the (possibly evil) macro.
I want to produce an OpenOffice document that will upload itself on save to a hardcoded URL.
Is it possible?
What are the rough steps to achieve this?
My guess is:
bind a macro to the save event
have that macro get the current file binary data
have it post this data to a URL
but before researching about how to do this I need to know if this can be done in the first place.
I don't believe you need a macro to do this, instead depending on your OS you can map a FTP or other type of protocol remotely.
For example in windows you can "Map" a FTP as a drive and this would do exactly the same thing as your describing, you open the file from the FTP and upon saving it will then be written to the remote server. FTP is just an example here, there are other platforms you can use.
If you are at all interested in this method then following the instructions below, otherwise disregard.
Mapping a Network Drive in Windows Vista and 7.
Click on Windows start orb and then click on "computer".
Click on map a network drive.
Map a network drive will then open a new dialog box where you can click "connect to a website"
Simply follow that easy to use wizard and click add a new network location (Choose a custom network location)
Type in your FTP address, including username and password.
Finally name your network location to whatever you want.
Just a suggestion, I really don't think you need any macro unless you plan on distributing these files to other people then yes, but they would need to install that macro/plugin on their open office since there is no way to encode the document itself with such features as far as I know.