I need to do this school project where I would take in a text file, convert it to a pdf file (but also format the text so there are different fonts, colors, etc). I thought it would be a cool addon to my project if I were to make a window that would show a visual of how the text file looked before the conversion, and how the pdf file looked after the conversion. I searched up how to take screenshots using java and I was able to find this code snippet.
BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File("/screenshot.png"));
However, this would only take a screenshot of the screen in its current state. Is there any way that the java program would be able to take a screenshot of the text file I had, and the pdf file I created afterwards without these two files already being opened and displayed on the screen?
Related
I have SVG file (created by com.spire.pdf) and this SVG created from pdf file (pdf file created from html using iText lib).
So i need to convert this SVG to SVG with another tags(path), or SVG to PDF.
All tags in my example is like this: <text style="fill:#000000;font-family:Arial;font-weight:bold;" font-size="10" x="36" y="46.21002" letter-spacing="-0.075">2020</text>
I'm find lib, where it's possible to convert (inkscape) where i can by this paramether --export-text-to-path made my SVG file unable to select text.
The final goal i`m need PDF file where unposible to select text from there. (like it was created from image).
There is ways to convert SVG "text" file to SVG "image" file or to pdf?
Inkscape not good for me as i want to do it in java code (Spring boot app)
For now, I’m find only one lib where it's possible to do: inkscape with --export-text-to-path param.
Inkscape work in few threads, and can be runned from java. Convertions are slow, and size of exported files depends of version of inkscape.
I have a scraped few images from a website. The scraper did not download the image files with the correct extension.
I changed one of the file's extension to ".jpg" and it opened in Picasa. So I wrote a Java program to change all downloaded image file extensions to ".jpg".
Now when I tried to open images in Java, using Swing, it's not displaying the image. I am using this code to display. It is working fine with other images downloaded manually from web.
String path = "resources\\images\\"+gamePlayer.getName()+".jpg";
JLabel image = new JLabel(new ImageIcon(path));
I even tried converting image files to a different format by a third part software(Format Factory) but even it couldn't read the file.
I can open and view all the images in Picasa.
How do I display scraped images with incorrect extensions using Swing ?
Picassa is probably inspecting the file signature (https://en.wikipedia.org/wiki/List_of_file_signatures) rather than the file extension and therefore opens it correctly. You can't just rename a file and expect your code to understand how to open/display it.
Anyone know how to remove the Batik logo from the generated images? I'm trying the examples on their page http://xmlgraphics.apache.org/batik/tools/rasterizer.html
This is the source svg image https://bitbucket.org/llythiumn/cmput206/src/912d7681375d/batik-1.7/samples/barChart.svg?at=Ian2
This is the Java line I'm running to convert the svg to a png image
java -jar batik-rasterizer.jar -m image/png samples/barChart.svg
And this is what the generated image looks like with the logo at the bottom
http://svn.apache.org/repos/asf/xmlgraphics/batik/tags/batik-1_0beta2/test-references/samples/barChart.png
Perhaps its simple but I just can't find the option to remove it. Any suggestions would be appreciated.
The watermark is in the source image. If you don't supply a source image with a watermark you won't get one in the output.
Found it. I guess I should have tested it with svg files other than the ones batik provided. It seems that the Batik SVG examples come with a tag that forces the logo watermark. But it only does it when generating the image. Opening the svg image in a browser doesn't show the logo.
I tried it with other svg files from here and it worked fine. http://dev.w3.org/SVG/tools/svgweb/samples/svg-files
I currently have a program that can take a pdf saved to an android device and calls an intent to display the pdf. What I wish to do is to create a multipage pdf out of 2 pdf files saved to the device. Is there some sort of token or symbol that pdfs look for that tells the displayer to create a new page? What can I put between the two inputstreams to denote the fact that I want a new pdf page?
I did a lot of research and tried to use itext but it seemed to over-complicate my program. Is there a simple way to achieve my goal?
Thanks in advance!
I have a group of JRadioButtons. I want to use image instead of text in my JRadioButtons. So I believe i will have to use this:
JRadioButton(Icon icon, boolean selected)
Now the issue is that I am not sure about how to create this icon. I have the image that I want to use and I have copied the image in my source code folder. It is in .tiff format. i want to read that .tiff image (inputStream I believe) and convert that to icon so that i can have my JRadioButtons.
Please help in implementing this.
Thanks in advance.
Assuming you put the image in your source folder, in the package com.foo.bar, and that your build process copies this file with your classes so that it's in the classpath when running the application (that's what all IDEs do by default), you can just use
new ImageIcon(MyClass.class.getResource("/com/foo/bar/MyImage.png"))
to get you an icon.
I'm not sure that Java has native support for the tiff format, so you might have to convert the image to another supported format to load it (gif, JPEG and PNG will work fine).
If you're getting a NullPointerException, it probably means that the image is not at the path you're indicating.
You said you stuck it right into the src folder so this should work:
new ImageIcon(getClass().getResource("icon.jpg"))