diff --git a/PdfFile/PdfWriter.cpp b/PdfFile/PdfWriter.cpp index 2778980943..ba426cfff0 100644 --- a/PdfFile/PdfWriter.cpp +++ b/PdfFile/PdfWriter.cpp @@ -2104,19 +2104,6 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF double dFontSize = pPr->GetFontSizeAP(); PdfWriter::CFontTrueType* pFontTT = NULL; - if (nWidgetType == 27) - { - put_FontName(wsFontName); - put_FontStyle(nStyle); - put_FontSize(dFontSize); - - if (m_bNeedUpdateTextFont) - UpdateFont(); - if (m_pFont) - pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont); - pWidgetAnnot->SetDA(pFontTT, pPr->GetFontSize(), dFontSize, pPr->GetTC()); - } - BYTE nAlign = pPr->GetQ(); if (nWidgetType != 27 && nWidgetType != 28 && nWidgetType != 29) pWidgetAnnot->SetQ(nAlign); @@ -2292,6 +2279,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF if (nIFFlags & (1 << 7)) pButtonWidget->SetIX(pPr->GetIX()); + put_FontName(wsFontName); + put_FontStyle(nStyle); + put_FontSize(dFontSize); + + if (m_bNeedUpdateTextFont) + UpdateFont(); + if (m_pFont) + pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont); + pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); + // ВНЕШНИЙ ВИД pButtonWidget->SetFont(m_pFont, dFontSize, isBold, isItalic); if (nFlags & (1 << 10)) @@ -2338,9 +2335,12 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF return S_OK; } + put_FontName(wsFontName); + put_FontStyle(nStyle); + put_FontSize(dFontSize); + if (m_bNeedUpdateTextFont) UpdateFont(); - if (m_pFont) pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont); pWidgetAnnot->SetDA(pFontTT, pPr->GetFontSize(), dFontSize, pPr->GetTC()); @@ -2396,6 +2396,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF } else if ((bValue && pTextWidget->Get("T")) || bAPValue) { + put_FontName(wsFontName); + put_FontStyle(nStyle); + put_FontSize(dFontSize); + + if (m_bNeedUpdateTextFont) + UpdateFont(); + if (m_pFont) + pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont); + pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); + pTextWidget->SetFont(m_pFont, dFontSize, isBold, isItalic); DrawTextWidget(pAppFonts, pTextWidget, wsValue); } @@ -2441,6 +2451,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF } else if (!arrValue.empty()) { + put_FontName(wsFontName); + put_FontStyle(nStyle); + put_FontSize(dFontSize); + + if (m_bNeedUpdateTextFont) + UpdateFont(); + if (m_pFont) + pFontTT = m_pDocument->CreateTrueTypeFont(m_pFont); + pWidgetAnnot->SetDA(pFontTT, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); + pChoiceWidget->SetFont(m_pFont, dFontSize, isBold, isItalic); DrawChoiceWidget(pAppFonts, pChoiceWidget, arrValue); } @@ -3614,6 +3634,12 @@ void CPdfWriter::DrawAP(PdfWriter::CAnnotation* pAnnot, BYTE* pRender, LONG nLen m_pDocument->SetCurPage(pFakePage); m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0); + PdfWriter::CAnnotAppearanceObject* pAP = pAnnot->StartAP(); + pAP->EndText(); + + pFakePage->SetStream(pAP->GetStream()); + pFakePage->Add("Resources", (PdfWriter::CObjectBase*)m_pDocument->GetFieldsResources()); + IMetafileToRenderter* pCorrector = new IMetafileToRenderter(m_pRenderer); NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pRender, nLenRender, pCorrector); RELEASEOBJECT(pCorrector); diff --git a/PdfFile/SrcWriter/Annotation.cpp b/PdfFile/SrcWriter/Annotation.cpp index a049b26cf8..cbfd425020 100644 --- a/PdfFile/SrcWriter/Annotation.cpp +++ b/PdfFile/SrcWriter/Annotation.cpp @@ -303,16 +303,19 @@ namespace PdfWriter sRes.append(" ] 0 d\012"); return sRes; } + CAnnotAppearanceObject* CAnnotation::StartAP() + { + m_pAppearance = new CAnnotAppearance(m_pXref, this); + if (!m_pAppearance) + return NULL; + Add("AP", m_pAppearance); + return m_pAppearance->GetNormal(); + } void CAnnotation::APFromFakePage(CPage* pFakePage) { - // xref NULL - тогда у CAnnotAppearanceObject не будет создан stream - m_pAppearance = new CAnnotAppearance(NULL, this); if (!m_pAppearance) return; - Add("AP", m_pAppearance); - CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal((CResourcesDict*)pFakePage->Get("Resources")); - m_pXref->Add(pNormal); - m_pAppearance->Add("N", pNormal); + CAnnotAppearanceObject* pNormal = m_pAppearance->GetNormal(); CArrayObject* pArray = new CArrayObject(); if (!pArray) @@ -335,15 +338,6 @@ namespace PdfWriter pArray->Add(1); pArray->Add(-GetRect().fLeft); pArray->Add(-GetRect().fBottom); - - CDictObject* pFPStream = pFakePage->GetContent(); - pNormal->SetStream(m_pXref, pFPStream->GetStream(), false); -#ifndef FILTER_FLATE_DECODE_DISABLED - if (m_pDocument->GetCompressionMode() & COMP_TEXT) - pNormal->SetFilter(STREAM_FILTER_FLATE_DECODE); -#endif - pFPStream->SetStream(NULL); - // RELEASEOBJECT(pFPStream); Нельзя удалять - это объект стрима, он уже в xref } //---------------------------------------------------------------------------------------- // CMarkupAnnotation diff --git a/PdfFile/SrcWriter/Annotation.h b/PdfFile/SrcWriter/Annotation.h index 35b810a69e..5a992a5545 100644 --- a/PdfFile/SrcWriter/Annotation.h +++ b/PdfFile/SrcWriter/Annotation.h @@ -184,6 +184,7 @@ namespace PdfWriter void SetC(const std::vector& arrC); void APFromFakePage(CPage* pFakePage); + CAnnotAppearanceObject* StartAP(); TRect& GetRect() { return m_oRect; } void SetXref(CXref* pXref) { m_pXref = pXref; } void SetDocument(CDocument* pDocument);