You are viewing limited content. For full access, please sign in.

Question

Question

DocumentExporter in Java.

SDK
asked on September 2, 2014

Hi there,

 

Is there any class used to export document in laserfiche repository to PDF using JAVA ? I don't find out yet...

 

0 0

Answer

SELECTED ANSWER
replied on September 3, 2014

Please call Document.readEDoc to get an InputStream instance that can be used to read electronic document data, and Page.read to read page parts.

0 0

Replies

replied on September 2, 2014

There isn't anything like DocumentExporter. The Laserfiche Java libraries do not have any facilities to generate PDFs, or to perform image format conversion (e.g., converting a PNG to a TIFF). You can download and upload the raw byte streams using the Java libraries but you'll need to use third-party libraries to generate a PDF.

1 0
replied on September 3, 2014

Hi Michael, 

 

You said: You can download and upload the raw byte streams using the Java libraries but you'll need to use third-party libraries to generate a PDF.

 

I I find out how to upload a file to laserfiche repository with Java. But i dont find any class in laserfiche java SDK to download a file through byte streams with Java. If you enlighten me in this problem, i'll be very gratefull. 

0 0
SELECTED ANSWER
replied on September 3, 2014

Please call Document.readEDoc to get an InputStream instance that can be used to read electronic document data, and Page.read to read page parts.

0 0
replied on September 4, 2014

Hi Michael, thanks for the help.

 

	public void getFileFromRepository(int id){
		
		try {
			if(id != 0){
				Document doc = Document.getById(id, RepositoryConnection.getInstancia());
				Entry entry = doc;
				String formato = "";
				
				if(doc.getMIMEType().equals("application/pdf"))
					formato = "." + doc.getExtension(); 
								
				File f = new File("C:\\Users\\allan.freitas\\Pictures\\");
				InputStream inputStream = doc.readEDoc();
				OutputStream saida = new FileOutputStream(new File(f, entry.getName() + formato));
				
				int ler = 0;
				byte[] bytes = new byte[1024];
				
				while((ler = inputStream.read(bytes)) != -1){
					saida.write(bytes, 0, ler);
				}
				
				inputStream.close();
				saida.flush();
				saida.close();				
				
				RepositoryConnection.getInstancia().logOut();
				System.out.println("Documento exportado com sucesso!");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

I hope the code above help others with the same difficulty!

1 0
replied on September 2, 2014

I am not sure that there is one but I do know you can export Laserfiche pages as a PDF file through Workflow or the SDK. Here is an example in VB that Workflow can use:

 

ExportDoc.ExportPdf(MyDocument,MyDocument.AllPages, PdfExportOptions.None, DirectoryFolder + EntryName + ".pdf")

 

0 0
replied on September 2, 2014

Hi Cristobal Guerrero,

 

In VB or C# I already known! But thanks! i'm looking for the same thing in java.

0 0
replied on September 2, 2014

Using the .COM (ActiveX/ OLE)  libraries, you should have access to the PDFExporter provided by Laserfiche.  Unfortunately I don't have a Java example (I use C# with .COM) which is mixing Win32 with .NET -- and have no problems.  See if you can see how to use .COM in Java, and take it from there.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.