I need to 2-up (A4 to A3 every two A4 pages) a pdf doc. I found this and it works (I use the pdfbox answer) but only for the first new page on the newly created doc. The problem is that when use a loop to add more new pages then it throws an error "Optional group (layer) already exists: left" in the layerUtility.appendFormAsLayer(outPdfPage, formPdf1, afLeft, "left");
UPDATE:
I replaced "left" with "left" + i to have left1,left2 etc but the result is a not well responsive pdf file after 100-200 pages. It is very difficult to navigate pages.
Related
I've written code to do the following:
Take a PDF of a certain page size (e.g., 8.5" x 11")
Create a new PDF with a larger page size (e.g., 17" x 11")
Impose the original PDF onto the new one (e.g., 2-up such that the resulting new PDF has the original PDF side-by-side)
To do this, I use the PdfWriter.GetImportedPage method to get the current page from the original PDF, then use the PdfContentByte.AddTemplate(page, x, y) method to place the original page onto the current page of the new PDF.
My new challenge is that I need to crop the original PDF before adding it to the new PDF. For example, imagine I want to crop 2" off of the original PDF before imposing it. The input PDF would still be 8.5" x 11" and the new PDF would still be 17" x 11", but the two "copies" of the original PDF in the new one would have had 2" removed from its top, right, bottom and left sides.
Hopefully these images can make this clearer. Here's what I have now, doing a 2-up imposition. (This is working swimmingly.)
But here's what I need to do:
I know that I can alter the display of the PDF in a viewer by using the MediaBox or CropBox settings, but those settings aren't respected by AddTemplate. I know that with AddTemplate I can use a transform matrix to position the page or to scale or rotate it, but I don't want to shrink the original PDF, I want to crop it.
Thanks
I found that I can use the BoundingBox of the imported page to crop it prior to adding it to the new PDF (via AddTemplate).
So my code looks something like this:
PdfImportedPage page = writer.GetImportedPage(pageNumber);
// Crop!
page.BoundingBox = new Rectangle(llx, lly, urx, ury);
// Add to new PDF
writer.DirectContent.AddTemplate(page, x, y);
That does the trick!
I have an A4 size document with 6 Photos, while I am trying to cut one photo from the original and create a new document the new file name is created as "Untitled-1".
Since I am using an Action to cut from original and paste it into the new document, every new file is opened with same name as "Untitled-1" and while saving it replaces the existing.
Is there any way to make every new document with sequence number or any different names for each file while create new document in Photoshop?
Or else please suggest if any script is available for the same.
Please find below screenshot for your clear understanding.
thanks in advance.
Full page image
Every new document name
Are you familiar with slices? It's beneath the crop tool - You can slice up your document the way you want it, then Export > Save for web, then each slice will save as an individual file.
I am using itext to create a pdf. As a final result i am downloading a zip file.After extracting it i am having directory structure as follows:-
main dir
|
|_ evidence_dir/abc.pdf
|
|_xyz.pdf
i am using this code to create the link in pdf
chunk = new Chunk( "Link" ).setAction(PdfAction.gotoRemotePage("evidence_dir/abc.pdf", "6", false, true ));
this code is for file xyz.pdf. I am getting the link create but when clicking on the link current pdf getting closed and then nothing happened.
Can anybody please help me.
Thanks,
Manish
I've create a small standalone example that shows how to create a RemoteGoto in a PDF using iText. You can download the ZIP with the resulting PDFs here. It works for me, can you check if it works for you?
Several things aren't clear from your question.
Is "6" present as a named destination in your abc.pdf? (I created an abc.pdf file with a destination named "dest")
Is "6" a named destination defined by a PDF string? (cf. your false parameter)
Are you aware of the limitations of opening a new PDF viewer window? (cf. your true parameter)
Update:
In your comment, you say that "6" should be a number, but in your code, you use a string. It's normal that that doesn't work, strings aren't numbers. Please take a look at the RemoteGoToPage example to see how it's done.
Update 2
In one of the comments, I'm asked if you can link to a specific word in an existing PDF from an HTML-link. That's a completely different question. You can do this using Open Parameters. On page 7 of this spec, you can find more info about the search parameter:
Opens the Search UI and performs a search for the specified word list
in the document. Matching words are highlighted in the document.
Hello,
How can I use the Word VBA code to insert another document including its paper size? I mean if I insert 5 documents with different paper sizes then it needs to be in the main document with these different paper sizes.
For example:
Document(1) - A4
Document(2) - Letter
Document(3) - A3
Then in the main document there will be pages with different paper settings like A4, Letter and A3.
How do I code that?
Thanks in advance.
I figured the answer myself and here is the code for it,
Selection.InsertBreak Type:=wdSectionBreakNextPage
You have to use th above code to break the page and then,
Selection.PageSetup.PageHeight = <size>
Selection.PageSetup.PageWidth = <size>
The cursor in the document needs to on the specific page for the above code to work.
To make the page setup apply to the specific part of the document you have to use the Selection as shown above.
I have a scanned e-book with 2 pages per sheet. I was able to crop the e-book for the white borders on four sides. Since the two book sheets are on one single page, I am getting bad view on e-reader like kindle. I am trying to split the e-book to 1 page per sheet. Is there a way to to do this in acrobat professional?
I thought of cropping the pdf as two batches (left and right) and merging them together but the page collation will go off completely. the pages won't come adjacent to each other. I will get 1,3,5,7 upto 101 as one pdf and 2,4,6....100 as another PDF
pLEASE provide me a solution in acrobat professional
You can merge the PDFs back together in script. When running from Acrobat, JS has access to quite a few functions that aren't available in Reader.
doc.insertPages(nPageInDoc, pathToOtherPDF, nStartPage, nEndPage)
So you could create a script in a button in one of your 1,3,5,7... files to import all the pages from the other. Something like:
var oddPagesDoc = app.openDoc("c:\\oddPages.pdf");
var evenPagesDoc = app.openDoc("c:\\evenPages.pdf");
var evenPageCount = evenPagesDoc.numPages;
for (var i = 0; i < evenPageCount; ++i) {
oddPagesDoc.insertPages(i, "c:\\evenPages.pdf", i, i);
}
So insert a button into the "odd pages" file with the above script as the button's "mouse down" javascript action. Click. Delete the button.
It's entirely possible there's an "off by one" error in my script, so I don't recommend saving over the original until you're sure everything was assembled properly.
If you Adobe Acrobat Pro, there is a way to do this without scripting. It's quite tedious, but I'll explain:
I advise you to make a copy of the file first
Crop the left part of the page: Select Crop pages, if it's an A4 sheet then for Margin Controls use Right = 14.85, for Page Range select All. Save as left.pdf
Extract all the left pages as separate files: in the file left.pdf, select Extract pages, edit the From and To boxes to select all the pages, check the box Extract Pages As Separate Files. Now select a folder to save all the files in, it will name them left 1.pdf, left 2.pdf, left 3.pdf, etc
Repeat step 1 for the right side of the page: open original file, crop at Left = 14.85 for all pages and save as right.pdf
Repeat step 2 for right.pdf to extract all the pages into the same folder as right 1.pdf, right 2.pdf, right 3.pdf, etc
In Acrobat choose Create -> Combine Files into a Single PDF, and navigate to the folder where you've saved all the separate pages. You can rearrange the files into the correct order, i.e. left 1.pdf, right 1.pdf, left 2.pdf, right 2.pdf, etc. Then click Combine Files and save your new ebook.
Tip: if you have many pages in the book, it can take quite long to rearrange the files when combining them. Acrobat arranges them alphabetically, so it would be better if the files were named, for instance for a PDF with 354 pages, 001left.pdf, 002right.pdf, ..., 354left.pdf, 354right.pdf. I can't find any setting in Acrobat to change the default name. But you could use this free tool to batch rename files: http://www.snapfiles.com/get/denrenamer.html
The following modified script (idea based on the previous answer) worked for me:
for (var i = 0; i < pageCount; i++) {
this.insertPages({nPage:2*i,cPath:"/C/***/fileName.pdf",nStart: i,nEnd: i});
}
Multiplication by 2 is needed since when you're inserting pages, your page numbering shifts.