Create elements wrapper vertically rotated out of the PDF main central content

I want to position inside an existing pdf and out of the main central content some elements behaving like a block. Those elements consist of a barcode image, some text and another text with a link.

See the attached pdf to make a better idea of what I am refering to: ExamplePDF.pdf (288.4 KB)
Pay attention to the rotated elements on the first page left.

I want all that elements to behave like a block to have the possibity to show then vertically or horizontally in an easy way depending on a parameter.

Which is the best approach to implement this with aspose.pdf java library?

I have tried with tables, with a floating box but don´t find definitely the way to place all the elements like a whole in a concrete position and with a concrete rotation angle.

Thank you in advance!


Thanks for contacting support.

We have investigated your requirement and tried to come up with a workaround where you can deal with the whole content as a single object to add it inside the PDF document. You can prepare a separate PDF document which contains all the content you want to display as a block in your original file. Later, you can use PdfFileStamp Class to add the stamp inside PDF document. Please check the below code snippet:

Add Pdf File Stamp

com.aspose.pdf.facades.PdfFileStamp fileStamp = new com.aspose.pdf.facades.PdfFileStamp();
fileStamp.bindPdf(dataDir + "ExamplePDF.pdf");
com.aspose.pdf.facades.Stamp stamp = new com.aspose.pdf.facades.Stamp();
stamp.bindPdf(dataDir + "stampDoc.pdf", 1);
stamp.setOrigin(20, 20);
//stamp.IsBackground = false;
fileStamp.addStamp(stamp); + "output.pdf");

Following is the code which was used to generate the stamp document:

Document stampDoc = new Document();
Page page = stampDoc.getPages().add();
page.getPageInfo().setMargin(new MarginInfo(0,0,0,0));

Table table = new Table();
table.setColumnWidths("50 200 300");
//table.setDefaultCellBorder(new BorderInfo(BorderSide.All, 0.5F));


Row row = table.getRows().add();

Image img = new Image();
img.setFile(dataDir + "Barcode.jpg");

Cell cell = row.getCells().add();


Cell cell2 = row.getCells().add("Ziurtagiriaren zk. Código de Verificación");
Cell cell3 = row.getCells().add("Egiaztatzeko helbidea Dirección de comprobación");

Row row2 = table.getRows().add();

Cell cell5 = row2.getCells().add("974w-iyXT-bjZa-We7N");
Cell cell6 = row2.getCells().add("");
cell6.setVerticalAlignment(VerticalAlignment.Top); + "stampDoc.pdf");

Attached is the output PDF document obtained from the approach mentioned above:

output.pdf (345.2 KB)

We hope this would help you in achieving your requirements.

1 Like

This solution works perfectly.
Thank you very much.


It is good to know that you were able to achieve your requirements with suggested approach. Please keep using our API and feel free to create a new topic in case of any further inquiry.