Files
core/PdfWriter/test/test.cpp
2022-02-03 18:25:14 +03:00

49 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "../PdfRenderer.h"
#include "../../PdfReader/PdfReader.h"
#include "../../DesktopEditor/common/File.h"
int main()
{
NSFonts::IApplicationFonts* pApplicationFonts = NSFonts::NSApplication::Create();
CPdfRenderer pdfWriter(pApplicationFonts, true);
pdfWriter.SetTempFolder(NSFile::GetProcessDirectory() + L"/wtemp");
PdfReader::CPdfReader* pReader = new PdfReader::CPdfReader(pApplicationFonts);
pReader->SetTempDirectory(NSFile::GetProcessDirectory() + L"/rtemp");
std::wstring sPassword = L"";
bool bResult = pReader->LoadFromFile(NSFile::GetProcessDirectory() + L"/test.pdf", L"", sPassword, sPassword);
if (bResult)
{
/*
for (int i = 0, nPagesCount = pReader->GetPagesCount(); i < nPagesCount; ++i)
{
pdfWriter.NewPage();
pdfWriter.BeginCommand(c_nPageType);
double dPageDpiX, dPageDpiY;
double dWidth, dHeight;
pReader->GetPageInfo(i, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
dWidth *= 25.4 / dPageDpiX;
dHeight *= 25.4 / dPageDpiY;
pdfWriter.put_Width(dWidth);
pdfWriter.put_Height(dHeight);
pReader->DrawPageOnRenderer(&pdfWriter, i, NULL);
pdfWriter.EndCommand(c_nPageType);
}
*/
}
// на какую страницу, писатель PdfWriter, IRenderer с командами дозаписи
pReader->AddToPage(0, &pdfWriter, NULL);
//pdfWriter.SaveToFile(NSFile::GetProcessDirectory() + L"/res.pdf");
RELEASEOBJECT(pReader);
RELEASEOBJECT(pApplicationFonts);
return 0;
}