myDocDesigner
:Here is the definition of myDocDesignerclass
with contructor as:
public myDocDesigner(customDocFormat doc, InputStream imageStream, int page) throws IOException
{
docImageStream(imageStream);
calculatePageSize(doc, page);
}
generateOutputDoc()
in myFileManager
class as:jMyDocDesigner = createObject("java"
,"myPackage.visible.myDocDesigner")
.init(jMyLocalDoc ,myImageFileStream,1);
/* load document : `customDocFormat` isn't only a format it also returns the document object of the type `customDocFormat` to be used in #1 & #2 above */
//document & image file paths
lStrInputFilePath = "#expandPath('sampledocs')#\mySampleDoc.pdf";
lStrImageFilePath = "#expandPath('sampledocs')#\myPlacementLogo.png";
//java FileInputStream object for the PDF file
lOsPDFInput = CreateObject("java","java.io.FileInputStream")
.init(CreateObject("java","java.io.File").init(lStrInputPDFfile));
jMyLocalDoc = createObject("java","myPackage.docModel.customDocFormat");
jMyLocalDoc.load(lOsPDFInput);
//FileInputStream Object for image
lSignImage = CreateObject("java","java.io.FileOutputStream")
.init(CreateObject("java","java.io.File").init(lStrImageFilePath));
To be clear and make things easy: I have tried every possible option to the best of my knowledge of Java. But I cannot get this working. This portion of code is a part of project to manipulate documents based upon some internal requirement and conventions. Every thing is working perfectly...I step debugged the whole code, but this portion is hampering everything....I tried 4-5 variations to convert and pass the FileInputStream
object to the contructor as InputStream
but everytime I am getting this error, which is understood, as it is not accepting the parameters I am throwing at it:
I updated my question, since I found out the cause for the problem lied within the FileInputStream object itself that I initialized as pointed out by Leigh in his answer, comes out I was not going the right way, thanks to him...I was able to move forward with my code and here's the only bug in my code that is stopping the project to be finalized :( :
Here are the Java files for PDDocument & PDDocumentInformation classes that I dealing with, and for which I get the incorrect no. of pages after the document is loaded through it: go here
Found it, works perfectly! The arguments signature for myDocDesigner
accepts the FileInputStream
and OutputStream
objects for the input and output documents. The whole problem was my lacks of java knowledge I admit it but thanks to the group and after some study and testing I made some changes and magically it works. Really happy since I can proceed forward now. Thanks Leigh for your help.
fis = createObject("java", "java.io.FileInputStream");
lOsPDFInput = createObject("java", "java.io.BufferedInputStream").init(fis.init(arguments.lStrInputPDFfile));
fos = createObject("java", "java.io.FileOutputStream");
lOsPDFOutput = createObject("java", "java.io.BufferedOutputStream").init(fos.init(arguments.lStrOutputPDFfile));
fimgs = createObject("java", "java.io.FileInputStream");
lSignImage = createObject("java", "java.io.BufferedInputStream").init(fimgs.init(arguments.lStrSignImageFile));
fkeys = createObject("java", "java.io.FileInputStream");
lKeyStoreFileStream = createObject("java", "java.io.BufferedInputStream").init(fkeys.init(arguments.lStrKeyStoreFilePath));