From 5b37d5d11d269c295dcff33e4882ccfda7b35fde Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Wed, 15 Nov 2023 14:49:36 +0300 Subject: [PATCH] Fix DashPattern for pdf border annots --- .../graphics/commands/AnnotField.cpp | 9 ++++++--- PdfFile/PdfWriter_empty.cpp | 2 +- PdfFile/SrcWriter/Annotation.cpp | 2 +- PdfFile/test/test.cpp | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/DesktopEditor/graphics/commands/AnnotField.cpp b/DesktopEditor/graphics/commands/AnnotField.cpp index 9c3f6782e4..6035767f1f 100644 --- a/DesktopEditor/graphics/commands/AnnotField.cpp +++ b/DesktopEditor/graphics/commands/AnnotField.cpp @@ -457,9 +457,12 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta { m_oBorder.nType = pReader->ReadByte(); m_oBorder.dWidth = pReader->ReadDouble(); - int n = pReader->ReadInt(); - for (int i = 0; i < n; ++i) - m_oBorder.arrDash.push_back(pReader->ReadDouble()); + if (m_oBorder.nType == 2) + { + int n = pReader->ReadInt(); + for (int i = 0; i < n; ++i) + m_oBorder.arrDash.push_back(pReader->ReadDouble()); + } } if (nFlags & (1 << 5)) m_wsLM = pReader->ReadString(); diff --git a/PdfFile/PdfWriter_empty.cpp b/PdfFile/PdfWriter_empty.cpp index 8261f706a2..c64c3d2e80 100644 --- a/PdfFile/PdfWriter_empty.cpp +++ b/PdfFile/PdfWriter_empty.cpp @@ -32,7 +32,7 @@ #include "PdfWriter.h" #ifdef BUILDING_WASM_MODULE -CPdfWriter::CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA, IRenderer* pRenderer) : m_oCommandManager(this) {} +CPdfWriter::CPdfWriter(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA, IRenderer* pRenderer, BYTE* pMetaData, DWORD nMetaLength, const std::map& pMetaResources) : m_oCommandManager(this) {} CPdfWriter::~CPdfWriter() {} int CPdfWriter::SaveToFile(const std::wstring& wsPath) { return 0; } void CPdfWriter::SetPassword(const std::wstring& wsPassword) {} diff --git a/PdfFile/SrcWriter/Annotation.cpp b/PdfFile/SrcWriter/Annotation.cpp index 0e3358f1e8..8ae447d252 100644 --- a/PdfFile/SrcWriter/Annotation.cpp +++ b/PdfFile/SrcWriter/Annotation.cpp @@ -199,7 +199,7 @@ namespace PdfWriter EBorderSubtype eSubtype = EBorderSubtype(nType); if (border_subtype_Dashed == eSubtype) - AddToVectorD(this, "D", arrDash); + AddToVectorD(pBorderStyleDict, "D", arrDash); switch (eSubtype) { diff --git a/PdfFile/test/test.cpp b/PdfFile/test/test.cpp index a42a613ef1..094550ac84 100644 --- a/PdfFile/test/test.cpp +++ b/PdfFile/test/test.cpp @@ -146,19 +146,24 @@ int main() return 0; } - if (true) + if (false) { - BYTE* pFileData = NULL; - DWORD nFileSize; - std::wstring sFile = NSFile::GetProcessDirectory() + L"/res0.png"; - if (NSFile::CFileBinary::ReadAllBytes(sFile, &pFileData, nFileSize)) - pdfFile.CreatePdf(false, pFileData, nFileSize, {}); + if (true) + { + BYTE* pFileData = NULL; + DWORD nFileSize; + std::wstring sFile = NSFile::GetProcessDirectory() + L"/res0.png"; + if (NSFile::CFileBinary::ReadAllBytes(sFile, &pFileData, nFileSize)) + pdfFile.CreatePdf(false, pFileData, nFileSize, {}); + else + pdfFile.CreatePdf(); + RELEASEARRAYOBJECTS(pFileData); + } else pdfFile.CreatePdf(); pdfFile.OnlineWordToPdfFromBinary(NSFile::GetProcessDirectory() + L"/pdf.bin", wsDstFile); - RELEASEARRAYOBJECTS(pFileData); RELEASEINTERFACE(pApplicationFonts); RELEASEOBJECT(pCertificate); return 0;