Fixed issue 1112

preferencesAboutTextFull
shibakaneki 12 years ago
parent 69fec641b2
commit 3d28de7539
  1. 35
      src/adaptors/UBExportFullPDF.cpp

@ -169,6 +169,7 @@ void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS
MergeDescription mergeInfo; MergeDescription mergeInfo;
int existingPageCount = pDocumentProxy->pageCount(); int existingPageCount = pDocumentProxy->pageCount();
for(int pageIndex = 0 ; pageIndex < existingPageCount; pageIndex++) for(int pageIndex = 0 ; pageIndex < existingPageCount; pageIndex++)
{ {
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex); UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocumentProxy, pageIndex);
@ -180,18 +181,42 @@ void UBExportFullPDF::persistsDocument(UBDocumentProxy* pDocumentProxy, const QS
{ {
QString pdfName = UBPersistenceManager::objectDirectory + "/" + pdfItem->fileUuid().toString() + ".pdf"; QString pdfName = UBPersistenceManager::objectDirectory + "/" + pdfItem->fileUuid().toString() + ".pdf";
QString backgroundPath = pDocumentProxy->persistencePath() + "/" + pdfName; QString backgroundPath = pDocumentProxy->persistencePath() + "/" + pdfName;
QRectF annotationsRect = scene->itemsBoundingRect();
// Original datas
double xAnnotation = qRound(annotationsRect.x());
double yAnnotation = qRound(annotationsRect.y());
double xPdf = qRound(pdfItem->sceneBoundingRect().x());
double yPdf = qRound(pdfItem->sceneBoundingRect().y());
double hPdf = qRound(pdfItem->sceneBoundingRect().height());
// Exportation-transformed datas
double hScaleFactor = pageSize.width()/scene->itemsBoundingRect().width();
double vScaleFactor = pageSize.height()/scene->itemsBoundingRect().height();
double scaleFactor = qMin(hScaleFactor, vScaleFactor);
double xAnnotationsOffset = 0;
double yAnnotationsOffset = 0;
double hPdfTransformed = qRound(hPdf * scaleFactor);
qDebug() << "scene->itemsBoundingRect()" << scene->itemsBoundingRect(); // Here, we force the PDF page to be on the topleft corner of the page
qDebug() << "pdfItem->boundingRect()" << pdfItem->boundingRect(); double xPdfOffset = 0;
qDebug() << "pdfItem->sceneBoundingRect()" << pdfItem->sceneBoundingRect(); double yPdfOffset = (hPdf - hPdfTransformed) * mScaleFactor;
// Now we align the items
xPdfOffset += (xPdf - xAnnotation) * scaleFactor * mScaleFactor;
yPdfOffset -= (yPdf - yAnnotation) * scaleFactor * mScaleFactor;
TransformationDescription pdfTransform(xPdfOffset, yPdfOffset, scaleFactor, 0);
TransformationDescription annotationTransform(xAnnotationsOffset, yAnnotationsOffset, 1, 0);
MergePageDescription pageDescription(pageSize.width() * mScaleFactor, MergePageDescription pageDescription(pageSize.width() * mScaleFactor,
pageSize.height() * mScaleFactor, pageSize.height() * mScaleFactor,
pdfItem->pageNumber(), pdfItem->pageNumber(),
QFile::encodeName(backgroundPath).constData(), QFile::encodeName(backgroundPath).constData(),
TransformationDescription(), pdfTransform,
pageIndex + 1, pageIndex + 1,
TransformationDescription(), annotationTransform,
false, false); false, false);
mergeInfo.push_back(pageDescription); mergeInfo.push_back(pageDescription);

Loading…
Cancel
Save