Free Support Forum - aspose.com

Changing PDF

Hi,


I am evaluating Pdf and Pdf.Kit libraries and had a question regarding manipulating already existing document.

I could not find appropriate approach to modify already existing Pdf in similar way that I would use Pdf library and work with Sections, for example. I would need to merge documents (found), recreate TOC on merged documents (found basic example that does not produce nice looking TOC - for example when I create TOC with Words library and convert it to PDF, it looks much much nicer), renumber pages (not found), change page size (found) and change margins (not found for Pdf.Kit). I would probably needs other things to change existing text on some elements for example.

Any help is appreciated if you can suggest how to do this. I would normally use Words for this as it is much easier to work with DOC, but I need to merge different documents like (other DOC, DOCX, Excel, Images, other PDF files) and the easiest way to do this (I think) with your library is to convert everything to PDF and the merge and reshape content.

Thanks

branislav.cavlin:
I could not find appropriate approach to modify already existing Pdf in similar way that I would use Pdf library and work with Sections, for example. I would need to merge documents (found),

Hi Branislav,

Thanks for contacting support.

As you have already found, you can concatenate PDF files using Aspose.Pdf.Kit for Java. For more information, Concatenate PDF Documents
branislav.cavlin:
recreate TOC on merged documents (found basic example that does not produce nice looking TOC - for example when I create TOC with Words library and convert it to PDF, it looks much much nicer),
I am afraid Aspose.Pdf.Kit for Java does not support the feature to manipulate/create TOC in existing PDF files. For the sake of implementation, I have logged this requirement as PDFKITJAVA-33274 in our issue tracking system. Furthermore, we already have logged a requirement to update page numbers information in TOC as PDFKITJAVA-15375.
branislav.cavlin:
renumber pages (not found),
If you need to update the page number information in Header/Footer, you may try updating/replacing the text. For more information, Manipulate Text Inside a Rectangle
branislav.cavlin:
change margins (not found for Pdf.Kit).
This requirement is logged as PDFKITJAVA-33275.
branislav.cavlin:
I would probably needs other things to change existing text on some elements for example.
Please visit the following links for information on

branislav.cavlin:
Any help is appreciated if you can suggest how to do this. I would normally use Words for this as it is much easier to work with DOC, but I need to merge different documents like (other DOC, DOCX, Excel, Images, other PDF files) and the easiest way to do this (I think) with your library is to convert everything to PDF and the merge and reshape content.
Aspose.Pdf.Kit for Java supports the feature to add images to existing PDF file. You may add images to existing pages or you can inset new blank pages and add images to newly added pages. Or, you may consider following the approach to add images in DOC file,manipulate the DOC file and save the output in PDF format. When dealing with Excel files, you can convert the files to PDF format and finally use Aspose.Pdf.Kit for Java to concatenate the these documents. For more information, please visit

In the event of any further query, please feel free to contact.

Thank you for the quick reply.


I have found a way to do page numbering and even though not perfect, will do for now. Changing margins is important feature but I guess there are workarounds there too (like changing margins in other modules before converting to PDF). However, TOC is pretty important feature for us as our documents are quite long. Is there a way to create new PDF with only TOC and then concatenate other PDF files to it (meaning that we also need to capture pages information)? This TOC should be clickable (link) that can jump to any section that we need in concatenated PDFs.

Thanks

branislav.cavlin:
I have found a way to do page numbering and even though not perfect, will do for now.
Hi Branislav,

Thanks for sharing the details.

Can you please share the code snippet that you are using and problem that you are facing so that we can test the scenario at our end.
branislav.cavlin:
Changing margins is important feature but I guess there are workarounds there too (like changing margins in other modules before converting to PDF).
We have a component named Aspose.Pdf for Java which supports the feature to create PDF files from scratch. It supports the feature to specify the margin while creating PDF files. You may consider using this component to create PDF files and then concatenate them using Aspose.Pdf.Kit for Java. For further information on how to set margin information while creating PDF files, please visit
Set Paragraph Margins and Set Page Size and Margins.
branislav.cavlin:
However, TOC is pretty important feature for us as our documents are quite long. Is there a way to create new PDF with only TOC and then concatenate other PDF files to it (meaning that we also need to capture pages information)? This TOC should be clickable (link) that can jump to any section that we need in concatenated PDFs.
You may try creating TOC manullay. Either you can use Aspose.Pdf for Java to create a document only containing TOC and then you can append this document at the begining of original large file. While creating TOC, you can specify the target page number information. You may try following the approaches shared over


In the event of any further query, please feel free to contact.

Thanks for the reply,


I was using this to add page numbers:
PdfFileStamp fileStamp = new PdfFileStamp(“c:/temp/output.pdf”);
fileStamp.addFooter(new FormattedText(“My new Footer with”, new Color(200,200,200), FontStyle.Courier, EncodingType.Winansi, true, 10),0f);
//fileStamp.addPageNumber(new FormattedText(“Page #”, new Color(100,100,100), FontStyle.Courier, EncodingType.Winansi, true, 10));
fileStamp.close();

but it seems that I had to remove footer from Word converted document as it ended up in the body of PDF (or this is what it seemed to me). Also, it seems that when using both addPageNumber and addFooter, they overwrite each other.

Aspose PDF will not do for us, as we need to use mail merge for Words. Also, we are aiming to manipulate already existing PDF documents. So we need to change margins, page numbers, update headers and footers, remove TOC from other documents and regenerate one TOC in the beginning of the merged document. It seems like a LOT of work using Pdf.Kit nad the Pdf products to recreate TOC. Also, I have to keep in mind that some information about headers is lost when we convert to PDF (I believe).

Anyway, I think that I have enough information for my review.

Thanks

branislav.cavlin:
but it seems that I had to remove footer from Word converted document as it ended up in the body of PDF (or this is what it seemed to me).
Hi Branislav,

Sorry for the delayed response. Can you please share the source Word document so that we can test the scenario at our end.

branislav.cavlin:
Also, it seems that when using both addPageNumber and addFooter, they overwrite each other.
You may try using addLogomark to specify different X,Y location for Footer and pagenumber information being added in PDF file.

[Java]

//add watermark<o:p></o:p>

String inFile = "example2.pdf";

String outFile = "kitOut.pdf";

PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);

FormattedText logo1 = new FormattedText("Hello World!", new FontColor(0, 20, 180),

FontStyle.TimesRoman, EncodingType.Winansi, false, 12);

FormattedText logo2 = new FormattedText("Aspose.Pdf.Kit", new Color(10, 30, 100), FontStyle.HelveticaOblique,

EncodingType.Winansi, false, 20);

fileStamp.addLogomark(logo1, 20, 50);

fileStamp.addLogomark(logo2, 20, 70);

fileStamp.addWatermark("imgLogoPDFKit.gif", 100, 100);

fileStamp.close();


branislav.cavlin:
Aspose PDF will not do for us, as we need to use mail merge for Words. Also, we are aiming to manipulate already existing PDF documents. So we need to change margins, page numbers, update headers and footers, remove TOC from other documents and regenerate one TOC in the beginning of the merged document. It seems like a LOT of work using Pdf.Kit nad the Pdf products to recreate TOC. Also, I have to keep in mind that some information about headers is lost when we convert to PDF (I believe).
Aspose.Pdf.Kit for Java does not support the Mail Merge feature but you may use Aspose.Pdf.Kit in conjunction with Aspose.Words to fulfill your requirements. In case we can be of any further assistance, please feel free to contact. We are sorry for your inconvenience.