Placing a FloatingBox box on the pdf

I’m looking to put a FloatingBox on the page in the upper left and top of the page specifically…

would not the following code do that?

public Document createPdf(Connection connection) throws SQLException{
Document doc = new Document();
doc.setFitWindow(true);
doc.setCenterWindow(true);
double zoom = 1;
com.aspose.pdf.GoToAction action = new com.aspose.pdf.GoToAction(1);
action.setDestination(new com.aspose.pdf.XYZExplicitDestination(doc, 0, 0, 0, zoom));
doc.setOpenAction(action);

Page page = doc.getPages().add();
//page.setPageSize(PageSize.LETTER_WIDTH, 200);
PageInfo info = page.getPageInfo();
MarginInfo pageMarginInfo = new MarginInfo();
pageMarginInfo.setLeft(5);
pageMarginInfo.setRight(5);
pageMarginInfo.setTop(5);
pageMarginInfo.setBottom(5);

info.setMargin(pageMarginInfo);

page.setPageInfo(info);
//com.aspose.pdf.HeaderFooter header = new com.aspose.pdf.HeaderFooter();
//header.setMargin(getHeaderMargin());

//header.getParagraphs().add(createBoundingBox());
//page.setHeader(header);
page.getParagraphs().add(createBoundingBox());
//page.getParagraphs().add(createBusinessUnitBox());
//page.getParagraphs().add(createPaymentBox());
//page.getParagraphs().add(createToOrderOfBox());
//page.getParagraphs().add(createDetailBox(connection));
return doc;

}

private FloatingBox createBoundingBox(){
FloatingBox box = new FloatingBox(500,150);
box.setLeft(0);
box.setTop(0);

box.setBorder(new BorderInfo(BorderSide.All));
return box;
}

Hi Mark,


Thanks for your inquiry. Yes you are following right approach. However, please make a slight change in your code as following.

Page page = doc.getPages().add();<o:p></o:p>

doc.setFitWindow(true);

doc.setCenterWindow(true);

double zoom = 1;

com.aspose.pdf.GoToAction action = new com.aspose.pdf.GoToAction(new com.aspose.pdf.XYZExplicitDestination(doc.getPages().get_Item(1),0, 0, zoom));

doc.setOpenAction(action);

//page.setPageSize(PageSize.LETTER_WIDTH, 200);

PageInfo info = page.getPageInfo();

.....


Please feel free to contact us for any further assistance.

Best Regards,

Ok, everything seems to be working ok, except when I add one pdf to another. if I create the check image by itself it lines up perfectly, however if I add it tot he invoice it misaligns. enclosed are examples of what I am seeing, what can cause this?


Hi Mark,


Thanks for your feedback. We will appreciate it if you please share your sample code and intput/output documents here, so we will look into it and provide you solution accordingly.

We are sorry for the inconvenience.

Best Regards,