We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Images are not centered with custom margins

I am using aspose-words-17.3.0-jdk16.jar to create a pdf file. When I set the margins to .5 the images are off center. I have tried with aspose word and with aspose pdf and I get the same results. Please see below. test1.pdf shows result with 0.5 margins. result-wanted.pdf was created with default margins. What can I do to fix this issue?

Margin created with aspose.pdf
public void convert() {
Document document = new Document(new FileInputStream("aspose.html"));
DocumentBuilder builder = new DocumentBuilder(document);

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
opts.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

document.updatePageLayout();
document.save("test.pdf", opts);


com.aspose.pdf.Document pdfdoc = new com.aspose.pdf.Document("test.pdf");
pdfdoc.getPageInfo().setMargin(new MarginInfo(
ConvertUtil.inchToPoint(0.5),
ConvertUtil.inchToPoint(0.5),
ConvertUtil.inchToPoint(0.5),
ConvertUtil.inchToPoint(0.5)));
}
pdfdoc.setDisplayDocTitle(true);
pdfdoc.save("test.pdf");
}

Margin created with aspose.words
public void convert() {
Document document = new Document(new FileInputStream("aspose.html"));
DocumentBuilder builder = new DocumentBuilder(document);

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
opts.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

for (Section section : document.getSections()) {
section.getPageSetup().setTopMargin(ConvertUtil.inchToPoint(0.5));
section.getPageSetup().setRightMargin(ConvertUtil.inchToPoint(0.5));
section.getPageSetup().setBottomMargin(ConvertUtil.inchToPoint(0.5));
section.getPageSetup().setLeftMargin(ConvertUtil.inchToPoint(0.5));
}

document.updatePageLayout();
document.save("test.pdf", opts);
}

Hi,

Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSJAVA-1531. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Hi,


Do you know when this fix for this issue might be released?

Thank you

Hi,


Thanks for your inquiry. Unfortunately, your issue is not resolved yet and there are no estimates available at the moment. Currently, it is pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.

Best regards,

Thanks. Please keep us informed. Our customers are inquiring about margin less than 1 inch

Hi,


After an initial analysis, we have found that the problematic content is a Table with nested Image. Apparently, image is positioned within Cell and not Section. Thus changing margins will affect Table position and not the Image itself. And when margins are changed, Table position changes too, but not width. So, the Table with all its content is moved to the left and is not centered. Our product team needs to look into the details of this issue (WORDSJAVA-1531) further. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.

Best regards,