A reader, September 27, 2019 - 4:21 am UTC
Thank you...
Mr.
Jai, April 11, 2021 - 4:35 pm UTC
you can merge using ITEXT PDF.
Download 1. itext-2.1.5.jar
2.bcmail-jdk14-143.jar
3.bcprov-jdk14-143.jar
1. Load itext-2.1.5.jar into database
open CMD..change directory to folder where jar file exist.
loadjava -user schemname/password@SID itext-2.1.5.jar
* initially most of them will be compiled with errors
2. Load bcmail-jdk14-143.jar into database
loadjava -user schemname/password@SID bcmail-jdk14-143.jar
3. Load bcprov-jdk14-143.jar into database
loadjava -user schemname/password@SID bcprov-jdk14-143.jar
4. Recompile objects in itext-2.1.5
5. create a java object
set define off
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED <SCHEMA_NAME>."mergePDF" as package createPDF_test;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfCopy;
import com.lowagie.text.pdf.PdfReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
public class mergePDF {
public static void Create_Pdf(String path, String src) throws IOException, DocumentException {
File fs= new File(path);
if(fs.exists())
{
Date ds = new Date();
Document dc= new Document();
FileInputStream fi= new FileInputStream(path);
PdfReader Existfile= new PdfReader(fi);
FileOutputStream fo= new FileOutputStream(path);
PdfCopy copy = new PdfCopy(dc, fo);
try {
PdfReader newfile = new PdfReader(src);
int newfilenoofpages = newfile.getNumberOfPages();
int existfilenoofpages = Existfile.getNumberOfPages();
dc.open();
for (int l = 1; l <= existfilenoofpages; l++) {
copy.addPage(copy.getImportedPage(Existfile, l));
}
for (int k = 1; k <= newfilenoofpages; k++) {
copy.addPage(copy.getImportedPage(newfile, k));
}
newfile.close();
Existfile.close();
dc.close();
}
catch (DocumentException ex) {
System.out.println("ITextHelper.addPDFToPDF(): can't read output location: " + ex);
} catch (IOException ex) {
System.out.println(ex);
}
}
else if (!fs.exists())
{
Document document = new Document();
PdfCopy copy= new PdfCopy(document,new FileOutputStream(path));
try {
PdfReader pr= new PdfReader(src);
if (pr!=null)
{
int numberofpages= pr.getNumberOfPages();
document.open();
for (int k = 1; k <= numberofpages; k++) {
copy.addPage(copy.getImportedPage(pr, k));
}
}
pr.close();
}
catch (DocumentException ex) {
System.out.println("ITextHelper.addPDFToPDF(): can't read output location: " + ex);
} catch (IOException ex) {
System.out.println(ex);
}
document.close();
}
}
public static void main(String[] args) throws IOException, DocumentException {
}
}
6. create a function to call
CREATE OR REPLACE function <SCHEMA-NAME>.CREATE_PDF_TEST_TEN(p_path in varchar2,p_src in varchar2)
return varchar2
as
language java
name 'createPDF_test.mergePDF.Create_Pdf(java.lang.String,java.lang.String) return String';
/
7. Pass the path and source file in the function
April 12, 2021 - 5:19 am UTC
Nice input.