Merge pdf - Empty page

Guys,
I am trying to merge some pdf files into one file. This is my code
- (BOOL) concateFiles:(NSArray *) filePaths {
    PDFDocument * outputDocument = [[PDFDocument alloc] init];
    NSUInteger pageIndex = 0;
    for (id file in filePaths) {
        PDFDocument * inputDocument = [[PDFDocument alloc] initWithURL: [NSURL fileURLWithPath:file]];
        for (NSUInteger page = 0; page < [inputDocument pageCount]; page ++ ) {
            [outputDocument insertPage: [inputDocument pageAtIndex:page] atIndex:pageIndex++ ];
    //BOOL done = [outputDocument writeToFile: @"/Users/bubuzzz/test.pdf"]; // does not work
    NSError *error = nil;
    NSString * filePath=@"/Users/bubuzzz/test.pdf";
    NSData * data = [outputDocument dataRepresentation];
    BOOL done = [data writeToFile:filePath options:NSDataWritingAtomic error:&error]; // does not work either
    NSLog(@"Write returned error: %@", [error localizedDescription]);
    return done;
There is no error during run time. However, the created file only has empty page, though the number of page is correct. The only thing I find out is using CGPDFContextClose to close the context to make it work fine, since it is stated in the document
After closing the context, all pending data is written to the context destination, and the PDF file is completed. No additional data can be written to the destination context after the PDF document is closed.
However, I have no idea how to integrate the CGPDFContextClose into my code. Any suggestion, please?

Just change the above code to do a page by page vopy like yours and it works
#import <Foundation/Foundation.h>
#import <Quartz/Quartz.h>
int main(int argc, const char * argv[])
    @autoreleasepool {
        // insert code here...
        PDFDocument * inputDocument;
        PDFDocument * outputDocument = [[PDFDocument alloc] init];
        NSUInteger pageIndex = 0;
        NSURL * pdfFile = [NSURL  fileURLWithPath:@"/Users/frank/Desktop/Hold/TX-SR304_En_0124.pdf"];
        // open old PDF
        if ((inputDocument = [[PDFDocument alloc] initWithURL: pdfFile]) == NULL) {
            NSLog(@"error opening");
            return 0;
        // copy old PDF to new PDF
        //outputDocument = inputDocument;
        for (NSUInteger page = 0; page < [inputDocument pageCount]; page ++ ) {
            [outputDocument insertPage: [inputDocument pageAtIndex:page] atIndex:pageIndex++ ];
        //write new PDF
        [outputDocument writeToFile:@"/Users/frank/Desktop/Hold/testCard.PDF"];
    return 0;
When this is done testCard.PDF has the contents of the input file.

Similar Messages

  • Merging PDF / Page Numbers / Acrobat SDK V9  & LiveCycle

    Hello everyone,
    I use Adobe LiveCycle to create forms, Visual Studio 2005 and the Acrobat SDK for the application I'm programming to fill in these forms. The application fills in the forms and merges them with no issues.
    The problem I have is that these pages have page numbers in the upper right. I use the Page N of M object on these forms in LiveCycle. PDF page numbers are filled in correctly when filling in the forms, but when I merge PDFs, the pages keep their original page numbers. I've looked at the Windows - Interapplication Communications even using templates to no avail.
    How can I merge these pdf's and have my program renumber these pages correctly and how can insert pages anywhere I want in the merge document?
    Below is the code I use to merge the PDF's. It was posted in a forum.
    Sub MergePDF(ByVal ThePath As String, ByVal outFileName As String)
    On Error GoTo serror
    Dim dPDDocMerge As New Acrobat.AcroPDDoc
    Dim dPDDoc As New Acrobat.AcroPDDoc
    Dim strFiles() As String
    Dim numPage As Integer
    Dim TotalPage As Integer
    Dim objThisFile As IO.FileInfo 'get FileInfo object for file string
    strFiles = System.IO.Directory.GetFiles(ThePath) ' Read in the file names
    Dim b As Boolean ' mostly for testing purposes... could use it for error 'checking to make sure that a file is really added before deleleting it...
    For i As Integer = 0 To strFiles.Length - 1 ' run through all the files in 'the directory
    objThisFile = New IO.FileInfo(strFiles(i)) ' Get the extension
    If objThisFile.Extension = ".pdf" Then ' Only add in PDFs
    If dPDDocMerge.GetFileName = "" Then ' check if it's the first file
    dPDDocMerge = New Acrobat.AcroPDDoc
    b = dPDDocMerge.Open(strFiles(i)) ' open first file
    TotalPage = dPDDocMerge.GetNumPages
    Else
    dPDDoc = New Acrobat.AcroPDDoc
    b = dPDDoc.Open(strFiles(i)) ' open other files
    numPage = dPDDocMerge.GetNumPages ' get the page count
    TotalPage += numPage
    b = dPDDocMerge.InsertPages(numPage - 1, dPDDoc, 0, dPDDoc.GetNumPages, _ False) ' Insert
    End If
    End If
    Next
    'b = dPDDocMerge.Save(1, ThePath & "\" & outFileName) ' save file
    b = dPDDocMerge.Save(1, ThePath & "\" & "\MyTest.PDF") ' save file
    b = dPDDocMerge.Close()
    Exit Sub
    serror:
    MsgBox(ErrorToString)
    End Sub
    Thanks for any code or advice.

    You can't merge LiveCycle forms this way :(. LC forms are NOT standard PDF files and can't be processed in the same way.

  • Standardise page sizes in merged PDF?

    Hi everyone,
    I'm trying to merge together a PowerPoint '07 and an Excel '07 file, both set to A4 lanscape page layouts, in Acrobat 9 Standard.  However, in the final merged PDF, the old Excel pages are huge compared to the PowerPoint slides - about 6 times larger.
    Any ideas how I can force Adobe output a merged PDF all in the same page size and orientation?
    Thanks in advance,
    Simon

    Acrobat's combine feature to merge files into one PDF does not provide a page size "editor".
    Likely a cleaner work flow if the input files had page size adjusted by their native application.
    Once done, use combine to merge into the single PDF.
    You may find this is (over all) easier than using the Crop Tool resize features.
    To view any PDF's page size when open in Adobe Reader/Acrobat go into Preferences.
    Select the Page Display catagory then tick the "Always show document page size" choice.
    Be well

  • Which product do I purchase???? - Creating a merged PDF report from excel with cover page

    Hi Guys,
    I work in the BI field and have created a pdf document using PDFCreator and another third part scripting tool called jpdfbookmarks.
    We have delivered something to the client but the quality of the output ( not the best) and the time it takes to cycle through each page ( when being viewed) within the merged
    pdf document takes a little time...
    So my boss as asked me to explore something within the Adobe suite of products BUT.... i have no idea which one i should choose.
    My requirements are as follows:
    To deliever this report to the client the program needs to be able to do the following:
    1)  convert excel files to pdf
    2) take these individually created converted excel to pdf converted files and and merge them into 1 document
    3) within this merged document have the abilty to be able to bookmark each page
    4) have a cover page with hyperlinks
    5) and finally but most important of all to be able perform steps 1 to 4 above programatically through scripting language vb script / vba
    nice to haves:
    6) abilty to email each merged doc to list of email address
    7) abilty to edit document to add in hyperlinks etc
    Need to get an understanding of costs ie
    1) how much per licence
    2) what product with have all the features above and how much
    Can anyone please be kind enough to point me in the right direction as to what product would be best suited?? Being able
    to scipt a solution together is key.
    Cheers
    Shockwave

    You can do everything except the cover page with Adobe Acrobat (Standard or Pro).  There are demos on our website that you can install and try out.  You will need the SDK documentation and sample code to learn how to automate/program.

  • Make Data Merge import certain page of pdf or indesign document

    I don't know if it is possible but can you make Data Merge import certain page of pdf or indesign document, this would be great addition for indesign

    Here are a couple of questions that might help understand what might need to be done to achieve your request:
    * How do you propose to identify the desired page(s) within a PDF and an ID document, so the merge field placeholder knows how to find it?
    * How do you propose to keep track of the page if they're re-ordered in an updated document?
    * What if the identification marker is within text and flows to a different page - would you want to retrieve the original page (before the reflow) or the new page to which the marker would have flowed?
    Perhaps the scripters could comment on the possibility of scripting these.
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    aybekDes wrote:
    I don't know if it is possible but can you make Data Merge import certain page of pdf or indesign document, this would be great addition for indesign

  • Merge pdf page

    Hi everyone !
    I would like to merge pdf documents : I have a client who wants to send a PDF to several people. Each person puts his annotations (like comments) into the document.
    Then, I get all pdf (always the same, with several comments) and merge it in one PDF with all comments.
    I thought I was able to do it with a simple DDX file, but I can't find a way to do it !
    How can I do it ?
    Thank's for your help !
    FYI, the configuration is : LiveCycle ES + Reader Extensions (I don't think that's help).
    (I hope I post in the right place to ask this.)

    I find a way to do this, but I still have a problem : some comments which are near the same position in 2 or more PDF are not displayed nor assembled. To be exact, only one of them are kept in the output file.
    Have you any idea how to solve this ?
    Thanks for your help !
    FYI, this is how i assemble them :
    <Comments result="allComments.xfdf" format="XFDF">
         <PDF source="doc2" />
         <PDF source="doc3" />
    </Comments>
    <PDF result="output.pdf" save="FastWebView">
         <PDF source="doc1" />
         <Comments source="allComments.xfdf" />
    </PDF>

  • How to download & how to merge pdfs into one pdf file?

    Hello everyone!
    I hope someone can help me, because I am SO frustrated right now! I want to create an electronic document of a 40-page thesis I wrote. I no
    longer have the original computer files, so I took digital photos of each page.
    Then I converted all the jpegs into pdf files.
    Now I want to merge these 40 jpegs into one pdf file.
    I read that this is possible with Adobe Acrobat 8 or 9. So, yesterday I downloaded the trial version of what I thought was Adobe Acrobat 9. Well,
    two whole hours later, all I could find on my computer was Adobe Reader 9, which would not allow me to merge any pdfs.
    So, today, I again reinstalled the Adobe Acrobat 9. Now, after waiting another two hours, there is NOTHING on my computer--no Adobe Reader, no Adobe Acrobat, no desktop icons, nothing in the "All Programs" list when I press the Start menu, etc.
    What happened? How could something that took so damned long to download be totally invisible on my computer now? I do see Arcsoft, but that is for photographs. Is it possible to merge pdfs together using Arcsoft?
    I have SO much other work to do, and I am so disgusted that I have lost two days on this project, just trying to merge pdfs together! Please, if
    you have any suggestions as to how to get Adobe Acrobat 9 as a trial version an/or how to merge pdfs, please answer this post!
    Thank you very much for your help.
    Courtney

    Hi. Yes, that is the link from which I downloaded Acrobat 9. I now have this file on my computer: AcroPro90_efg.exe
    Yes, I did install it, but one of the times it hanged at 99.96%. Do you know what that means?
    Thanks in advance.
    Courtney

  • How does I resize a pdf file page using Acrobat Pro?

    In Acrobat Pro, how can one resize a pdf file page (21.38'' x 26.75'') into one measuring 6'' x 9'', to be submitted as the trim size? Is there a feature that allows this to be done? How does one set all print options from the Application print dialog box to enable one to adjust the dimensions of any customized file page?

    I want to scale the 21.4'' by 26.8'' content down to one that can be fitted inside a 6'' by 9'' book.
    I have this pdf that was created from the InkFlow app, and I'm using Acrobat Pro to merge three files into one (about 300MB), which I needed to submit to Amazon's CreateSpace, but they needed the trim size of 6'' by 9'', while the pdf is 21.4''' by 26.8'', and I can't amend the source file size of the InkFlow files.
    I tried fiddling with the Crop and Print options, but I'm unable to resize the pdf to match the trim size. The problem on my side isn't so much on printing but to resize the pdf file page to 6'' by 9'' to satisfy Amazon's requirement for their trim size. Could this be done with Acrobat Pro? The message that appears is: Full print options of Acrobat Pro, set all print options from the Application print dialog box. Thank for the help.

  • 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.

  • Merge PDF Documents

    Hi,
    I have Adobe Acrobat XI
    I have a PDF Cover Letter, containing recipients, created from Word mail merge and using Excel as the datasource.  One recipient details per page.
    I have another PDF Legal letter, that cannot be edited, and cannot include an address or the normal method of PDF merges, hence the requirement for a cover letter.
    Can I create a new merged PDF document, for each recipient / page in the cover letter, and add the Legal letter after each cover page?
    Cover_Letter.pdf                               Legal.pdf
    Page 1 - Recipient 1                         6 Pages
    Page 2 - Recipient 2
    Page 3 - Recipient 3
    New.pdf
    Cover Letter - Recipient 1
    Legal Pages
    Cover Letter - Recipient 2
    Legal Pages
    Cover Letter - Recipient 3
    Legal Pages
    etc!
    Many thanks
    Larry

    Hi Bill
    Many thanks for your reply.  The Insert option is available, but by the looks of it, it cannot insert the document multiple times.  Having to do this manually for the 10 recipients in my test doc is painful enough.  The usual recipient list can be 100+!
    Cheers
    Larry

  • 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);

  • Problems merging PDF's with Preview

    Hi there,
    I'm on 10.8.5, with Preview Version 6.0.1 (765.6).  I have followed all of the steps to merge pdf's. In the title bar of the document it says there are two pages.  Then I save (there is no save as command) and it only saves one page.  Is there something I'm missing or is this a bug?
    Any help is appreciated!
    Thanks
    Shaynee

    "Try showing them as thumbnails, then Edit/Select All, and then Export as PDF.
    Tried this several times as well as every other export/save option. View as thumbnails in two separate documents and successfully see 1 document with 2 files listed in the left pane.
    And though the export displays a completed progress bar just before it disapears and the file is created where I pointed, there is still only the bottom page of the the two thumbnails in the newly created file.
    Running a Macbook Pro (see image below for details.)

  • How do I merge PDFs into one.  I have the PDF pack. iOS

      I bought the PDF pack so I could merge PDFs from my email together with an excel page. I seem to missing something to be able to get a complete PDF without having to print and scan. Any ideas?

    Hi AFO77515,
    When you use Combine Files to PDF, Adobe PDF Pack stores just the combined PDF file, not the files from which it was created.
    Click Combine Files To PDF.
    Click Select Files.
    Select one of the files that you want to combine.
    Click Open.
    Click Add Files and select additional files to combine. Click Open.
    (Optional) Click the arrows next to the files you’ve selected to change the order in which they are added to the combined PDF.
    Enter a name for the combined file, and then click Combine.
    Note: You cannot combine PDF files that are secure, password protected, 3D, or part of a PDF Portfolio.
    If you are unable to follow the above mentioned steps then please let me know the error you get.
    Regards,
    Rave

Maybe you are looking for

  • Refresh document call in RESTful workflow is taking long time.

    Hi, I am facing an issue with the Refresh Document step, in Raylight Workflow using RESTful API. We are using this Refresh Document call, To make the dataprovider mappings formed. For few WEBI documents, this Refresh document step is taking much time

  • Problem with Socket Connection and Out of Memory Exception in JavaME

    Hi, I am working on creating an application to check pop3 emails and send emails using smtp. I have implemented almost everything. It works fine if I run it with debugger [Step by step] but it fails when I run the application on emulator. It never co

  • Help purchasing org, plants & company codes

    Hi Gurus, I have the following scenario which need some advice and clarification from all of you. Plant A is assigned to company code A Plant B is assigned to company code B *Note that company code A and company code B are using different currency PO

  • Uganda Currency in PO

    We are raising PO using Uganda Shillings currency (UGX). The quantity is 100 and the price per each quantity is 100 UGX. So the total amount is 10000 UGX. In print preview of PO, under Net amount the amount shown as 10000 UGX correctly but the amount

  • Permitted extra characters in BW

    Hi, we are loading material master data and get an error message: Charachter µ (lower case Mu) is not permitted. We are on BW 7.0. We didn't have any problem with BW 3.5 as we have maintained it in permitted extra characters in RSKC. I tried to copy