mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
fix don't makeWritable different files
This commit is contained in:
@ -680,18 +680,25 @@ return 0;
|
|||||||
sInfo = XMLConverter::DictToXml(L"Info", &info);
|
sInfo = XMLConverter::DictToXml(L"Info", &info);
|
||||||
info.free();
|
info.free();
|
||||||
|
|
||||||
|
std::wstring wsPath = m_pInternal->m_pPdfWriter->GetEditPdfPath();
|
||||||
bool bRes = m_pInternal->m_pPdfWriter->EditClose(sTrailer, sInfo);
|
bool bRes = m_pInternal->m_pPdfWriter->EditClose(sTrailer, sInfo);
|
||||||
GString* owner_pswd = NSStrings::CreateString(sPassword);
|
|
||||||
GString* user_pswd = NSStrings::CreateString(sPassword);
|
|
||||||
bRes &= m_pInternal->m_pPDFDocument->makeWritable(false, owner_pswd, user_pswd);
|
|
||||||
delete owner_pswd;
|
|
||||||
delete user_pswd;
|
|
||||||
|
|
||||||
NSFile::CFileBinary oFile;
|
std::string sPathUtf8New = U_TO_UTF8(wsPath);
|
||||||
if (oFile.OpenFile(m_pInternal->m_wsSrcPath))
|
std::string sPathUtf8Old = U_TO_UTF8(m_pInternal->m_wsSrcPath);
|
||||||
|
if (sPathUtf8Old == sPathUtf8New || NSSystemPath::NormalizePath(sPathUtf8Old) == NSSystemPath::NormalizePath(sPathUtf8New))
|
||||||
{
|
{
|
||||||
m_pInternal->m_nFileLength = oFile.GetFileSize();
|
GString* owner_pswd = NSStrings::CreateString(sPassword);
|
||||||
oFile.CloseFile();
|
GString* user_pswd = NSStrings::CreateString(sPassword);
|
||||||
|
bRes &= m_pInternal->m_pPDFDocument->makeWritable(false, owner_pswd, user_pswd);
|
||||||
|
delete owner_pswd;
|
||||||
|
delete user_pswd;
|
||||||
|
|
||||||
|
NSFile::CFileBinary oFile;
|
||||||
|
if (oFile.OpenFile(m_pInternal->m_wsSrcPath))
|
||||||
|
{
|
||||||
|
m_pInternal->m_nFileLength = oFile.GetFileSize();
|
||||||
|
oFile.CloseFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRes;
|
return bRes;
|
||||||
|
|||||||
@ -2222,6 +2222,14 @@ void CPdfRenderer::Sign(const double& dX, const double& dY, const double& dW, co
|
|||||||
m_pDocument->Sign(TRect(MM_2_PT(dX), m_pPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), m_pPage->GetHeight() - MM_2_PT(dY + dH)),
|
m_pDocument->Sign(TRect(MM_2_PT(dX), m_pPage->GetHeight() - MM_2_PT(dY), MM_2_PT(dX + dW), m_pPage->GetHeight() - MM_2_PT(dY + dH)),
|
||||||
pImage, pCertificate);
|
pImage, pCertificate);
|
||||||
}
|
}
|
||||||
|
std::wstring CPdfRenderer::GetEditPdfPath()
|
||||||
|
{
|
||||||
|
if (!m_bEdit)
|
||||||
|
{
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
return m_pDocument->GetEditPdfPath();
|
||||||
|
}
|
||||||
|
|
||||||
NSFonts::IApplicationFonts* CPdfRenderer::GetApplicationFonts()
|
NSFonts::IApplicationFonts* CPdfRenderer::GetApplicationFonts()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -241,6 +241,7 @@ public:
|
|||||||
bool EditClose(const std::wstring& sTrailer, const std::wstring& sInfo);
|
bool EditClose(const std::wstring& sTrailer, const std::wstring& sInfo);
|
||||||
void PageRotate(int nRotate);
|
void PageRotate(int nRotate);
|
||||||
void Sign(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsPicturePath, ICertificate* pCertificate);
|
void Sign(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsPicturePath, ICertificate* pCertificate);
|
||||||
|
std::wstring GetEditPdfPath();
|
||||||
|
|
||||||
NSFonts::IApplicationFonts* GetApplicationFonts();
|
NSFonts::IApplicationFonts* GetApplicationFonts();
|
||||||
|
|
||||||
|
|||||||
@ -160,6 +160,7 @@ namespace PdfWriter
|
|||||||
bool DeletePage(int nPageIndex);
|
bool DeletePage(int nPageIndex);
|
||||||
bool AddToFile(const std::wstring& sTrailer, const std::wstring& sInfo);
|
bool AddToFile(const std::wstring& sTrailer, const std::wstring& sInfo);
|
||||||
void Sign(const TRect& oRect, CImageDict* pImage, ICertificate* pCert);
|
void Sign(const TRect& oRect, CImageDict* pImage, ICertificate* pCert);
|
||||||
|
std::wstring GetEditPdfPath() { return m_wsFilePath; }
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char* GetTTFontTag();
|
char* GetTTFontTag();
|
||||||
|
|||||||
@ -109,7 +109,10 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bResult && pReader->EditPdf(&pdfWriter, sSrcFile, sPassword))
|
bool bNewDstFile = false;
|
||||||
|
if (bNewDstFile)
|
||||||
|
NSFile::CFileBinary::Copy(sSrcFile, sDstFile);
|
||||||
|
if (bResult && pReader->EditPdf(&pdfWriter, bNewDstFile ? sDstFile : sSrcFile, sPassword))
|
||||||
{
|
{
|
||||||
if (true && pCertificate)
|
if (true && pCertificate)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user