Merge pdf files

Is it possible to read two blobs and merege them into one pdf file? I have been able to a blob and write it to a file, however I am still struggling in reading two of them and merging them both into one pdf file.OutputStream fwriter = new FileOutputStream("c:\\test _new.pdf");
                         wrote = readFromBlob(blob, fwriter);
                         fwriter.close();
final static int bBufLen = 4 * 8192;
public long readFromBlob(Blob blob, OutputStream out) throws SQLException, IOException
     InputStream in = blob.getBinaryStream();
     int length = -1;
     long read = 0;
     byte[] buf = new byte[bBufLen];
     while ((length = in.read(buf)) != -1)
          out.write(buf, 0, length);
          read += length;
     in.close();
     return read;
}what I am trying to do is to pass two blobs to this method readFromBlob and then merge them to wrie to a file so if I pass two blobs
public long readFromBlob(Blob blob1, Blob blob2, OutputStream out) throws SQLException, IOException
     InputStream in = blob1.getBinaryStream();
                      InputStream in2 = blob2.getBinaryStream();
     int length = -1;
     long read = 0;
     byte[] buf = new byte[bBufLen];
     while ((length = in.read(buf)) != -1)
          out.write(buf, 0, length);
          read += length;
                     while ((length = in2.read(buf)) != -1)
          out.write(buf, 0, length);
          read += length;
     in.close();
     return read;
}But this doesnot seem to work? And advice!!!!

public void addPDFContent(Document pDocument, PdfWriter pWriter, java.io.InputStream is) throws DocumentException, IOException
     PdfReader reader = new PdfReader(is);
     int numberOfPages = reader.getNumberOfPages();
     PdfContentByte cb = pWriter.getDirectContent();
     for (int i = 1; i <= numberOfPages; i++)
          if (i > 0)
               pDocument.newPage();
          PdfImportedPage page = pWriter.getImportedPage(reader, i);
          cb.addTemplate(page, 0, 0);
}

