mirror of https://github.com/JakubMelka/PDF4QT.git
Bugfixing
This commit is contained in:
parent
232832e753
commit
629559bb53
|
@ -980,7 +980,7 @@ QPainter* PDFContentStreamBuilder::begin()
|
|||
m_pdfWriter = new QPdfWriter(m_buffer);
|
||||
m_pdfWriter->setPdfVersion(QPdfWriter::PdfVersion_1_6);
|
||||
m_pdfWriter->setPageSize(QPageSize(m_size, QPageSize::Point));
|
||||
m_pdfWriter->setResolution(m_pdfWriter->logicalDpiX());
|
||||
m_pdfWriter->setResolution(72);
|
||||
m_pdfWriter->setPageMargins(QMarginsF());
|
||||
|
||||
m_painter = new QPainter(m_pdfWriter);
|
||||
|
@ -988,7 +988,7 @@ QPainter* PDFContentStreamBuilder::begin()
|
|||
if (m_coordinateSystem == CoordinateSystem::PDF)
|
||||
{
|
||||
m_painter->translate(0, m_size.height());
|
||||
m_painter->scale(0.0, -1.0);
|
||||
m_painter->scale(1.0, -1.0);
|
||||
}
|
||||
|
||||
return m_painter;
|
||||
|
|
|
@ -160,6 +160,7 @@ void PDFWriteObjectVisitor::visitStream(const PDFStream* stream)
|
|||
m_device->write(*stream->getContent());
|
||||
m_device->write("\x0D\x0A");
|
||||
m_device->write("endstream");
|
||||
m_device->write("\x0D\x0A");
|
||||
}
|
||||
|
||||
void PDFWriteObjectVisitor::visitReference(const PDFObjectReference reference)
|
||||
|
|
|
@ -257,11 +257,36 @@ bool PDFStream::equals(const PDFObjectContent* other) const
|
|||
|
||||
PDFObject PDFObjectManipulator::merge(PDFObject left, PDFObject right, MergeFlags flags)
|
||||
{
|
||||
if (left.getType() != right.getType())
|
||||
const bool leftHasDictionary = left.isDictionary() || left.isStream();
|
||||
|
||||
if (left.getType() != right.getType() && (leftHasDictionary != right.isDictionary()))
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
if (left.isStream())
|
||||
{
|
||||
Q_ASSERT(right.isDictionary() || right.isStream());
|
||||
const PDFStream* leftStream = left.getStream();
|
||||
const PDFStream* rightStream = right.isStream() ? right.getStream() : nullptr;
|
||||
|
||||
PDFDictionary targetDictionary = *leftStream->getDictionary();
|
||||
const PDFDictionary& sourceDictionary = rightStream ? *rightStream->getDictionary() : *right.getDictionary();
|
||||
|
||||
for (size_t i = 0, count = sourceDictionary.getCount(); i < count; ++i)
|
||||
{
|
||||
const QByteArray& key = sourceDictionary.getKey(i);
|
||||
PDFObject value = merge(targetDictionary.get(key), sourceDictionary.getValue(i), flags);
|
||||
targetDictionary.setEntry(key, qMove(value));
|
||||
}
|
||||
|
||||
if (flags.testFlag(RemoveNullObjects))
|
||||
{
|
||||
targetDictionary.removeNullObjects();
|
||||
}
|
||||
|
||||
return PDFObject::createStream(std::make_shared<PDFStream>(qMove(targetDictionary), QByteArray(rightStream ? *rightStream->getContent() : *leftStream->getContent())));
|
||||
}
|
||||
if (left.isDictionary())
|
||||
{
|
||||
Q_ASSERT(right.isDictionary());
|
||||
|
|
Loading…
Reference in New Issue