× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



OK, as usual the program does just what you tell it.

Save target instead of document (bottom).

Only saves one page though, but I hope that is a small thing.


PDDocument document = new PDDocument(); File topfile = new File(args[0]);
PDDocument topSource = PDDocument.load(topfile); File bottomfile = new File(args[1]);
PDDocument bottomSource = PDDocument.load(bottomfile); PDDocument target = new PDDocument();

LayerUtility layerUtility = new LayerUtility(target);
PDFormXObject topForm = layerUtility.importPageAsForm(topSource, 0);
PDFormXObject bottomForm = layerUtility.importPageAsForm(bottomSource, 0);

float height = topForm.getBBox().getHeight() + bottomForm.getBBox().getHeight();
float width, topMargin, bottomMargin;
if (topForm.getBBox().getWidth() > bottomForm.getBBox().getWidth()) {
width = topForm.getBBox().getWidth();
topMargin = 0;
bottomMargin = (topForm.getBBox().getWidth() - bottomForm.getBBox().getWidth()) / 2;
} else {
width = bottomForm.getBBox().getWidth();
topMargin = (bottomForm.getBBox().getWidth() - topForm.getBBox().getWidth()) / 2;
bottomMargin = 0;
}

PDPage targetPage = new PDPage(new PDRectangle(width, height));
target.addPage(targetPage);


PDPageContentStream contentStream = new PDPageContentStream(target, targetPage);
if (bottomMargin != 0)
contentStream.transform(Matrix.getTranslateInstance(bottomMargin, 0));
contentStream.drawForm(bottomForm);
contentStream.transform(Matrix.getTranslateInstance(topMargin - bottomMargin, bottomForm.getBBox().getHeight()));
contentStream.drawForm(topForm);
contentStream.close();


document.save(args[2]); <==== change from document to target
}
}

Tom Deskevich




Tom Deskevich
Programmer/Analyst
P: 814-472-6066 x134
F: 814-472-5019
E: TDeskevich@xxxxxxxxxxxxxxxxxx
172 Gateway Road PO Box 568
Ebensburg, Pennsylvania
15931
www.harrislocalgov.com
This message has been sent on behalf
of a company that is part of the Harris Operating Group of
Constellation Software Inc. These companies are listed at the
following link:
http://subscribe.harriscomputer.com
Unsubscribe Option:

If you do not wish to receive any future email, please unsubscribe
by clicking on the following link:
http://subscribe.harriscomputer.com
This message is
intended exclusively for the individual or entity to which it is
addressed. This communication may contain information that is
proprietary, privileged or confidential or otherwise legally exempt
from disclosure. If you are not the named addressee, you are not
authorized to read, print, retain, copy or disseminate this message
or any part of it. If you have received this message in error,
please notify the sender immediately by e-mail and delete all copies
of the
message.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.