我有一個pdf文件,當我用記事本++打開時,需要做一些小的調整。 如果我手動執行,它工作正常。 我想在一個小型的C++程序中做到這一點。 我試圖做的是讀爲二進制流,並調整運行的內容。 例如:在C++中調整pdf文件內容
std::ofstream outputStream(output,std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
std::ifstream inputStream(input, std::ofstream::in | std::ifstream::binary);
for(std::string stringInput; getline(inputStream,stringInput);)
{
if (stringInput.find("abc") != std::string::npos && stringInput.find("#1") != std::string::npos)
stringInput.replace(....);
outputStream << stringInput << endl;
stringInput.clear()
}
但是,它永遠不會匹配。並在那裏。不知道爲什麼。 我對二進制文件/ io方法做錯了什麼? 這是正確的方法嗎? 當我試圖讀取文本文件,它沒有寫新行,它不能處理除字符以外的任何東西。林不知道爲什麼強硬
此外,黑客用自己的方式爲PDF格式,試圖替換/插入的東西可能最終破裂,絕對不是正確的前進道路。不要依賴它的工作。 – Thomas
你想用什麼樣的文字來取代這種方式?希望不會內容串流?他們一般可以使用完全自定義的編碼,所以他們可能看起來像完全亂碼給你。 – mkl
好吧,沒有。我想要替換一個經過編碼的小部分。我可以在記事本++中看到它作爲常規文本。如果我用記事本「手工」修復它,它工作正常。所以我只想應用自動修復。 – buddy123