Similar Messages

  • How to merge pdf files into one pdf file?

    In E-Rec we need the capability to mass printing for correspondance. There i want to merge pdf files for candidates into one pdf file. I am doing the following:
    Data: lv_document1           TYPE rcf_s_cs_document_content.
    LOOP AT activity_object_tab INTO ls_activity_object.
        lo_act_corr ?= ls_activity_object-activity.
         CALL METHOD lo_act_corr->process_document
           EXPORTING
             channel  = 'FRONTEND'
           IMPORTING
             document = lv_document1.
      ENDLOOP.
    Now lv_document1 contains the pdf file in  lv_document1-DOCUMENT_X which is of type RAWSTRING.
    This works for one candidate, in this case the pdf for last candidate will be displayed.
    But how would i append in the loop or what would i need to do display all candidates in one pdf.
    Any help will be appreciated.
    Thanks

    File>Create PDF>From File.
    Please post followups in the Acrobat forum.
    Bob

  • Problem in Merging PDF files

    Need to print batches of PDF.<br />The command copy *.PDF > LPT1: (redirected by NET USE) doesn't work.<br />On the printer I get an error message. All files are sent in one file.<br />.<br />I guess this is related to the PDF header which is not set correctly for the second PDF copied.<br />I mean, according to the PDF Reference guide, the proper syntax for a PDF file header is for the "%PDF-<version>" comment to be the first line of the PDF file. The recommended second line is a comment line with four binary characters to indicate the file contains binary information.<br />.<br />Acrobat requires only that the header appears somewhere within the first 1024 bytes of the file.<br />.<br />I guess the Rip is not able to convert PDF into PS before its interpretation as the second header exceeds 1024. Even the combined file has %%EOF before each PDF Header, this is probably not enough to merge them without problem.<br />.<br />Did you experience the same ?<br />Thanks for your comments.<br />Regards.<br />Franck

    You can build your own PDF merge utility using the PDF Merge and split libraries for .NET from from http://www.dotnet-reporting.com or http://www.winnovative-software.com .
    You can use it to merge PDF files, html files, text files and images,
    set the page orientation, compression level and page size.
    All this can be accomplished with only a few lines of code:
    PdfDocumentOptions pdfDocumentOptions = new PdfDocumentOptions();
    pdfDocumentOptions.PdfCompressionLevel = PDFCompressionLevel.Normal;
    pdfDocumentOptions.PdfPageSize = PdfPageSize.A4; pdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
    PDFMerge pdfMerge = new PDFMerge(pdfDocumentOptions);
    pdfMerge.AppendPDFFile(pdfFilePath);
    pdfMerge.AppendImageFile(imageFilePath);
    pdfMerge.AppendTextFile(textFilePath);
    pdfMerge.AppendEmptyPage();
    pdfMerge.AppendHTMLFile(htmlFilePath);
    pdfMerge.SaveMergedPDFToFile(outFile);

  • Merge PDF files into (preserving layer info)

    Is it possible to combine several PDF files into one and preserve the layers of each source PDF into the merged one ?

    ... not sure SSIS is the correct tool for you unless you're already using it or have other tasks to perform besides merging pdf files.
    There is no functionality like that available out of the box, but if you have the right (third party) .Net assemblies then you could use SSIS (Script Task/Component). An other option is to call a tool/batch file via the execute process task.
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Merging PDF files through a script

    Hi everyone,
    I want to merge a couple of PDF files
    through a script, because i have to do
    it for a good number of them every time
    I get them sent.
    I was wondering, does Reader have a
    command that can be called in the command
    line in order to merge this pdf files through
    a script.
    Ted.

    Reader can do very few things besides being a reader. If you wanna merge PDF files, use a PDF merger.

  • Getting NULLPointerException while merging pdf files using PDFDocMerger

    Hi,
    I am using BI Publisher 11.1.1.7 Version Jar Files to use PDFDocMerger Class in Jdeveloper and my requirement is,
    need to merge pdf files taking from the third party server.So, I am passing url as an input to PDFDocMerger(As per BIP documentation we can pass url as an input to PDFDocMerger using Object Class) but I am getting NULLPointerException.
    I am using below code:
    import java.io.File;
    import java.io.FileOutputStream;
    import oracle.xdo.common.pdf.util.PDFDocMerger;
    public class PDFMerger
    public PDFMerger() {
         public void pdfDocumentMerger() {
    try {
    System.out.println("Testing1");
                      Object[] f = new Object[2];
                f[0]= ("http://docs.mytxi.com/downloads/Invoices/OE/06082013/02599553.PDF");
                f[1]= ("http://docs.mytxi.com/downloads/Invoices/OE/06082013/02599553.PDF");
                FileOutputStream output;
                output = new FileOutputStream("c:\\docs\\OutputPDF.pdf");
         System.out.println("Testing3" + f[0]);
                PDFDocMerger pdfMerger;
                pdfMerger = new PDFDocMerger(f, output);
         System.out.println("Testing4");
          pdfMerger.process();
         System.out.println("Testing5");
    pdfMerger = null;
    output.close();
         }//try
          catch (Exception e)
          System.out.println(" Exception " + e.getMessage()) ;
          e.printStackTrace() ;
          System.out.println("End") ;
       public static void main(String[] argv) {
    PDFMerger xmlPublisher;
    xmlPublisher = new PDFMerger();
    xmlPublisher.pdfDocumentMerger();
    Error:
    Testing1
    Testing3http://docs.mytxi.com/downloads/Invoices/OE/06082013/02599553.PDF
    Testing4
    Jul 22, 2013 10:22:22 PM oracle.xdo.common.pdf.util.PDFDocMerger$PDFUtility <init>
    SEVERE: The first input to be merged has problem and caused stopping merging
    Jul 22, 2013 10:22:22 PM oracle.xdo.common.log.Logger log
    WARNING: java.lang.NullPointerException
    at oracle.xdo.template.pdf.util.PDFObjectDictionary.<init>(PDFObjectDictionary.java:36)
    at oracle.xdo.common.pdf.util.PDFDocMerger$PDFUtility.checkIfDupFields(PDFDocMerger.java:2438)
    at oracle.xdo.common.pdf.util.PDFDocMerger$PDFUtility.processWithNoOut(PDFDocMerger.java:2932)
    at oracle.xdo.common.pdf.util.PDFDocMerger.generateMergedPDF(PDFDocMerger.java:623)
    at oracle.xdo.common.pdf.util.PDFDocMerger.mergeDocs(PDFDocMerger.java:551)
    at oracle.xdo.common.pdf.util.PDFDocMerger.process(PDFDocMerger.java:506)
    at xxtxi.oracle.apps.ar.iex.server.PDFMerger.pdfDocumentMerger(PDFMerger.java:24)
    at xxtxi.oracle.apps.ar.iex.server.PDFMerger.main(PDFMerger.java:40)
    Exception java.lang.Exception: Document #2 looks corrupted.
    oracle.xdo.XDOException: java.lang.Exception: Document #2 looks corrupted.
    at oracle.xdo.common.pdf.util.PDFDocMerger.process(PDFDocMerger.java:510)
    at xxtxi.oracle.apps.ar.iex.server.PDFMerger.pdfDocumentMerger(PDFMerger.java:24)
    at xxtxi.oracle.apps.ar.iex.server.PDFMerger.main(PDFMerger.java:40)
    End
    Process exited with exit code 0.
    It would be great, if any one provide solution on this issue.
    Thanks,
    Irfan.

    One of the merged PDF was edited by using the "Adobe Lifecycle Assembler" tool and i was able to open that file successfully in my machine.
    Is bi publisher API compatible with such files?
    It would be great, if any one can throw some light on this issue.
    Thanks,
    Indira

  • While trying to merge pdf files which are having the version 1.4 throws err

    As per my business need i need to merge some pdf files. Among those files some are having the version above 1.4. I am using the api "oracle.apps.xdo.jar ".
    While trying to merging the pdf files its throwing the exceeption like
    " oracle.apps.xdo.XDOException: oracle.apps.xdo.template.pdf.exception.FatalException: The template seems to be in either corrupted one or newer version than PDF1.4 ".
    If all of the files are having the below 1.4 version then working fine. But any one of the file have above 1.4 version then it is throwing the above error.
    Please can i have the solution for this problem.

    Thanks for the response.
    Sorry.there is no option to feed again into <1.4 version. cause those documents are already existed in database and i have to use the same documents to merge.
    So is there any alternate solution on the same .

  • How to merge pdf files in Preview in Lion

    I've consulted Preview Help to find out how to merge many pdf files into one. The Help window tells me to open each file, and transfer the thumbnail from each opened document into the sidebar of the other. Who wrote this Help item? Once you drag one thumbnail into the other sidebar, the other window closes, and there's no way to drag the closed file into the other file's sidebar. And I've tried! And tried! A helpful way out is to combine the two files, click Print, then save as PDF. But there must be a more direct way to accomplish this merger. Before Leopard, the procedure was easy. Then in Leopard, Apple made it a little more challenging. Finally in Lion, Apple seems to have surpassed itself, making it almost impossible. Does anyone know how to accomplish this Herculean task in an easy way?

    > The Help window tells me to open each file, and transfer the thumbnail from each opened document into the sidebar of the other.
    It works the same way it did in SL. That's exactly what I did. Are you sure you are dragging the thumnail? I just dragged a pdf to a file of many pdfs combined and it went right in and joined the family. View menu > Thumbnails?

  • Merging PDF files

    Can someone please tell me how to merge multiple PDF files into one PDF file?

    Hello,
    To edit or merge PDFs you need to use Adobe Acrobat desktop software.
    You can download a free 30 day trial of Acrobat Pro here:
    http://www.adobe.com/products/acrobatpro/tryout.html
    Regards,
    Michelle

  • Merging PDF files - Each file name to be added as bookmark

    Hi,
    Assume i have pdf file with file names as follows
    Intrduction.pdf
    Lesson1.pdf
    Lesson2.pdf
    Lesson3.pdf
    After Merging in to a single pdf file i want the file names to be added as bookmark and when i click the
    a. Lesson1 bookmark it should go to the Lesson1 first page
    b. Lesson2 bookmark it should go to the Lesson2 first page
    Please let me know how to achieve this.
    Thanks.

    Combine the files as usual via File - Create - Combine files into a Single PDF, just click on the Options button in that window and make sure that the "Always add bookmarks" box is ticked.

  • Unable to merge PDF files.

    I have been running Acrobat 5 for a number of years and until recently have been able to merge and/or pages to existing PDF files with no problems; however I now get the following error statement when I try to merge or add pages to an existing file.  "These documents contain subset fonts that have the same name and cannot be merged"
         Does anyone know exactly what that means?  And how do I over ride that error.  What I have to do now, is take my original file, convert it to JPG files, then transfer it to Word and convert back to PDF.  It works but is a lot of extra work.  Help!!

    Try67- Thanks- How do I embed full font subsets when creating files. The pdf files were created from Word and include captions for photos .
    On the conversion. I convert the existing pdf files (pages of photos) to jpg and then import them to Word so I can add the new Word photo pages to them and then convert them back to PDF files. I know that sounds weird, but it works.
    Previously I could just add the new pdf pages to existing pages, but not anymore. Fred

  • Merging PDF Files in Preview 5 in OS X v10.7 Lion

    I recently updated to the OSX v10.7 Lion operating system.  In the previous version I had, I was able to merge two or more PDF files in Preview just by dragging the thumbnail.  However, in the Lion version, it is not allowing to drag one PDF file into another.  It just opens them as different files in the same preview window.  I need to know if someone can help me figure out how to merge these files 'cause I can't send ten different PDF files to my client.  Thank you so much for any help you can provide.

    Use 'Automator (applications > automator.app).
    Choose 'Workflow'.
    Type 'get specified finder' in the little search box.
    From the list drag 'get specified finder files' into the the panel on the right. Click 'options' and check 'Show this action when the workflow runs'.
    Next type 'combine pdf' in the search box, and drag 'Combine pdf pages' into the panel on the right underneath the previous one.
    Save the workflow to your apps folder.
    Whenever you want to merge any pdfs, click on the workflow. Add the pdfs to the dialogue box, click 'Run' in the top left of Automator. To find the resulting merged pdf, click 'Results'.
    This is no doubt a clumsy way of doing it, but it works.

  • Merge pdf files in preview

    I must be missing something. I've read the instructions for merging pdf documents in Preview, but it's just not working. Wants me to "duplicate" a file or something. This seems very un-Mac-like. I get 2 documents open, drag the thumbnails from one into another, one at a time, and then try to "Save As". Can anyone tell me what I might be doing wrong? I'm using Lion.
    TIA!

    This is because of the new versioning.
    As I recall this is what I did.
    Start with a new, blank preview page and then drag the other pdfs onto the blank form.
    I am not sure how I created the new blank page. I may have created it with Adobe first.
    It seems that one cannot use Preview alone to open a new blank pdf.
    Now when you click Save you should be asked for a new name.
    Otherwise, I think that preview will overwrite one of the other pdf files with the new files.
    It's a bit confusing - I suggest experimenting with a few "scrap" pdf files first.
    I wish Apple would put back the old "Save as" function. It is so much clearer and intuitive than the current scheme where often one has to search for the location of the file once it goes away.

  • Failed conversion with merging PDF files

    I am trying to merge 3 files together.
    Each time I am trying to upload them, they fail with the conversion.
    I know we are having a slow internet connection, but with other files it did work.
    Also with another file I merged, it did not merge in the order I wanted it to merge. How could I fix this?
    I hope someone can help me!

    Hi Gerard,
    What version of Acrobat are you using?
    Is it updated to the latest patch?
    Where are you trying to upload the files?
    Which OS are you using?
    Are you trying to create a pdf portfolio or a single pdf file of the 3 files?
    Regards,
    Rave

  • Batch Merging PDF files.

    Okay here is the deal. We have two folders. Both folders have different PDF files that have the exact same name. So there is a /billing/00001.pdf and /activity/00001.pdf. We want to merge those two PDFs together through a batch process that will take care of all of the PDFs in each of the folders at once. Is this possible?

    Hello
    We look exactly for the same. A Batch Script to have multiple files merged in one PDF. Can you please also send me a PM for further Information?
    Thanks a lot
    regards
    Stefan

Maybe you are looking for

  • Can you hook up a monitor using hdmi?

    Hi I am using a Cintiqi Display and would like to add another monitor using the other port HDMI is that possible or do I need to do something else. I just wanted another display to watch videos to learn how to do some Adobe products and thought it be

  • Feedback Form Coding

    I have a contact form-to-mail php file with an apparent script error that I can't find. The submission bit works well, meaning it gives the impression that it is sent, but it doesn't get delivered at all. The code is attached.

  • Can't configure SMSY

    Hello, i'm new at SAP and i have trouble with SM configuration. I correctly configured OSS1 and saprouter, everything is working ok. I created also landscape, and that's working fine also, except that i can't do Read System Number. I recieve error SA

  • Powershell script for deleting sitecollection and its content db

     want to know whether any powershell script is avlble for deleting the sitecollection and its content db at oneshot! i have created sitecollection specific content db and i wanna delete the same.

  • Here solution for logic 9.1.5 issue under SL 10.6.8: Won't quit until saving project

    You have to follow instructions in this Apple support' s Link. http://support.apple.com/kb/DL1385 That's work fine for me for Logic 9.1.5 on MacbookPro3,1  2,2 Ghz under 10.6.8 after upgrade from 10.5.8 without re-install Logic. ;-) Have Fun!