I feel like if anybody can help me, it is you PhiLho, thankfully, you are all over this forum. Here is my code, it runs perfectly, but, when I click save, I want it to create another .exe, rather than a .tiff image, let me add, it does't have to be exe, just something I can display the pdf, not an image, without editing options I will add in the future. To start click import and pick a pdf file;
pdfit.pde
import org.apache.pdfbox.pdmodel.edit.*;
import org.apache.pdfbox.persistence.util.*;
import org.apache.pdfbox.pdmodel.interactive.action.*;
import org.apache.pdfbox.pdmodel.graphics.shading.*;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.*;
import org.apache.pdfbox.pdmodel.documentinterchange.prepress.*;
import org.apache.pdfbox.pdmodel.text.*;
import org.apache.pdfbox.pdmodel.interactive.pagenavigation.*;
import org.apache.pdfbox.encryption.*;
import org.apache.pdfbox.filter.*;
import org.apache.pdfbox.pdmodel.interactive.measurement.*;
import org.apache.pdfbox.pdmodel.common.function.*;
import org.apache.pdfbox.*;
import org.apache.pdfbox.encoding.*;
import org.apache.pdfbox.pdfparser.*;
import org.apache.pdfbox.pdmodel.*;
import org.apache.pdfbox.pdmodel.interactive.form.*;
import org.apache.pdfbox.util.*;
import org.apache.pdfbox.pdmodel.interactive.viewerpreferences.*;
import org.apache.pdfbox.util.operator.pagedrawer.*;
import org.apache.pdfbox.pdmodel.interactive.annotation.*;
import org.apache.pdfbox.pdfviewer.*;
import org.apache.pdfbox.pdmodel.common.*;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.*;
import org.apache.pdfbox.pdmodel.graphics.optionalcontent.*;
import org.apache.pdfbox.pdmodel.font.*;
import org.apache.pdfbox.pdfwriter.*;
import org.apache.pdfbox.encoding.conversion.*;
import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.*;
import org.apache.pdfbox.pdmodel.common.filespecification.*;
import org.apache.pdfbox.io.ccitt.*;
import org.apache.pdfbox.pdmodel.common.function.type4.*;
import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.*;
import org.apache.pdfbox.pdmodel.interactive.action.type.*;
import org.apache.pdfbox.io.*;
import org.apache.pdfbox.pdmodel.encryption.*;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.*;
import org.apache.pdfbox.pdmodel.markedcontent.*;
import org.apache.pdfbox.exceptions.*;
import org.apache.pdfbox.pdmodel.graphics.xobject.*;
import org.apache.pdfbox.pdmodel.graphics.predictor.*;
import org.apache.pdfbox.util.operator.*;
import org.apache.pdfbox.cos.*;
import org.apache.pdfbox.pdmodel.graphics.pattern.*;
import org.apache.pdfbox.pdmodel.fdf.*;
import org.apache.pdfbox.pdmodel.graphics.*;
import org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.*;
import org.apache.pdfbox.pdmodel.graphics.color.*;
import java.awt.image.BufferedImage;
import processing.pdf.*;
import javax.swing.*;
// fc.getSelectedFile() File Direction with Name
// file.getName() Just the File name with Extension
String x=" ";
float rx = width-6;
float ry = 0;
float ry2 = 100;
int cl = 40;
int b =0;
int rb = 250;
int e = 0;
int re = 250;
int v = 0;
int rv = 250;
int mx =0;
int my =0;
boolean importing = false;
boolean imported = false;
boolean transed = false;
void setup()
{
size(1100, 760);
if (frame != null) {
frame.setResizable(true);
}
background(125,255,55);
drawNavBars();
// noLoop();
// beginRecord(PDF, "filename.pdf");
}
void draw() {
if(mousePressed && transed && mouseX<=50 && mouseX>=0 && mouseY>=0 && mouseY <= 50){
fill(125,255,55);
rect(0,0,width,height);
transed = false;
}
if(!transed)
uploadPDF();
mx = mouseX;
my = mouseY;
fill(255);
rect(width-50,0,50,40);
fill(0);
text("Save",width-35,25);
if(mousePressed && mouseX<=width && mouseX>=width-50 && mouseY>=0 && mouseY <= 50)
save("xxpdf.exe");
//ellipse(mx,my,20,20);
//uploadPDF();
//endRecord();
}
void drawNavBars(){
// Draw something good here
noStroke();
fill(170);
rect(0, 0, width, 40);
}
//UPLOADING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void uploadPDF(){
noStroke();
fill(255);
rect(0,0,50,40);
fill(0);
text("Import",7,25);
if(mousePressed){// && mouseX<=50 && mouseX>=0 && mouseY>=0 && mouseY <= 50){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
// create a file chooser
final JFileChooser fc = new JFileChooser();
// in response to a button click:
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// see if it's an image
println(" "+fc.getSelectedFile());
// (better to write a function and check for all supported extensions)
if (file.getName().endsWith("jpg")) {
// load the image using the given file path
PImage img = loadImage(x);
if (img != null) {
// size the window and show the image
size(img.width,img.height);
image(img,0,0);
}
} else {
println("Open command cancelled by user.");
}
// x = fc.getSelectedFile();
InputStream inputStream = createInput(fc.getSelectedFile());
PDDocument doc = null;
try
{
doc = PDDocument.load(inputStream);
for(int i=0; i<1; i++){
final PDPage page = (PDPage) doc.getDocumentCatalog().getAllPages().get(i);
PipedInputStream pis = new PipedInputStream();
final PipedOutputStream pos = new PipedOutputStream(pis);
BufferedImage bi = page.convertToImage(BufferedImage.TYPE_INT_ARGB, 80);
// println("Conversion done "+file);
PImage image = new PImage(bi);
image(image, width/2-280, 32);
}}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (doc != null)
{
try { doc.close(); }
catch (IOException e) { println("Problem when closing doc: " + e.getMessage()); }
}
}
}
transed = true;
}
}