On Wed, 20 Mar 2019 at 11:16, Michal Sudolsky <sudols...@gmail.com> wrote: > > Actually it would be enough to call it only in functions with PdfOutputDevice > parameter as all other functions call these two. > >
Ah ok, you already wrote it in previous comment, I missed that. Yes, this leads also to small code clean. I am going to test: If everything goes well and there are no complains I am going commit since it seems very straightforward fix. Cheers, Francesco
diff --git a/src/doc/PdfMemDocument.cpp b/src/doc/PdfMemDocument.cpp index a7255ee..bdc047d 100644 --- a/src/doc/PdfMemDocument.cpp +++ b/src/doc/PdfMemDocument.cpp @@ -438,9 +438,6 @@ void PdfMemDocument::Write( const char* pszFilename ) * it writeable. */ - // makes sure pending subset-fonts are embedded - m_fontCache.EmbedSubsetFonts(); - PdfOutputDevice device( pszFilename ); this->Write( &device ); @@ -449,16 +446,6 @@ void PdfMemDocument::Write( const char* pszFilename ) #ifdef _WIN32 void PdfMemDocument::Write( const wchar_t* pszFilename ) { - /** TODO: - * We will get problems here on linux, - * if we write to the same filename we read the - * document from. - * Because the PdfParserObjects will read there streams - * data from the file while we are writing it. - * The problem is that the stream data won't exist at this time - * as we truncated the file already to zero length by opening - * it writeable. - */ PdfOutputDevice device( pszFilename ); this->Write( &device ); @@ -478,6 +465,9 @@ void PdfMemDocument::Write( PdfOutputDevice* pDevice ) * it writeable. */ + // makes sure pending subset-fonts are embedded + m_fontCache.EmbedSubsetFonts(); + PdfWriter writer( &(this->GetObjects()), this->GetTrailer() ); writer.SetPdfVersion( this->GetPdfVersion() ); writer.SetWriteMode( m_eWriteMode ); @@ -500,9 +490,6 @@ void PdfMemDocument::WriteUpdate( const char* pszFilename ) PODOFO_RAISE_ERROR( ePdfError_InvalidHandle ); } - // makes sure pending subset-fonts are embedded - m_fontCache.EmbedSubsetFonts(); - bool bTruncate = !m_pszUpdatingFilename || strcmp( m_pszUpdatingFilename, pszFilename) != 0; PdfOutputDevice device( pszFilename, bTruncate ); @@ -543,6 +530,9 @@ void PdfMemDocument::WriteUpdate( PdfOutputDevice* pDevice, bool bTruncate ) PODOFO_RAISE_ERROR( ePdfError_InvalidHandle ); } + // makes sure pending subset-fonts are embedded + m_fontCache.EmbedSubsetFonts(); + /** TODO: * We will get problems here on linux, * if we write to the same filename we read the
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users